Skip to content

Run heteroscedasticity diagnostics on the data of a survey design

Source: man/runSurveyHeteroTests.Rd ยท Help: ?runSurveyHeteroTests

A convenience wrapper that takes the data out of a survey::svydesign() object, fits the model by ordinary least squares and runs runHeteroTests. It does not use the sampling weights, strata or clusters of the design, and warns when the design has unequal weights or clusters.

Usage

runSurveyHeteroTests(formula, design, tests = c("white", "koenker"), ...)

Arguments

formula
Model formula specifying the mean structure.
design
A survey::svydesign() object. Only its data are used.
tests
Diagnostic names passed on to runHeteroTests. Defaults to the White and Koenker tests, the default of runHeteroTests; it was the White and the classical Breusch-Pagan tests up to 0.14.0.
...
Additional arguments forwarded to runHeteroTests.

Value

An object of class hetero_test_suite.

Details

The tests are the ones runHeteroTests runs on any lm: they treat the observations as an independent sample with equal weights. They hold their level on survey data when the design can be ignored given the regressors, that is when the chance of being sampled depends only on variables in the model, and the sample has no clusters. When selection depends on the response, or observations are clustered, they reject a model with constant error variance far more often than their nominal level.

The package has no design-based test of constant variance. Sampling weights are not precision weights: they say how many population units an observation stands for and nothing about its error variance. Passing them to lm(weights = ), or testing a survey::svyglm() fit, makes the tests examine residuals multiplied by the square roots of the weights, and a homoscedastic model is then rejected whenever the weights vary with the regressors. svyglm fits are refused for that reason.

inst/validation/survey-designs-size.R measures all of this, together with two design-based tests that were tried and not adopted because they reject too often at the sample sizes examined.

Earlier versions

Up to 0.12.0 this page described a survey-weighted fit. The weights did not reach the fit, which was by ordinary least squares, as it is now, so the reported values are unchanged.

See also

runHeteroTests

Examples

if (requireNamespace("survey", quietly = TRUE)) {
  data(api, package = "survey")
  design <- survey::svydesign(id = ~1, strata = ~stype, weights = ~pw, data = apistrat)
  # Warns: the weights of this design are unequal and are not used.
  res <- runSurveyHeteroTests(api00 ~ api99 + ell, design)
  generics::tidy(res)
}