MyNixOS website logo
Description

Power Analyses for Interaction Effects in Cross-Sectional Regressions.

Power analysis for regression models which test the interaction of two or three independent variables on a single dependent variable. Includes options for correlated interacting variables and specifying variable reliability. Two-way interactions can include continuous, binary, or ordinal variables. Power analyses can be done either analytically or via simulation. Includes tools for simulating single data sets and visualizing power analysis results. The primary functions are power_interaction_r2() and power_interaction() for two-way interactions, and power_interaction_3way_r2() for three-way interactions. Please cite as: Baranger DAA, Finsaas MC, Goldstein BL, Vize CE, Lynam DR, Olino TM (2023). "Tutorial: Power analyses for interaction effects in cross-sectional regressions." <doi:10.1177/25152459231187531>.

InteractionPoweR

CRANstatus metacrandownloads

The {InteractionPoweR} package conducts power analyses for regression models in cross-sectional data sets where the term of interest is an interaction between two or three variables, also known as ‘moderation’ analyses. The package includes functions for simulating data sets, conducting power analyses, and plotting and interpreting results. Notable package features include (1) the ability to compute power for interactions between two continuous variables, (2) effect sizes are all specified as the cross-sectional Pearson’s correlation, (3) simulations do not assume that the interacting variables are independent, (4) any variable in the model, including the outcome, can have anywhere from 2 (i.e., binary) to 20 discrete values, and (5) analyses can incorporate the effects of reliability, both of the interacting variables, as well as of the outcome variable.

For more information see our tutorial paper, the package vignette, and the FAQ.

We have a Shiny app which implements the major functions for simulation-based power analyses in a user-friendly point-and-click interface. We also have a simpler Shiny app for computing analytic power. We recommend this app particularly for beginners and users who are new to power analyses. We have also recently added a new shiny app for three-way interactions.

Please report bugs, issues, or questions as an Issue on Github.

Installation

You can install InteractionPoweR from CRAN with:

install.packages("InteractionPoweR")

You can also install the development version of InteractionPoweR from github with:

install.packages("devtools")
devtools::install_github("dbaranger/InteractionPoweR")

If you get an error about a corrupt .rdb file, try restarting your R session.

Basic Usage

The simplest use-case is when all the input parameters are known. We know the population-level correlation between our predictors (x1 and x2) and our outcome, we have a smallest effect size of interest in mind for our interaction effect size, and our sample size is already set (maybe we are conducting secondary data analysis). Power can be determined with a single command.

First - analytic power, using variable correlations (and reliability, if provided) to estimate how much additional variance is explained by the interaction term.

library(InteractionPoweR)

test_power<-power_interaction_r2(
  alpha = 0.05,             # alpha, for the power analysis
  N = 350,                  # sample size
  r.x1x2.y = .15,           # interaction effect to test (correlation between x1*x2 and y)
  r.x1.y = .2,              # correlation between x1 and y
  r.x2.y = .1,              # correlation between x2 and y
  r.x1.x2 = .2              # correlation between x1 and x2
)

test_power
#>         pwr
#> 1 0.8131373

We see that we have 81% power.

We can also use simulations to estimate power. Simulations are particularly useful because they can account for non-normal data, including binary and likert variables.

NB In all these examples we use 1000 simulations for speed (n.iter = 1000), but for robust results we recommend 10,000 simulations (n.iter = 10000).

set.seed(2022)
test_power<-power_interaction(
  n.iter = 10000,            # number of simulations per unique combination of input parameters
  alpha = 0.05,             # alpha, for the power analysis
  N = 350,                  # sample size
  r.x1x2.y = .15,           # interaction effect to test (correlation between x1*x2 and y)
  r.x1.y = .2,              # correlation between x1 and y
  r.x2.y = .1,              # correlation between x2 and y  
  r.x1.x2 = .2,             # correlation between x1 and x2 
  k.y =  5,                 # y is likert
  k.x1 = 2                  # x1 is binary
)

test_power
#>     N    pwr
#> 1 350 0.8086

The simulation’s accuracy will increase with more iterations.

Citation

If you use {InteractionPoweR} in a publication, please cite our tutorial paper:

Baranger DAA, Finsaas MC, Goldstein BL, Vize CE, Lynam DR, Olino TM (2023). “Tutorial: Power analyses for interaction effects in cross-sectional regressions.” Advances in Methods and Practices in Psychological Science. 6(3). doi: 10.1177/25152459231187531

Metadata

Version

0.2.2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows