I have a model with two factors: a (4 levels) and b (3 levels). Each participant receives two problems (id as a random effect). I want to estimate sample size based on pilot data to give me sufficient power to detect an interaction effect.
The model would be as follows:
mod1 <- lmer(outcome ~ a*b+ (1 | id), data).
If I run a powerSim on the interaction given the current data (without changing effect sizes), the power is ~ 66% using the following:
powerSim(mod1, fixed(“a:b”, "lr"), nsim=100)
And is similar if I were to test the interaction using fcompare (to the main effects):
powerSim(mod1, fcompare(~ a+b), nsim=100)
Now I know that estimating power based on one’s own data is not good, so I want to change the effect size estimates. However, I am unsure whether I need to change each fixed effect (e.g., a1:b1, a2:b1…) separately, or if there is a way to test the whole interaction with one test (e.g., like the fcompare test above)? If I do need to change the fixed effect estimate for each of the interaction terms, do I do so individually, estimate the power/sample size, and repeat for each fixed effect or do all changes in the same model (e.g., change all fixed effects)?
fixef(mod1)["a1:b1"] <- 2
fixef(mod1)["a1:b2"] <- 2.1 ...
If not, how do I change the effect estimate for the interaction term to test the whole interaction?
The next step would then be to extend the model and increase the sample within each group, for example:
mod2 <- extend(mod1, within=“a+b”, n=100)
I have seen the interaction term tested when one of the predictors is continuous, but not when both are factors. Any help would be much appreciated.