| ab | R Documentation |
This function computes the indirect (mediated) effect in a mediation model
and either tests its significance or calculates statistical power.
It uses regression coefficients from an independent variable to a mediator (a)
and from the mediator to an outcome (b) with their standard errors.
Variance can be estimated using Sobel, Aroian, or Goodman formulas.
ab(
type = c("power", "test"),
n = 25000,
a = 0.15,
sa = 0.01,
b = log(1.19),
sb = 0.01,
alpha = 0.05,
fold = 1,
method = c("sobel", "aroian", "goodman")
)
type |
Character; |
n |
Numeric; baseline sample size for power calculation (default 25000). |
a |
Numeric; regression coefficient from independent variable to mediator. |
sa |
Numeric; standard error of |
b |
Numeric; regression coefficient from mediator to outcome. |
sb |
Numeric; standard error of |
alpha |
Numeric; significance level (default 0.05) for power calculation. |
fold |
Numeric; multiplicative factor for sample size in power calculation. |
method |
Character; one of |
The indirect effect is ab, representing the portion of the effect of X on Y
transmitted through mediator M.
Standard errors of the indirect effect are approximated using the delta method:
Sobel: SE = \sqrt{b^2 s_a^2 + a^2 s_b^2}
Aroian: SE = \sqrt{b^2 s_a^2 + a^2 s_b^2 + s_a^2 s_b^2}
Goodman: SE = \sqrt{b^2 s_a^2 + a^2 s_b^2 - s_a^2 s_b^2}
The z-statistic is z = ab / SE(ab), assumed to follow a standard normal
distribution under H_0: ab = 0.
Two-sided p-value: p = 2 \Phi(-|z|)
95% confidence interval: ab \pm 1.96 \cdot SE(ab)
Power is based on a non-central chi-square approximation:
\lambda = z^2 \cdot \text{fold}
Power = P(\chi^2_1(\lambda) > \chi^2_{1,1-\alpha}),
where \chi^2_{1,1-\alpha} is the critical value at significance level \alpha.
These tests assume large samples. For small samples, bootstrap confidence intervals are recommended.
If type = "test", a named numeric vector with:
effect: indirect effect estimate (ab)
se: standard error
z: z-statistic
p: two-sided p-value
lcl: lower 95% confidence limit
ucl: upper 95% confidence limit
If type = "power", a named numeric vector with:
sample_size: effective sample size (fold * n)
power: estimated statistical power
freathy08gap
\insertRefkline05gap
\insertRefmackinnon08gap
\insertRefpreacher01gap
## Not run:
# Test mediation effect
ab(a = 0.15, sa = 0.01,
b = log(1.19), sb = 0.01,
method = "aroian")
# Power calculation for 10% increase in sample size
ab(type = "power", n = 25000,
a = 0.15, sa = 0.01,
b = log(1.19), sb = 0.01,
fold = 1.1)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.