Skip to contents

Test the interaction from a single simulated data set.

Usage

test_interaction(
  data,
  alpha = 0.05,
  detailed_results = FALSE,
  q = 2,
  simple = FALSE
)

Arguments

data

Simulated data set. Output of 'generate_interaction()'.

alpha

The alpha. At what p-value is the interaction deemed significant? Default is 0.05.

detailed_results

Should results beyond the linear model (change in R2, simple slopes, correlations, and confidence intervals) be returned? Default is FALSE.

q

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.

simple

For internal use. Default is FALSE.

Value

Either a named list or a data frame containing the results of the regression y~x1+x2+x1*x2, the pearson's correlation between y, x1,x2, and x1x2, and the slopes of the simple slopes.

Examples

dataset <- generate_interaction(N = 250,r.x1.y = 0,r.x2.y = .1,r.x1x2.y = -.2,r.x1.x2 = .3)
test_interaction(data = dataset, alpha=0.05, q=2)
#> $linear.model
#>          Estimate Std. Error     t value     Pr(>|t|)
#> x1   -0.004107034 0.06399475 -0.06417767 9.488809e-01
#> x2    0.138731281 0.06390510  2.17089542 3.089570e-02
#> x1x2 -0.243264153 0.05884106 -4.13425839 4.887912e-05
#>