svytest provides a unified suite of diagnostic tests for assessing the informativeness of survey weights in regression models. It implements both classical parametric tests (Hausman–Pfeffermann, DuMouchel–Duncan, Pfeffermann–Sverchkov, Wu–Fuller, Estimating Equations) and novel non‑parametric permutation tests.
svytest?Survey weights are essential for unbiased descriptive statistics, but their role in regression modeling is debated. Using weights unnecessarily can inflate variance, while ignoring informative weights can bias estimates.
svytest helps you decide whether weights matter in your regression by offering:
You can install the released version of svytest from CRAN with:
install.packages("svytest") or install the development version from
GitHub with: remotes::install_github("cnlubianski/svytest").
Load the package and your survey data.
library(svytest)
library(survey)
data("svytestCE", package = "svytest")
des <- svydesign(ids = ~1, weights = ~FINLWT21, data = svytestCE)
fit <- svyglm(TOTEXPCQ ~ ROOMSQ + BATHRMQ + BEDROOMQ + FAM_SIZE + AGE,
design = des)
res_dc <- diff_in_coef_test(fit, var_equal = TRUE)
summary(res_dc)
#>
#> Difference-in-Coefficients Test
#> Call:
#> diff_in_coef_test(model = fit, var_equal = TRUE)
#>
#> Method:
#> Hausman-Pfeffermann Difference-in-Coefficients Test
#>
#> Test Statistic:
#> Chi-sq = 15.3278 on 6 df , p-value = 0.0179
This compares weighted vs. unweighted regression coefficients. A small p‑value suggests weights are informative.
res_dd <- wa_test(fit, type = "DD")
summary(res_dd)
#>
#> Weight-Association Test
#> Call:
#> wa_test(model = fit, type = "DD")
#>
#> Method:
#> DuMouchel-Duncan Weight-Association Test
#>
#> Test Statistic:
#> F = 2.5557 on 6 and 21914 df , p-value = 0.0178
This regresses residuals on weights. A significant slope indicates informativeness.
res_perm <- perm_test(fit, stat = "pred_mean", B = 500, engine = "R")
summary(res_perm)
See the vignette for a comprehensive review of all tests, the
statistical underpinnings, and references: vignette("svytest").