Power analysis for interaction models, by simulation. A set of n.iter simulations is run for each unique combination of model settings.

power_interaction(
n.iter,
N,
r.x1.y,
r.x2.y,
r.x1x2.y,
r.x1.x2,
rel.x1 = 1,
rel.x2 = 1,
rel.y = 1,
skew.x1 = 0,
skew.x2 = 0,
skew.y = 0,
transform.x1 = "default",
transform.x2 = "default",
transform.y = "default",
alpha = 0.05,
q = 2,
cl = NULL,
ss.IQR = 1.5,
detailed_results = FALSE,
full_simulation = FALSE,
seed = NULL
)

## Arguments

n.iter Number of iterations. The number of simulations to run for each unique setting combination. Must be a positive integer. Sample size. Must be a positive integer. Has no default value. Can be a single value or a vector of values. Pearson's correlation between x1 and y. Must be between -1 and 1.. Has no default value. Can be a single value or a vector of values. Pearson's correlation between x2 and y. Must be between -1 and 1.. Assumed to be the 'moderator' in some functions. Has no default value. Can be a single value or a vector of values. Pearson's correlation between the interaction term x1x2 (x1 * x2) and y. Must be between -1 and 1.. Has no default value. Can be a single value or a vector of values. Pearson's correlation between x1 and x2. Must be between -1 and 1.. Has no default value. Can be a single value or a vector of values. Reliability of x1 (e.g. test-retest reliability, ICC, Cronbach's alpha). Default is 1 (perfect reliability). Must be greater than 0 and less than or equal to 1. Reliability of x2 (e.g. test-retest reliability, ICC, Cronbach's alpha). Default is 1 (perfect reliability). Must be greater than 0 and less than or equal to 1. Reliability of xy (e.g. test-retest reliability, ICC, Cronbach's alpha). Default is 1 (perfect reliability). Must be greater than 0 and less than or equal to 1. Skew of x1. Default is 0 (normally distributed). Skew of x2. Default is 0 (normally distributed). Skew of y. Default is 0 (normally distributed). Transform x1? Options are "default", "binary", or "gamma". "binary" will cause variable to be binarized - 2 unique values. Default ("default") will pick "gamma" if variables are skewed. Transform x2? Options are "default", "binary", or "gamma". "binary" will cause variable to be binarized - 2 unique values. Default ("default") will pick "gamma"if variables are skewed. Transform y? Options are "default", "binary", or "gamma". "binary" will cause variable to be binarized - 2 unique values. Default ("default") will pick "gamma" if variables are skewed. If variables are skewed or binary, should correlations be adjusted so that output data has the specified correlation structure? Default is TRUE. The alpha. At what p-value is the interaction deemed significant? Default is 0.05. Simple slopes. How many quantiles should x2 be split into for simple slope testing? Default is 2. Simple slope testing returns the effect-size (slope) of y~x1 for the two most extreme quantiles of x2. If q=3 then the two slopes are y~x1 for the bottom 33% of x2, and the top 33% of x2. Number of clusters to use for running simulations in parallel (recommended). Default is 1 (i.e. not in parallel). Simple slope IQR. Multiplier when estimating the distribution of simple slopes within each simulation setting. Default is 1.5. Default is FALSE. Should detailed results be reported? Default is FALSE. If TRUE, will return a list that includes the full per-simulation results. Simulation seed. Default is NULL, in which case a seed will be chosen at random and echoed to the user. This seed can then be used to repeat the simulation with identical results.

## Value

A data frame containing the power (% significant results) for each unique setting combination. If full_simulation = TRUE will return a list, with one data frame that includes power, and a second that includes raw simulation results.

## Examples

if (FALSE) {
power_interaction(n.iter=1000, N=seq(100,300,by=10),r.x1.y=0.2, r.x2.y=.2,r.x1x2.y=0.5,r.x1.x2=.2)
}