I am trying to do some sample size estimation for a glmer model. I have pulled the fixed and random effects from the actual fitted model, but when I try to specify a new model with makeGlmer, I get the above error and it does not complete.
Example:
# Specify required packages
Pkgs <- c( "tidyverse", "lme4", "lmerTest","simr")
# Load packages
lapply(Pkgs, require, c = T)
# Make a frame of predictors
Sub_Groups <- data.frame(Subject = factor(c(1:28)),
Group = factor(c(rep(1, 14), rep(2,14))))
Cat_Cond <- data.frame(expand.grid(Category = factor(c("A", "B", "C")),
Condition = factor(c("D", "E", "F", "G", "H"))))
Sim_Data <- merge(Sub_Groups, Cat_Cond, by = NULL)
# Specify needed argument values
b <- c(1.07018921860115,
0.0493144807004141,
-0.0417342373911914,
0.0151701510233487,
0.10810610398453,
0.544295737183165,
0.728323729029262,
0.0171335499356261)
V1 <- 0.01261291 # random intercept variance
s <- 1.6190 # residual standard deviation
# Usage
#makeGlmer(formula, family, fixef, VarCorr, data)
summary(Mod_Sim <- makeGlmer(y ~
Condition +
Category +
Group +
(1|Subject),
family = gaussian(link = "log"),
fixef = b,
VarCorr = V1,
data = Sim_Data))
This results in the error and warnings:
Error: Invalid grouping factor specification, Subject
In addition: Warning messages:
1: In setParams(object, newparams) :
some parameters not specified in setParams()
2: In rnorm(nsim * length(ftd), ftd, sd = sigma(object)) : NAs produced
Is there a way to find out what parameters are missing from the makeGlmer call and pass them?
I am trying to do some sample size estimation for a glmer model. I have pulled the fixed and random effects from the actual fitted model, but when I try to specify a new model with makeGlmer, I get the above error and it does not complete.
Example:
This results in the error and warnings:
Is there a way to find out what parameters are missing from the makeGlmer call and pass them?
The predictors appear to be fine:
Everything works as expected with makeLmer