Learn R Programming

DMAR (version 1.0.0)

ss_aipe_indirect_effect_sensitivity: Sensitivity Analysis for Sample Size Planning From the AIPE Perspective for an Indirect Effect

Description

Quantifies how much misspecification of the population mediation path coefficients \(a\) and \(b\) distorts an AIPE-based sample size plan for the indirect effect \(ab\). On each replication the function simulates a three-variable mediation system \(X \to M \to Y\) of size n with population path coefficients true_a and true_b, fits the two regressions of M on X and Y on M and X, computes the sample indirect effect \(\hat a \hat b\), and forms the interval the plan targeted: the symmetric Wald interval from the delta method standard error (method = "closed_form") or the Monte Carlo interval (method = "monte_carlo"), matching ss_aipe_indirect_effect.

Usage

ss_aipe_indirect_effect_sensitivity(
  true_a = NULL,
  true_b = NULL,
  estimated_a = NULL,
  estimated_b = NULL,
  width,
  specified_N = NULL,
  method = c("closed_form", "monte_carlo"),
  conf_level = 0.95,
  B = 5000L,
  G = 1000,
  print_iter = FALSE,
  filename = NULL
)

Value

A data.frame with rows for mean / median / SD of

\(\hat a \hat b\) and the CI width, the proportion of intervals at or below width, tail-specific and overall non-coverage of the population value true_a * true_b, and the input echoes.

Arguments

true_a

Population path coefficient a (from X to M); the data generating value.

true_b

Population path coefficient b (from M to Y after controlling for X); the data generating value.

estimated_a, estimated_b

Path coefficients used to plan the study (passed to ss_aipe_indirect_effect). Supply both or neither (if neither, supply specified_N).

width

Desired full width of the CI on \(ab\).

specified_N

Sample size to evaluate (incompatible with estimated_a / estimated_b).

method

One of "closed_form" (default) or "monte_carlo"; the interval computed on each replication, also forwarded to the planner when the sample size is planned from estimated_a and estimated_b. A planning call with method = "monte_carlo" runs the planner's a priori Monte Carlo search at its default G, so it takes a few seconds.

conf_level

Confidence level (default 0.95).

B

Number of Monte Carlo draws used for the indirect-effect CI when method = "monte_carlo" (default 5000).

G

Number of outer simulation replications (default 1000).

print_iter

Logical.

filename

Optional path for a comma separated file recording every replication (the sample indirect effect \(\hat a \hat b\), the two confidence limits, the interval width, and two indicators of whether the interval missed true_a * true_b below or above): nothing is written when filename is NULL (the default), a new file with a header row is created otherwise, an existing file at that path is appended to, and a throwaway run should point it at tempfile(fileext = ".csv").

Author

Ken Kelley [email protected]

References

Preacher, K. J., & Kelley, K. (2011). Effect size measures for mediation models: Quantitative strategies for communicating indirect effects. Psychological Methods, 16(2), 93--115. tools:::Rd_expr_doi("10.1037/a0022658")

Tofighi, D., & Kelley, K. (2020). Improved inference in mediation analysis: Introducing the model-based constrained optimization procedure. Psychological Methods, 25, 496--515. tools:::Rd_expr_doi("10.1037/met0000259")

Maxwell, S. E., Delaney, H. D., & Kelley, K. (2027). Designing experiments and analyzing data: A model comparison perspective (4th ed.). Routledge.

See Also

ss_aipe_indirect_effect, var_indirect_effect

design_consequences for what a chosen design delivers: power, the Type S (sign) and Type M (exaggeration) errors of the significance filter, and the expected confidence interval width.

Other AIPE sample size planning: ss_aipe_c_sensitivity(), ss_aipe_cliff_delta(), ss_aipe_cliff_delta_sensitivity(), ss_aipe_composite_sem(), ss_aipe_equivalence_r(), ss_aipe_equivalence_r_sensitivity(), ss_aipe_equivalence_smd(), ss_aipe_equivalence_smd_sensitivity(), ss_aipe_icc(), ss_aipe_icc_sensitivity(), ss_aipe_indirect_effect(), ss_aipe_mixed_effects_sensitivity(), ss_aipe_omega_squared(), ss_aipe_omega_squared_sensitivity(), ss_aipe_partial_r(), ss_aipe_partial_r_sensitivity(), ss_aipe_pcm_sensitivity(), ss_aipe_r(), ss_aipe_r_sensitivity(), ss_aipe_reliability_sensitivity(), ss_aipe_semipartial_r(), ss_aipe_semipartial_r_sensitivity()

Examples

Run this code
# Reduced replications and a wide target width keep this fast.
set.seed(113)
ss_aipe_indirect_effect_sensitivity(
  true_a = 0.4, true_b = 0.3,
  estimated_a = 0.4, estimated_b = 0.3,
  width = 0.40, method = "closed_form",
  G = 50, print_iter = FALSE
)

Run the code above in your browser using DataLab