evans_king: Evans-King Tests for Heteroskedasticity in a Linear...

View source: R/evans_king.R

evans_kingR Documentation

Evans-King Tests for Heteroskedasticity in a Linear Regression Model

Description

This function implements the two methods of \insertCiteEvans88;textualskedastic for testing for heteroskedasticity in a linear regression model.

Usage

evans_king(
  mainlm,
  method = c("GLS", "LM"),
  deflator = NA,
  lambda_star = 5,
  qfmethod = "imhof",
  statonly = FALSE
)

Arguments

mainlm

Either an object of class "lm" (e.g., generated by lm), or a list of two objects: a response vector and a design matrix. The objects are assumed to be in that order, unless they are given the names "X" and "y" to distinguish them. The design matrix passed in a list must begin with a column of ones if an intercept is to be included in the linear model. The design matrix passed in a list should not contain factors, as all columns are treated 'as is'. For tests that use ordinary least squares residuals, one can also pass a vector of residuals in the list, which should either be the third object or be named "e".

method

A character indicating which of the two tests derived in \insertCiteEvans88;textualskedastic should be implemented. Possible values are "GLS" and "LM"; partial matching is used (which is not case-sensitive).

deflator

Either a character specifying a column name from the design matrix of mainlm or an integer giving the index of a column of the design matrix. This variable is suspected to be related to the error variance under the alternative hypothesis. deflator may not correspond to a column of 1's (intercept). Default NA means the data will be left in its current order (e.g. in case the existing index is believed to be associated with error variance).

lambda_star

A double; coefficient representing the degree of heteroskedasticity under the alternative hypothesis. \insertCiteEvans85;textualskedastic suggests 2.5, 5, 7.5, and 10 as values to consider, and \insertCiteEvans88;textualskedastic finds that 2.5 and 5 perform best empirically. This parameter is used only for the "GLS" method; the "LM" method represents the limiting case as λ^\star \to 0. Defaults to 5.

qfmethod

A character, either "imhof", "davies", or "integrate", corresponding to the algorithm argument of pRQF. The default is "imhof".

statonly

A logical. If TRUE, only the test statistic value is returned, instead of an object of class "htest". Defaults to FALSE.

Details

The test entails putting the data rows in increasing order of some specified deflator (e.g., one of the explanatory variables) that is believed to be related to the error variance by some non-decreasing function. There are two statistics that can be used, corresponding to the two values of the method argument. In both cases the test statistic can be expressed as a ratio of quadratic forms in the errors, and thus the Imhof algorithm is used to compute p-values. Both methods involve a left-tailed test.

Value

An object of class "htest". If object is not assigned, its attributes are displayed in the console as a tibble using tidy.

References

\insertAllCited

See Also

\insertCite

Evans85;textualskedastic, which already anticipates one of the tests.

Examples

mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
evans_king(mtcars_lm, deflator = "qsec", method = "GLS")
evans_king(mtcars_lm, deflator = "qsec", method = "LM")


skedastic documentation built on Nov. 10, 2022, 5:43 p.m.