0

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.

#sample data can be download from:
https://github.com/Keykiwinnie/myproject/blob/main/sampledata.csv

#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


梁琦奇
  • 1
  • 1
  • Could we have a [mcve] please ... ? – Ben Bolker Jun 19 '23 at 18:15
  • Hi Ben, Thanks for the link. I tried to use the minimum code I could. I am afraid that any deletion of the code above might affect clarity. – 梁琦奇 Jun 20 '23 at 19:40
  • 1
    @梁琦奇 I believe the issue at this point is not minimality, but reproducibility. Without sample data we can't run a single line of your code. `dput()` is an easy way to share sample data, e.g., `dput(S2[1:20, ])` will give the first 20 rows of `S2` in a copy/pasteable format including all data types. – Gregor Thomas Jun 20 '23 at 19:56
  • Hi Gregor, thank you for clarification! I provided sample data, which can be downloaded from the url I posted above. – 梁琦奇 Jun 21 '23 at 17:05

0 Answers0