Let's say I have a data set (with a binary DV) which I used a generalized linear mixed-effects model on. I am currently trying to run a simulation-based power analysis to determine the sample size I should try to collect for a replication attempt.
I know about the simulate function for fitted lme4 model objects, which will create simulated responses that follow the size and structure of the actual dataset.
My question is, how can I use this fitted model object to run an a-priori power analysis for my replication?. In other words, is there an easy way to extract the necessary information from the simulate function, vary the sample size, then to simulate responses?
Here is a simple example with ten subjects that should give me a good starting place. The data here are totally fake so the effects are not close to what I have in the pilot data.
The two variables of interest are age in months (between subjects) and whether the stimulus is "similar" or "dissimilar" (within subjects). Each individual is exposed to three items within each similarity group, for a total of six binary responses for each subject. As seen in the model, I am interested in a possible interaction between age and similarity and include a random slope of similarity to do this.
Let me know if I need to modify anything/provide more information to make things easier.
set.seed(28) fakeData <- data.frame(ID = rep(1:10, each = 6), months = rep(round(runif(10, min = 60, max = 80)), each = 18), similarity = rep(c("Sim", "Dissim"), each = 3), response = sample(c(0, 1), 60, replace = TRUE)) fakeModel <- glmer(response ~ months * similarity + (similarity | ID), family = binomial, data = fakeData) summary(fakeModel)