Learn R Programming

iMediate (version 0.5.5)

pwr.mdn: Power and Sample Size for Mediation Analysis

Description

pwr.mdn Compute power of tests related to mediation analysis or sample size to achieve desired power.

Usage

pwr.mdn(a, b, c.p, tau1, tau2, n = NULL, power = NULL, alpha = 0.05)

Arguments

a

specified value for coefficient \(a\)

b

specified value for coefficient \(b\)

c.p

specified value for coefficient \(c'\)

tau1

specified value of the ratio of residual variance of mediator \(M\) to the variance of the treatment \(X\)

tau2

specified value of the ratio of residual variance of outcome \(Y\) to the variance of the treatment \(X\)

n

the sample size available. Either "n" or "power" must be provided

power

a value specifying the desired power. Either "n" or "power" must be provided

alpha

specified significance level

Value

A \(2\times 5\) matrix

Details

This model is for the basic three-factor model. If coefficients are standardized, then \(\tau_1=1-a^2\) and \(\tau_2=1-(c')^2-b^2-2abc'\).

References

Wang, K. (2018) Understanding power anomalies in mediation analysis. Psychometrika 83 (2), 387-406.

Examples

Run this code
# NOT RUN {
n = 100
X = rnorm(n)
s2X = mean((X-mean(X))^2)
a=0.3
b=0.3
c.p = a*b

pwr.mdn(a, b, c.p, 1/s2X, 1/s2X, alpha=0.05, power=0.8)   
pwr.mdn(a, b, c.p, 1/s2X, 1/s2X, alpha=0.05, n=200)

## Using standardized coefficients
pwr.mdn(a, b, c.p, 1-a^2, 1-c.p^2-b^2-2*a*b*c.p, alpha=0.05, power=0.8)
pwr.mdn(a, b, c.p, 1-a^2, 1-c.p^2-b^2-2*a*b*c.p, alpha=0.05, n=200)

# }

Run the code above in your browser using DataLab