Opens a weighting recipe on a sample and its design base weights. The object
it returns is inert: it holds the data, the name of the base-weight column and
an empty list of steps, and computes nothing. Every step_*() function takes
such an object and returns it with one more step appended; prep() estimates
the result.
Arguments
- data
data.frame with the sample units (one row per case).
- base_weights
unquoted name of the design base-weight column. For a non-probability sample with no design weights, leave it
NULLand setnonprob = TRUE: every unit then starts with a base weight of 1.- nonprob
logical. Declare the sample as non-probability (an opt-in panel, a volunteer or river sample). Required when
base_weights = NULL. The flag is recorded so the report states the sample is non-probability and adds the methodological caveat; a non-probability sample is usually adjusted withstep_pseudoweight()(inverse participation propensity against a reference) and/orstep_calibrate()/step_model_calibration()to areference_sample(). A non-probability panel that already carries recruitment/base weights can pass them asbase_weightstogether withnonprob = TRUE.
Examples
rec <- weighting_spec(sample_survey, base_weights = pw)
rec
#>
#> == Weighting specification (weightflow) ==
#> Data : 467 cases
#> Base wts: pw
#> Steps : (none yet)
#> Status : not estimated
#>
# a non-probability sample: no design weights, base weight 1
np <- weighting_spec(sample_survey, base_weights = NULL, nonprob = TRUE)
