Skip to content

Perform Goldfeld-Quandt test for heteroscedasticity

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

Implements the Goldfeld-Quandt test on a fitted linear model with directional or two-sided alternatives.

Usage

performGQTest(model, data = NULL, order_by, fraction = 0.2,
  alternative = c("greater", "two.sided", "less"))

Arguments

model
an object of class lm.
data
data frame used to fit model. When NULL, the default, the model frame of model is used, so order_by must then be a variable of the model. The model frame holds the terms of the model rather than its variables (log(x) rather than x), so a model that transforms a variable needs data, as does a model with an offset() term.
order_by
single column name used to order observations.
fraction
fraction of observations omitted from the middle; must lie strictly between zero and one.
alternative
alternative hypothesis: "greater" for increasing variance from segment 1 to segment 2, "less" for decreasing variance, or "two.sided" for either direction.

Value

An object of class htest containing the directional GQ statistic, p-value, degrees of freedom and alternative hypothesis.

Details

Observations are ordered by a suspected variance-driving variable. With the split point fixed at the sample midpoint, a central fraction is omitted and the original model is re-estimated on the lower and upper segments. The statistic is the residual mean square of segment 2 divided by the residual mean square of segment 1 and is therefore directional rather than being forced above one. Split arithmetic and p-value conventions match lmtest::gqtest(..., point = 0.5).

Weighted fits

On a fit with weights each segment is refitted with its own weights and the segments are compared on the weighted residual sum of squares, \(\sum w_i e_i^2\). That is the Goldfeld-Quandt statistic of the equivalent unweighted regression, so the test asks whether the weights are adequate. Releases before 0.12.0 refitted the segments without the weights.

References

Goldfeld, S. M., & Quandt, R. E. (1965). Some tests for homoscedasticity. Journal of the American Statistical Association, 60(310), 539–547. doi:10.1080/01621459.1965.10480811

Greene, W. H. (2018). Econometric Analysis (8th ed.). Pearson.

Examples

 data(mtcars)
 m <- lm(mpg ~ wt + qsec, data = mtcars)
 performGQTest(m, mtcars, order_by = "wt")
 performGQTest(m, mtcars, order_by = "wt", alternative = "two.sided")