Changelog
v0.2.0 (development)
Paper-catchup release: brings the package up to the algorithmic defaults in the 2026-04 paper revision of Acharya, Hainmueller, and Xu (2026).
Major default-behavior change
scfit()now runs the paper’s empirical-Bayes MAP update (paperEnsC5) as the default Stage 2. The returnedbeta_hatis the hybrid (Stage-2-refined), task-expanded matrix that everysc_*quantity function reads. DML point estimates and clustered standard errors are unchanged on the sameseed— they continue to use the Stage-1 single-DNN prediction.- Set
stage2 = "none"onscfit()to recover v0.1 behavior exactly.
New scfit() arguments
stage2: one of"map_c5"(default),"none","varref","mixed_logit". The mixed-logit option implements thelme4::glmerBLUP alternative from paper §A.4 with a deterministic tryCatch fallback to the Stage-1 DNN on convergence failure.stage2_seed: integer seed for the 2nd DNN in the Stage-2 ensemble (default12345L); independent ofseed, so the master-seed bit-exact determinism guarantee extends through Stage 2.
New sc_fit slots
beta_hat_dnn: the Stage-1 single-DNN matrix that DML used.beta_hat_dnn2,beta_hat_ens,beta_hat_resp: auxiliary Stage-2 intermediates.sigma_prior,sigma_post_diag: diagonal prior variance and diagonal posterior variance (from the MAP Hessian).stage2_method,stage2_warnings,stage2_seed: provenance.
New which_beta argument on every quantity function
- Each
sc_*quantity now acceptswhich_beta = c("hybrid", "dnn"). Default"hybrid"reads the Stage-2-refined betas;"dnn"reads the Stage-1 single-DNN view.
New exports
sc_validate_amce(object, subgroup = NULL): pooled (and optionally subgroup) homogeneous-logit comparison against the DML \(\hat\theta\). Mirrors paper §App-D, where the pooled correlation on the paper’s external validation data is near 1. See [Example: Candidate Choice](#sec-sw-validate) for a worked example.
Bug guards
- Regression test against the prototype’s 2026-04-26 prior-indexing bug.
- Bit-exact orthogonality and determinism test suites confirm
thetaandvcovare invariant across Stage-2 choices on the sameseedand identical across sequential vs parallel × cores.
New dependencies
lme4added asSuggests(required only forstage2 = "mixed_logit").
v0.1.0
(2026-04-12) Initial release.
Estimator
scfit(): structural deep-learning estimator with DML inference, respondent-clustered cross-fitting, and bit-exact determinism across core counts.predict.sc_fit(): forward-pass on new moderator data vianewdataandtypearguments.keep_modulesargument to persist per-fold torch modules for forward-pass prediction.
Structural quantities (21 functions)
- Tier A (9):
sc_mrs,sc_counterfactual,sc_wtp,sc_importance,sc_polarization,sc_fraction_preferring,sc_optimal_profile,sc_direction_intensity,sc_heterogeneity_test. - Tier B (3):
sc_subgroup,sc_compensating,sc_clusters. - Tier C (7):
sc_surplus,sc_welfare_change,sc_average,sc_indifference,sc_demand_curve,sc_decisiveness,sc_inequality.
Baselines
sc_baseline_logit,sc_baseline_lpmfor side-by-side comparison with the structural model.
Plots (7 functions)
plot_amce,plot_fraction,plot_hetero,plot_subgroup,plot_importance: publication-quality diagnostic plots.- All accept
dummies,labels,groupsfor customization (variable selection, display names, attribute-group faceting). plot.sc_fit: beta ridgelines ("beta_ridgelines") and training loss trace ("loss_trace").
Bundled datasets
sw2022(Saha & Weeks 2022): 1,191 respondents, candidate choice, 5 factor attributes, 3 moderators.gs2020(Graham & Svolik 2020): 1,605 respondents, democratic norms, 30 attribute levels (7 groups), 12 moderators.br2017(Ballard-Rosa, Martin & Scheve 2017): 2,000 respondents, tax preferences, 7 numeric attributes, 12 moderators.bs2013(Bechtel & Scheve 2013): 2,500 respondents, climate treaties, 6 attributes (including numeric cost), 3 moderators.simdata: 1,000 synthetic respondents with known ground truth for validation.
Tutorial
- 9-chapter Quarto book: installation, simulated example, four real-data worked examples (SW, GS, BR, BS), plot options reference, references, changelog.