simr icon indicating copy to clipboard operation
simr copied to clipboard

Many errors in simulation

Open Code3020 opened this issue 1 year ago • 7 comments

Hi,

In the simulation I tried to run based on the model output of a model I tested, there were lots of errors - in 1000 simulations, there were 1000 errors.

Here are the codes: b = c(2.66,.11,-.65,-.03,.003,-.01) V1 <- 1.16
V2 <- matrix(c(1.16,0,0,.02),2) s <- .74

model1 <- makeLmer(pos_mean ~ sleep_quality * dep01 + Gender + Age + (1 + sleep_quality|ID), fixef=b, VarCorr=V2, sigma=s, data=df1) print(model1)

sim_p <- powerSim(model1, fixed("x","kr"), test = fcompare(~ sleep_quality * dep01), alpha=.05, nsim=1000)

print(sim_p)

Here is the output:

Power for predictor 'sleep_quality', (95% confidence interval):

0.00% ( 0.00, 0.37)

Test: Kenward Roger (package pbkrtest)

Based on 1000 simulations, (0 warnings, 1000 errors)

alpha = 0.05, nrow = NA

Time elapsed: 0 h 0 m 0 s

Many thanks for your help!

Code3020 avatar Feb 22 '24 15:02 Code3020

You've passed powerSim two test specifications: fixed("x","kr") and test = fcompare(~ sleep_quality * dep01). Because you've named the second one, the first is being used as the sim argument which is causing the errors.

pitakakariki avatar Feb 22 '24 17:02 pitakakariki

Thanks for your quick reply! I tried several single tests but I still got the same amount of errors and the same output.

Here are the ones I've tried: fixed("kr"), test = fixed("sleep_quality"), and test = fcompare(~ sleep_quality * dep01)

Code3020 avatar Feb 23 '24 11:02 Code3020

You can access the error log using sim_p$errors.

pitakakariki avatar Feb 25 '24 04:02 pitakakariki

All the error messages are the same

non-conformable arrays

Code3020 avatar Feb 27 '24 09:02 Code3020

I don't have access to your df1 data frame, but that error often comes up if there is missing data.

pitakakariki avatar Mar 02 '24 19:03 pitakakariki

Thanks for the hint!

Only one variable used in the formula had missing data so I subsetted the data by removing the rows containing these missing data. But now I got 1000 warnings and 1000 errors per 1000 simulations. The warnings are

boundary (singular) fit: see help('isSingular')

I guess that it's because I cluster-mean standardized the continuous independent variables.

Any suggestions or thoughts?

Code3020 avatar Apr 05 '24 10:04 Code3020

If you are getting errors those are what you should focus on.

pitakakariki avatar Apr 08 '24 04:04 pitakakariki