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.
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
)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.
Population total variance of Y.
Population variance of the cluster-level predictor.
Population intraclass correlation (between-cluster share of total variance).
Population fixed-effect slope (default 0).
Planning
values passed to ss_aipe_mixed_effects; supply
all three or specified_K but not both.
Desired full width of the CI on the fixed effect.
Number of observations per cluster (assumed balanced).
Number of clusters to evaluate.
Confidence level (default 0.95).
Number of Monte Carlo replications.
Logical.
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").
Ken Kelley [email protected]
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.)
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()
# 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