Learn R Programming

DMAR (version 1.0.0)

ss_aipe_mixed_effects_sensitivity: Sensitivity Analysis for Sample Size Planning From the AIPE Perspective for a Mixed-Effects Fixed Effect

Description

Quantifies how much misspecification of the variance components (\(\sigma^2_Y\), \(\sigma^2_X\), and the intraclass correlation \(\mathrm{icc}\)) distorts an AIPE-based sample size plan for a cluster-level fixed effect under a two-level random-intercept model. On each replication the function simulates K clusters of cluster_size observations each from $$Y_{ki} = \beta\,X_k + u_k + \epsilon_{ki},$$ with \(X_k \sim N(0, \sigma^2_X)\), \(u_k \sim N(0, \mathrm{icc}\cdot\sigma^2_Y)\), and \(\epsilon_{ki} \sim N(0, (1 - \mathrm{icc})\sigma^2_Y)\). The model is then refit by either lme4::lmer (if available) or by GLS-by-cluster aggregation, and a Wald CI on the fixed effect is recorded.

Usage

ss_aipe_mixed_effects_sensitivity(
  true_sigma2_y = NULL,
  true_sigma2_x = NULL,
  true_icc = NULL,
  true_beta = 0,
  estimated_sigma2_y = NULL,
  estimated_sigma2_x = NULL,
  estimated_icc = NULL,
  width,
  cluster_size = 20L,
  specified_K = NULL,
  conf_level = 0.95,
  G = 1000,
  print_iter = FALSE,
  filename = NULL
)

Value

A data.frame with rows for mean / median / SD of the realized fixed-effect estimate and CI width, the proportion of intervals at or below width, tail-specific and overall non-coverage of true_beta, and the input echoes.

Arguments

true_sigma2_y

Population total variance of Y.

true_sigma2_x

Population variance of the cluster-level predictor.

true_icc

Population intraclass correlation (between-cluster share of total variance).

true_beta

Population fixed-effect slope (default 0).

estimated_sigma2_y, estimated_sigma2_x, estimated_icc

Planning values passed to ss_aipe_mixed_effects; supply all three or specified_K but not both.

width

Desired full width of the CI on the fixed effect.

cluster_size

Number of observations per cluster (assumed balanced).

specified_K

Number of clusters to evaluate.

conf_level

Confidence level (default 0.95).

G

Number of Monte Carlo replications.

print_iter

Logical.

filename

Optional path for a comma separated file recording every replication (the fixed effect estimate, the two confidence limits, the interval width, and two indicators of whether the interval missed true_beta 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

McNeish, D., & Kelley, K. (2019). Fixed effects versus mixed effects models for clustered data: Reviewing the approaches, disentangling the differences, and making recommendations. Psychological Methods, 24, 20--35. tools:::Rd_expr_doi("10.1037/met0000182")

Maxwell, S. E., Delaney, H. D., & Kelley, K. (2027). Designing experiments and analyzing data: A model comparison perspective (4th ed.). Routledge. (See Chapters 15 and 16 on mixed-effects models.)

See Also

ss_aipe_mixed_effects, icc_lmer

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_indirect_effect_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()

Other mixed models: R2_mixed_effects(), R2_mixed_effects_decomposition(), icc_lmer(), manova_split_plot(), mixed_anova(), ss_aipe_mixed_effects(), ss_power_mixed_effects(), ss_power_split_plot_anova()

Examples

Run this code
# Monte Carlo sensitivity check, reduced sizes for a fast example.
set.seed(113)
ss_aipe_mixed_effects_sensitivity(
  true_sigma2_y = 1, true_sigma2_x = 1, true_icc = 0.10,
  true_beta = 0.30,
  specified_K = 25, cluster_size = 10,
  width = 0.40,
  G = 25, print_iter = FALSE
)

Run the code above in your browser using DataLab