svyder 0.2.0
svyder 0.2.0 makes the declared variance target explicit, corrects the sandwich engine, and ships a full documentation website. The diagnostic you get now depends on choices you state — the aggregation unit, the weight convention, the strata — rather than on silent defaults.
Breaking changes
-
der_compute()now requires the sandwich aggregation unit explicitly via theclusterargument (design PSU ids for a design-based target, orgroupfor a model-aligned target). There is no default: the aggregation unit is part of the variance-target definition, and DER values can change materially between targets.psuis retained as a deprecated alias and emits a warning. - Gaussian score fix: the weighted score residual for the gaussian family is now
w * (y - mu) / sigma_e^2, matching the bread’s working weightsw / sigma_e^2. The previous residualw * (y - mu)made the sandwich — and hence the DER — scale likesigma_e^4under a change of response units, so gaussian DERs were wrong by a factor ofsigma_e^4wheneversigma_e != 1. Binomial results are unaffected. - The meat is now stratified, centered within strata, and DF-corrected by default (
strata,center_meat = TRUE,df_correct = TRUE). Setcenter_meat = FALSE, df_correct = FALSE(andstrata = NULL) to reproduce v0.1.0 results exactly. -
der_correct()methods renamed: the previous per-parameter sqrt(DER) rescaling is nowmethod = "marginal"; the new defaultmethod = "block_cholesky"transforms the flagged block jointly so its covariance matches the sandwich target (the two coincide when exactly one parameter is flagged).method = "cholesky"was ambiguous and now errors with guidance. -
der_decompose()computes the protection factorR_kstructurally from the working-weighted within/between split of each covariate; it is no longer back-solved from the observed DER, which made the predicted-vs-observed comparison circular. Output columns renamed:deff_mean->deff_used,B_mean->B_used(now row-specific). Requires objects created by svyder >= 0.2.0 (which store the$dataslots).
New features
-
der_compute()gains acluster_strataargument declaring the full cluster universe of the design (the stratum of every cluster, indexed by cluster id). Clusters with zero sampled observations — e.g., selected PSUs whose second-stage sample is empty — then enter the meat as zero score-total clusters, contributing to the stratum centering and theC_h/(C_h-1)correction instead of silently vanishing from the declared target. LeaveNULLwhen every realized cluster has at least one observation. - Weight-normalization conventions:
normalize = c("unit_mean", "group_size", "none"). Random-effect DERs are not invariant to weight rescaling, so the convention is part of the declared target and is recorded in the result. - Declared-target metadata: results carry
$target(aggregation unit, strata, meat options, weight convention, bread convention), displayed byprint(). - Tier III exclusion table: results carry
$excluded, listing hyperparameters (sigma_theta, andsigma_efor gaussian) whose DER is undefined, with reasons. -
der_compare()fast path: given a svyder object (>= 0.2.0), only the meat is rebuilt per target;y/X/weightsneed not be re-supplied. -
param_types = NULLnow infers types from the design matrix (columns constant within every group arefe_between) and reports the inference via a message instead of silently defaulting. - Optional
stratathroughout; singleton strata contribute uncentered with a warning. - Fit-object methods (
brmsfit,CmdStanMCMC,stanreg) pass throughcluster,strata,normalize,center_meat,df_correct, andbeta_prior_sd; survey designs supply first-stage clusters and strata.
Documentation and website
- New pkgdown website: https://joonho112.github.io/svyder/.
- A two-track vignette set — five applied guides (getting started, choosing the variance target, the compute–classify–correct pipeline, an NSECE-style case study, and backends) and four method articles (the DER definition and regimes, the sandwich target, the decomposition theorems and conservation law, and classification & selective correction).
- roxygen help pages rewritten and expanded: worked, runnable examples on the bundled data; the mathematics of the target and the correction in
@details; literature references throughout; and a reference index grouped by topic. -
tidy()andglance()generics are re-exported, solibrary(svyder); tidy(result)works without also attaching generics (which moves from Suggests to Imports). - New hex logo.
svyder 0.1.0
- Initial release of the svyder package.
- Core pipeline:
der_compute(),der_classify(),der_correct(),der_diagnose(). - Analysis functions:
der_decompose(),der_sensitivity(),der_theorem_check(),der_compare(). - Backend support: brms, cmdstanr, rstanarm, survey package.
- Visualization: profile, decomposition, and CI comparison plots.
- Tidy methods:
tidy.svyder(),glance.svyder(). - Two bundled datasets:
nsece_demoandsim_hlr.