Expand description
Simulated data sets: the data generating processes of DoubleML’s
make_* functions, for examples, tests and simulation studies.
Every generator is a struct whose fields are the parameters, with
DoubleML’s defaults, and generate(seed) draws a data set. The draws come
from a seeded ChaCha generator, so they are reproducible but not identical
to DoubleML’s NumPy draws; the distributions are the same.
use dml_core::datasets::PlrCcddhnr2018;
use dml_core::{learner::Ols, Plr};
let sim = PlrCcddhnr2018 { n_obs: 300, dim_x: 5, ..Default::default() }.generate(42).unwrap();
let fit = Plr::new(Ols::new(), Ols::new()).fit(&sim.to_data().unwrap()).unwrap();
assert!((fit.coef()[0] - 0.5).abs() < 0.3);| Generator | DoubleML | Design |
|---|---|---|
PlrCcddhnr2018 | make_plr_CCDDHNR2018 | partially linear regression |
PlrTurrell2018 | make_plr_turrell2018 | partially linear regression |
ConfoundedPlr | make_confounded_plr_data | PLR with an unobserved confounder |
PlivChs2015 | make_pliv_CHS2015 | partially linear IV, many instruments |
PlivMultiwayClusterCkms2021 | make_pliv_multiway_cluster_CKMS2021 | PLIV with two-way clustering |
LplrLzz2020 | make_lplr_LZZ2020 | logistic partially linear regression |
PlprCp2025 | make_plpr_CP2025 | partially linear panel regression |
IrmData | make_irm_data | interactive regression, binary treatment |
ConfoundedIrm | make_confounded_irm_data | IRM with an unobserved confounder |
IrmDiscreteTreatments | make_irm_data_discrete_treatments | multi-valued treatment |
IivmData | make_iivm_data | binary instrument (LATE) |
SsmData | make_ssm_data | sample selection |
HeterogeneousData | make_heterogeneous_data | heterogeneous treatment effects |
DidSz2020 | make_did_SZ2020 | two-period difference-in-differences |
DidCs2021 | make_did_CS2021, make_did_cs_CS2021 | staggered adoption |
SimpleRdd | make_simple_rdd_data | regression discontinuity |
Structs§
- Confounded
Irm - A binary treatment with an unobserved confounder
A, asmake_confounded_irm_data(Sant’Anna and Zhao covariates), with oracle confounding strengths for sensitivity analysis. - Confounded
IrmOracle - Oracle values of
ConfoundedIrm. - Confounded
IrmSimulated - A data set of
ConfoundedIrm. - Confounded
Plr - A partially linear model with an unobserved confounder
Aof given strength (cf_y,cf_d), asmake_confounded_plr_data, for sensitivity analysis.ConfoundedPlrSimulated::oracleholds the long and short regressions and the confounder. - Confounded
PlrOracle - Oracle values of
ConfoundedPlr. - Confounded
PlrSimulated - A data set of
ConfoundedPlr. - DidCs2021
- Callaway and Sant’Anna (2021): staggered adoption over
n_periodsperiods, with cohorts first treated from periodn_pre_treat_periodson, dynamic and heterogeneous effects, unit and time effects. - DidSz2020
- Sant’Anna and Zhao (2020): two periods, a binary treatment and the
transformed covariates
Z.generategives a panel (y = Y₁ − Y₀);generate_cross_sectionsrepeated cross-sections with a time indicator. - Discrete
Treatment Oracle - Oracle values of
IrmDiscreteTreatments. - Discrete
Treatment Simulated - A data set of
IrmDiscreteTreatments. - Heterogeneous
Data - Heterogeneous treatment effects
τ(x) = exp(2x₀) + 3 sin(4x₀)(or3 sin(4x₁)withn_x = 2) on uniform covariates, asmake_heterogeneous_data. - Heterogeneous
Simulated - A data set of
HeterogeneousDatawith the individual effects. - Iivm
Data - A binary instrument
zshifting a binary treatment,d = 1{α_x z + v > 0},y = θd + x'β + uwithcorr(u, v) = 0.3. - IrmData
- Belloni, Chernozhukov, Fernández-Val and Hansen (2017): binary treatment
with
P(d = 1 | x) = expit(c_d x'β)andy = θd + d·c_y x'β + ζ, withc_d,c_yset by the targetR²values. - IrmDiscrete
Treatments - A multi-valued treatment
d ∈ {0, 1, …, n_levels}, asmake_irm_data_discrete_treatments: a latent continuous treatment cut at its quantiles, with a share1 / n_levelsof untreated units. - Lplr
Lzz2020 - Liu, Zhang and Zhou (2020): a binary outcome with
P(y = 1) = expit(αd + r₀(x)), equicorrelated covariates (0.2) clipped to[−2, 2].generatealso returns the outcome probabilities. - Pliv
Chs2015 - Chernozhukov, Hansen and Spindler (2015): partially linear IV with
dim_zinstrumentsz = x[:, :dim_z] + ξ. - Pliv
Multiway Cluster Ckms2021 - Chiang, Kato, Ma and Sasaki (2021): partially linear IV on an
n × mgrid of two-way clusters, with cluster-correlated covariates and errors. - Plpr
Cp2025 - Clarke and Polselli (2025): a static panel with correlated unit effects,
d = m₀(x) + cᵢ + v,y = θd + g₀(x) + αᵢ + u. - PlrCcddhnr2018
- Chernozhukov et al. (2018):
d = a₀x₀ + a₁·expit(x₂) + s₁ε,y = αd + b₀·expit(x₀) + b₁x₂ + s₂ζwith Toeplitz-correlated covariates (0.7^|i−j|). - PlrTurrell2018
- Turrell (2018):
d = m(x'b) + ε,y = θd + g(x'b) + ζwithg(v) = sin²(v),m(v) = sinh(γ) / (2π(cosh(γ) − cos(v − ν))),b_k = 1/kand a random positive definite covariance (scikit-learn’smake_spd_matrix). - Simple
Rdd - A simple RD design (
make_simple_rdd_data): a normal score, uniform covariates entering through polynomials of orderp, effecttauat the cutoff; sharp or fuzzy, with a continuous or binary outcome. - Simulated
- A simulated cross-section: covariates
x, outcomey, treatmentdand, depending on the design, instrumentsz, a selection indicators, a time indicatortor cluster labels (one column per clustering). - Simulated
Panel - A simulated panel in long format (one row per unit and period).
- Simulated
Rdd - A data set of
SimpleRdd: running variable, covariates, outcome, treatment and both potential outcomes. - Simulated
Staggered - A simulated staggered-adoption panel in long format (periods
0, 1, …);cohortis the first treated period,f64::INFINITYfor never treated units. - SsmData
- Sample selection: the outcome is observed when
s = 1, withs = 1{x'β + d + γz + e₀ > 0}; missing at random (mar, errors independent andγ = 0) or nonignorable (corr(e₀, e₁) = 0.8,γ = 1). Unobserved outcomes are 0.
Enums§
- Lplr
Treatment - Treatment of
LplrLzz2020. - Plpr
Design - Functional form of
PlprCp2025.