weights_tests | R Documentation |
Use the tests proposed in Pfeffermann and Sverchkov (1999) and DuMouchel and Duncan (1983) to check whether a regression model is specified correctly without weights.
weights_tests(
model,
weights,
data,
model_output = TRUE,
test = NULL,
sims = 1000,
digits = getOption("jtools-digits", default = 2)
)
model |
The fitted model, without weights |
weights |
The name of the weights column in |
data |
The data frame with the data fed to the fitted model and the weights |
model_output |
Should a summary of the model with weights as predictor be printed? Default is TRUE, but you may not want it if you are trying to declutter a document. |
test |
Which type of test should be used in the ANOVA? The default,
|
sims |
The number of bootstrap simulations to use in estimating the variance of the residual correlation. Default is 1000, but for publications or when computing power/time is sufficient, a higher number is better. |
digits |
An integer specifying the number of digits past the decimal to
report in the output. Default is 3. You can change the default number of
digits for all jtools functions with
|
This function is a wrapper for the two tests implemented in this package that
test whether your regression model is correctly specified. The first is
wgttest
, an R adaptation of the Stata macro of the same name.
This test can otherwise be referred to as the DuMouchel-Duncan test. The
other test is the Pfeffermann-Sverchkov test, which can be accessed directly
with pf_sv_test
.
For more details on each, visit the documentation on the respective functions. This function just runs each of them for you.
DuMouchel, W. H. & Duncan, D.J. (1983). Using sample survey weights in multiple regression analyses of stratified samples. Journal of the American Statistical Association, 78. 535-543.
Nordberg, L. (1989). Generalized linear modeling of sample survey data. Journal of Official Statistics; Stockholm, 5, 223-239.
Pfeffermann, D., & Sverchkov, M. (1999). Parametric and semi-parametric estimation of regression models fitted to survey data. Sankhya: The Indian Journal of Statistics, 61. 166-186.
Other survey tools:
pf_sv_test()
,
svycor()
,
svysd()
,
wgttest()
# Note: This is a contrived example to show how the function works,
# not a case with actual sammpling weights from a survey vendor
if (requireNamespace("boot")) {
states <- as.data.frame(state.x77)
set.seed(100)
states$wts <- runif(50, 0, 3)
fit <- lm(Murder ~ Illiteracy + Frost, data = states)
weights_tests(model = fit, data = states, weights = wts, sims = 100)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.