
Pseudo-weights for a non-probability sample against a reference
Source:R/adjust-pseudoweight.R
step_pseudoweight.RdFor a non-probability sample (opt-in panel, volunteer or river sample) with no
design weights, step_pseudoweight() estimates each unit's participation
propensity \(\hat p\) against a probability reference_sample() and assigns
the pseudo-weight \((1 - \hat{p})/\hat{p}\) (the participation odds;
Elliott and Valliant 2017), which inflates each unit to the population so the
weights sum to the reference's estimated population size. It stacks the non-probability sample and the
reference internally (the participation indicator and the two samples' weights
are built for you), fits the propensity, and returns the pseudo-weight on the
non-probability units only; the reference is used to train the model and then
dropped.
Usage
step_pseudoweight(
spec,
reference,
formula,
engine = c("logit", "tree", "forest", "boost"),
num_classes = NULL,
crossfit = NULL,
crossfit_seed = NULL,
id = NULL
)Arguments
- spec
a non-probability
weighting_spec.- reference
a
reference_sample()(the probability reference with its design weights). Pass the reference's replicate weights throughreference_sample(replicates = )to propagate its sampling variance through the recipe-aware bootstrap: each replicate refits the propensity from the paired reference replicate. Without them the reference is treated as fixed, so the bootstrap reflects only the variability of the non-probability sample (which it resamples as a with-replacement sample of units, a slightly conservative approximation when that sample is a large fraction of the population).- formula
one-sided formula of the covariates shared by both samples, e.g.
~ sex + age + region.- engine
propensity learner:
"logit"(default),"tree","forest"or"boost".- num_classes
NULL (default, direct
1/pi) or an integer: group the fitted propensities into that many quantile classes and use the class-average pseudo-weight, which is more robust to a misspecified model.- crossfit, crossfit_seed
optional K-fold cross-fitting of the propensity (recommended for the flexible learners), and its seed.
- id
optional stable step id.
Details
The recipe must be a non-probability spec: weighting_spec(..., nonprob = TRUE). This step is the inverse-propensity (IPW) route; you can instead, or
additionally, calibrate to a reference_sample() with step_calibrate() /
step_model_calibration() (mass imputation / model-based), and combining both
gives the doubly robust estimator.
References
Elliott, M. R. and Valliant, R. (2017). Inference for non-probability samples. Statistical Science 32(2), 249-264.
See also
reference_sample(), step_calibrate(), step_model_calibration()
Other weighting steps:
step_assert(),
step_calibrate(),
step_cre(),
step_drop_ineligible(),
step_model_calibration(),
step_nonresponse(),
step_nr_sensitivity(),
step_rescale(),
step_round(),
step_select_within(),
step_subsample(),
step_trim(),
step_trim_calibrated(),
step_trim_weights(),
step_unknown_eligibility()
Examples
set.seed(1)
N <- nrow(population)
# a biased volunteer sample (men over-participate) and a probability reference
vol <- population[rbinom(N, 1, plogis(-2 + 0.9 * (population$sex == "M"))) == 1,
c("region", "sex", "income")]
ref <- population[sample(N, 600), c("region", "sex")]
ref$d <- N / 600 # its design weights
fit <- weighting_spec(vol, base_weights = NULL, nonprob = TRUE) |>
step_pseudoweight(reference = reference_sample(ref, "d"),
formula = ~ region + sex, engine = "logit") |>
prep()
# the pseudo-weighted mean corrects the volunteer bias
c(naive = mean(vol$income),
pseudo = weighted.mean(vol$income, fit$final_weight),
truth = mean(population$income))
#> naive pseudo truth
#> 19353.58 18936.79 19298.11