| sim_mediation | R Documentation |
A synthetic dataset mimicking a clustered education study with a continuous treatment (tutoring hours), a continuous mediator (mid-year test score), and a continuous outcome (end-of-year test score). Designed to illustrate RobustMediate with realistic effect sizes and non-trivial confounding.
sim_mediation
A data frame with 600 rows (30 schools x 20 students) and 7 columns:
Factor. School identifier (30 levels). Use as cluster_var.
Numeric. End-of-year test score (outcome).
Numeric. Tutoring hours received (continuous treatment, >= 0).
Numeric. Mid-year test score (mediator).
Numeric. Prior achievement (continuous covariate).
Integer (0/1). Free-lunch status (binary covariate).
Numeric. Parental education index (continuous covariate).
The data-generating process sets:
NDE (X → Y direct path) ~= 0.25
NIE (X → M → Y path) ~= 0.35
TE ~= 0.60
% mediated ~= 58%
Use these as a ground truth to assess estimation accuracy.
Generated via data-raw/generate_sim_data.R. See that script for
the full data-generating process.
data(sim_mediation)
str(sim_mediation)
summary(sim_mediation[, c("Y","X","M")])
fit <- robustmediate(
treatment_formula = X ~ Z1 + Z2 + Z3,
mediator_formula = M ~ X + Z1 + Z2 + Z3,
outcome_formula = Y ~ X + M + Z1 + Z2 + Z3,
data = sim_mediation,
cluster_var = "school",
R = 500
)
diagnose(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.