Inference for Nonprobability Samples Using Multiple Reference Surveys
nonprobsampling implements pseudo-weighting methods for
finite population inference from nonprobability samples, such as
convenience samples, volunteer cohorts, and opt-in panels. Because the
participation mechanism in a nonprobability sample is unknown,
unweighted estimates of population means and prevalence may be biased.
The package addresses this issue by leveraging auxiliary information
from one or multiple probability reference surveys to estimate
participation probabilities and using their inverses as pseudo-weights
to obtain estimates of finite population means and prevalence adjusted
for participation bias.
The extent of bias reduction depends on the assumptions underlying the chosen method and the auxiliary information available.
The implemented methods are based on the generalized estimating equations framework of Landsman et al. (2026). This includes a multi-reference extension that enables the integration of auxiliary information across multiple reference surveys.
Install the released version from CRAN:
install.packages("nonprobsampling")Install the development version from GitHub:
# install.packages("remotes")
remotes::install_github("Jiakun0611/nonprobsampling")With one reference survey:
With multiple reference surveys:
Variance estimation is based on Taylor linearization, with complex
sampling designs in the reference surveys handled through integration
with the survey
package. When a reference survey is supplied as a replicate-weight
design, its contribution to the variance is estimated using the supplied
replicate weights.
Estimation proceeds in two steps: est_pw() estimates
pseudo-weights, then pwmean() estimates a pseudo-weighted
mean or prevalence for an outcome.
For user-supplied data, harmonize shared variables before creating survey design objects. Categorical variables must have identical factor levels in the same order and the same contrast coding across samples; treatment contrasts must use the same reference category. The package checks factor levels but does not check contrast coding. See the variable harmonization guidance for details.
library(nonprobsampling)
data(sc) # nonprobability sample (outcome: psa_level)
data(sp1) # probability reference survey
# Reference survey design
ref1_design <- survey::svydesign(
ids = ~psu_sp1,
strata = ~strata_sp1,
weights = ~wts_sp1,
data = sp1,
nest = TRUE
)
# Step 1: estimate pseudo-weights (one-reference calibration)
fit <- est_pw(
data = list(sc, ref1_design),
p_formula = ~ agecat + race + education + comorbidity + BMI + diabetes,
method = "calibration",
control = pw_solver_control(ftol = 1e-6)
)
print(fit)
summary(fit)
# Step 2: pseudo-weighted mean of the outcome, by BMI categories
out <- pwmean(fit, y = "psa_level", zcol = "BMI")
print(out)
summary(out)With multiple reference surveys, users provide one survey design object for each reference survey and a corresponding list of participation model formulas, with one formula specified for each survey.
data(sp2) # second probability reference survey
ref2_design <- survey::svydesign(
ids = ~psu_sp2,
strata = ~strata_sp2,
weights = ~wts_sp2,
data = sp2,
nest = TRUE
)
fit2 <- est_pw(
data = list(sc, ref1_design, ref2_design),
p_formula = list(
~ agecat + race + education + psa_level + pros_enlarged + comorbidity,
~ agecat + race + BMI + diabetes + comorbidity
),
sp_order = "size",
precali = TRUE,
control = pw_solver_control(ftol = 1e-6)
)
print(fit2)
summary(fit2)See vignette("nonprobsampling") for more details.
The package includes example datasets used throughout the documentation:
| Dataset | Description |
|---|---|
sc |
Nonprobability sample (synthetic, NHANES-based) |
sp1 |
First probability reference survey (NHANES 1999–2010) |
sp2 |
Second probability reference survey (NHIS 1997–2008) |
sp1_bootstrap |
sp1 with bootstrap replicate weights |
Run any of the following commands in R to open the corresponding help page (clickable links are available on the package website):
## Package overview
?nonprobsampling
## Main
functions
?est_pw
?pwmean
?pw_solver_control
## Datasets
?sc
?sp1
?sp2
?sp1_bootstrap
##
Vignette
vignette(“nonprobsampling”)
To cite the package in publications, run:
citation("nonprobsampling")GPL-3 © Jiakun Lin, Victoria Landsman, Aya A. Mitani