I am planning for a rather simple mixed design study. I have one within-subject factor (2-level, repeatedly measure/treatment twice) and one continuous between-subject factor. Now I am interested in potential interaction between the two. I wonder if there is any software or R-code that I can use to estimate the required sample size (i.e. level-2 sample size)?


In general, the most versatile way to perform sample size calculations in mixed models is via simulation. This entails the following three steps:

  1. Simulate a dataset from the specific design you are interested in, i.e., with a specific choice for the number of subjects, the number of repeated measurements, etc. This step requires a complete specification of the mixed model you are planning to use including not only the mean parameters (i.e., fixed effects) but also all parameters that specify the variance-covariance structure of your data.
  2. Fit the mixed model in this dataset.
  3. Perform the hypothesis test of interest and retain the p-value.

If you repeat these steps a sufficient number of times (e.g., 1000), you can obtain an estimate of the power for this specific design by simply calculating the proportion of times the p-value was significant at a pre-specified significance level $\alpha$. Then, you could change some of the settings of the design, e.g., increase the number of subjects and see how does this affect the power.

For some type of mixed models, these calculations are streamlined by the simr package in R.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.