Issues with powerSim: Simulating " new levels detected in new data: 120, 125, 336, 347"

I'm running into an issue where I receive the following error when trying to use powerSim to estimate power for my multilevel model. All my variables including DV and IV are continuous variables. Here are my codes for my model and powerSim

#My model:
m1<- lmer(a_p2relsat ~ (Avoidance_centering + Anxiety_centering) * Identification_centering+
(1|ID), control = lmerControl(optimizer = "bobyqa"),data = S2)

#changing effect size of ['Avoidance_centering:Identification_centering'] to 0.2:
model_size <- m1
fixef(model_size) ['Avoidance_centering:Identification_centering'] <- 0.2

# performing power analysis using powerSim()
power_m1 <- powerSim(model_size, test=fcompare(a_p2relsat~Avoidance_centering:Identification_centering),
nsim=400)
power_m1

#the output for power_m1 is listed below:
>power_m1
Power for model comparison, (95% confidence interval):
0.00% ( 0.00, 0.92)
Test: Likelihood ratio
Comparison to a_p2relsat ~ Avoidance_centering:Identification_centering + [re]
Based on 400 simulations, (0 warnings, 400 errors)
alpha = 0.05, nrow = NA
Time elapsed: 0 h 0 m 5 s

#I checked lastResult()$errors, and the output showed:
>lastResult()$errors
stage index message
1 Simulating 1 new levels detected in newdata: 120, 125, 336, 347
2 Simulating 2 new levels detected in newdata: 120, 125, 336, 347
3 Simulating 3 new levels detected in newdata: 120, 125, 336, 347
4 Simulating 4 new levels detected in newdata: 120, 125, 336, 347
5 Simulating 5 new levels detected in newdata: 120, 125, 336, 347
6 Simulating 6 new levels detected in newdata: 120, 125, 336, 347
7 Simulating 7 new levels detected in newdata: 120, 125, 336, 347
8 Simulating 8 new levels detected in newdata: 120, 125, 336, 347
9 Simulating 9 new levels detected in newdata: 120, 125, 336, 347
10 Simulating 10 new levels detected in newdata: 120, 125, 336, 347

I couldn't debug this issue. Is there something wrong in my code that is leading to the error messages? Does anyone have any idea about this ? Many thanks in advance for your time!

1 Like

Hi,
I don't know how your data looks like, but I had a similar issue and it had to do with missing data in for some factor levels. Just from the numbers I would suspect it's about excluded participant IDs.
If you excluded those participants you need to drop their factor levels, else I think the model tried to simulate data for those levels on the bases on no data fed into the original model.
I think you can just use levels(droplevels(S2$ID)) or whatever level has missing data in your dataset.
Hope it helps!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.