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.03329051 0.06601911 -0.5042556 0.6145331298
#> x2    0.11107539 0.06493561  1.7105468 0.0884255074
#> x1x2 -0.20153332 0.05546821 -3.6333123 0.0003405689
#>