Sample Size Estimation/Power Analysis Using Simulation in R

I am looking for a way to estimate the number of observations needed for a regression analysis. My hypothesised model is y_post ~ y_pre + x1*x2. My interest lies in whether the interaction term x1:x2 is statistically significant. I assumed a small-to-medium effect size for this x1:x2 term.

My question is: assuming a small-to-medium effect size, what is the sample size needed to detect the effect with a power of 80% and alpha 0.05?

After looking into similar questions, I couldn't find a good and systematic reference books for power analysis. Could anyone suggest a good reference book/book chapter on how to conduct a sample size estimation using simulation in R. I want to learn more about simulation because when I encounter different experimental designs in the future, I could simulate the the sample size again by myself.

My background is psychology. It would be wonderful if the references is also from this field (although it is not necessary).

Many similar questions remained unanswered or not satisfactorily (e.g.,Power Analysis By Simulation, How to simulate a custom power analysis of an lm model (using R), Simulating responses from a factorial experiment for power analysis). Your help would be very much appreciated. Thank you.

• What effect size do you intend to use? There are quite a few effect sizes available for regression models, the coefficients themselves are among them. To simulate a regression model, you probably need to assume quite a few things such as the distribution of the predictors, the coefficients and the residual variance. Once you have decided on those assumptions, the simulations themselves are not that hard. – COOLSerdash Mar 13 '19 at 12:13
• @COOLSerdash Thank you for your comment. I am not very sure about different effect size measures. Let's assume I'm referring to Partial Eta squared. Thank you for pointing out those parameters I will need to assume. However, as if often in real life, most of those parameters are unknown when I am doing an a priori power analysis (but it is almost a must to do the power analysis prior to data collection nowadays). Do you know of any suggestions? Thanks. – JetLag Mar 13 '19 at 12:20
• To be honest, I would just use G*Power instead of simulations in your case. – COOLSerdash Mar 13 '19 at 12:24
• @COOLSerdash Thank you. I think I'll just turn to G*Power then. Thanks. – JetLag Mar 13 '19 at 12:25