Standard machine-learning workflows assume independent, identically distributed observations, leading to optimistic risk estimates, miscalibrated probabilities, and invalid uncertainty quantification when applied to complex probability samples. We introduce svylearn, an R package for design-consistent statistical learning, recalibration, and inference across cross-sectional and longitudinal surveys. Built on a strict separation between model development and evaluation, svylearn partitions data by whole primary sampling units (preserving all waves of longitudinal subjects), learns weighted preprocessing and hyperparameter tuning strictly inside training folds, and applies nested out-of-fold recalibration with auditable stabilization rules for rare outcomes. A unified evaluation interface (svy_eval()) reports design-based proper scores, rank metrics, calibration diagnostics, clinical utility, covariate-shift transport checks, weighted split-conformal intervals, and bounded-weight sensitivity analyses, explicitly distinguishing conditional fixed-score inference from complete-workflow replication. The package uses a lightweight S3 architecture with zero required third-party modeling dependencies at attachment, delegating estimation to optional learners (glmnet, ranger, xgboost, nnet) and survey variance calculations to survey. We verify numerical parity against survey and independent Python reference kernels, evaluate finite-sample behavior across extensive Monte Carlo simulations and stress tests, and demonstrate applied workflows using NHANES and longitudinal ECLS-K:2011 data. The baseline binary evaluation kernel processes one million records in 0.39 seconds, providing survey analysts with an auditable, reproducible end-to-end prediction pipeline.
翻译:暂无翻译