Skip to content

Scatter-plot diagnostics for heteroscedasticity

Source: man/performScatterDiagnostic.Rd · Help: ?performScatterDiagnostic

Computes correlations between absolute residuals and selected variables.

Usage

performScatterDiagnostic(model, data, vars)

Arguments

model
an object of class lm.
data
The data frame model was fitted to, holding the variables named in vars. The residuals and weights are read from the fit itself, and vars from the rows of data that hold the observations of the fit. Since 0.16.0 they are matched to the observations of the fit: rows with row names of their own by name, in any order; rows that only number themselves (a tibble, a data.table, a data frame whose row names were reset) by the row numbers of the fit, or in the order of the fit when they hold one row per observation. The rows the fit dropped may be there or not. Data whose rows cannot be shown to hold the observations of the fit are refused; see test_results.
vars
character vector of variable names.

Value

A named numeric vector of correlations.

Details

High correlations suggest increasing spread with the explanatory variables and motivate variance-stabilizing transformations.

Supported models

It accepts the models the tests accept: an lm and a glm with the Gaussian family and the identity link, unweighted or with positive weights, a fitWLS() fit and a rank-deficient fit. It refuses a glm of another family or link (since 0.16.0), a survey::svyglm() fit, a fit with a zero weight, and data that lack rows or (since 0.16.0) variables of the fit. Which model each test accepts, and why, is set out in test_results, under Supported models.

References

Cleveland, W. S. (1979). Robust locally weighted regression and smoothing scatterplots. Journal of the American Statistical Association, 74(368), 829–836.

Examples

 data(mtcars)
 m <- lm(mpg ~ wt + qsec, data = mtcars)
 performScatterDiagnostic(m, mtcars, c("wt", "qsec"))