rpsychologist / powerlmm

powerlmm R package for power calculations for two- and three-level longitudinal multilevel/linear mixed models.
100 stars 12 forks source link

simulate: Bug when a parameter is NA, but the term is still included in model formula #6

Closed rpsychologist closed 6 years ago

rpsychologist commented 6 years ago

The following code will give an error.

library(powerlmm)
p <- study_parameters(n1 = 6,
                      n2 = 5,
                      n3 = 5,
                      icc_pre_subject = 0.5,
                      icc_pre_cluster = NA,
                      var_ratio = 0.02,
                      icc_slope = 0.05,
                      cohend = 0
                      )

res <- simulate(p, nsim = 5, formula = "y ~ time * treatment + (1 | subject) + (1 | cluster)")
summary(res)

summary will fail, code will work if icc_pre_cluster = 0 is used instead.