pitakakariki / simr

Power Analysis of Generalised Linear Mixed Models by Simulation
69 stars 19 forks source link

Should I use full models when using Powersim? #149

Closed sanjiangxiaodu closed 5 years ago

sanjiangxiaodu commented 5 years ago

I tried using powersim from R package simr to estimate the number of participants that I need for an experiment. I performed the simulation based on the data from my pilot study. The model I used is sketched below:

fit <- glmer(B ~ a+b+a:b (1+a+b+a:b|Subject) + (1+a+b+a:b|Item), family = binomial(link="logit"), data = data, control = glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=50000), tol = .0001))

in which Subject and Item mean the distinct id of subjects and items from the pilot study. I want to know test how the power of the interaction term (a:b) changes with the growth of the number of participants. The code I am using is:

fit2<- extend(fit, along="Subject", n = 84) sim <- powerCurve(fit2, test = fcompare(~a+b), along = "Subject", breaks=c(48,60,72,84), nsim = 5000)

But the results of the simulation was rather bizarre. To begin with, the power of the interaction grew smaller when the number of participants increased from 72 to 84, which I believe is incompatible with the normal observation that the power increases with the number of participants. Second, I tried using the full random model to perform the simulation, but it is really slow (it took me weeks to get just one result). I was wondering if I can use a simpler random model to perform the simulation.

To reiterate my question: first, why my simulated power decreased with the increase of the number of participants? Is there something wrong with my code? Second, can I use a simpler random model for the simulation in order to save time? Thanks in advance!

pitakakariki commented 5 years ago

Sorry, but I don't have the resources to help with general questions about power analyses.

Decreasing power with increasing sample size usually means something is wrong with the model specification and test. You could check by setting effect size to zero and seeing if you get the expected 5% "power" (false positive) rate.

sanjiangxiaodu commented 5 years ago

Thanks a lot for your help!