Robust Three-Group Tests for Heteroscedasticity in Linear Regression

Tests for heteroscedasticity in the linear regression model that sort the data by a regressor, split them into three equal parts and compare the error scale of the parts. The ordinary least squares version 'kah3.test()' refers the ratio of the largest to the smallest residual mean square to its exact null distribution, Hartley's maximum F-ratio with three groups; the robust version 'kah.robust.test()' replaces the mean squares by least trimmed squares scales, so that outliers neither create nor hide heteroscedasticity, and refers the ratio to a maximum F-ratio with simulated effective degrees of freedom, to a Monte Carlo reference or to a residual bootstrap. The distribution, density, quantile and random generation functions of the maximum F-ratio are provided, together with 'run.all.het()', which runs the proposed tests next to the Goldfeld-Quandt, Breusch-Pagan, White and robust modified Goldfeld-Quandt tests in one call. For more details see Hartley (1950) , Goldfeld and Quandt (1965) and Rousseeuw (1984) .


KOTORY

R-CMD-check

Robust three-group tests for heteroscedasticity in linear regression.

The tests sort the data by a regressor, split them into three equal parts, fit the regression in each part and compare the error scale of the parts.

Function What it does
kah3.test() Least squares in each part. The ratio of the largest to the smallest residual mean square follows Hartley's maximum F-ratio with three groups exactly, so the p-value is exact at every sample size.
kah.robust.test() Least trimmed squares (LTS) in each part, so outliers neither create nor hide heteroscedasticity as easily. Three references: an effective-degrees-of-freedom F-max approximation (default), a Monte Carlo reference, or a residual bootstrap for non-normal errors.
run.all.het() Runs the KaH tests next to Goldfeld-Quandt, Breusch-Pagan (Koenker), White and the robust modified Goldfeld-Quandt test of Rana, Midi and Imon (2008) and, when skedastic is installed, three more recent tests.
pfmax(), dfmax(), qfmax(), rfmax() Hartley's maximum F-ratio distribution for any number of groups and any positive degrees of freedom.

Installation

# development version
# install.packages("remotes")
remotes::install_github("ebrahimkhaled/KOTORY")

Example

library(KOTORY)

# stopping distance of cars: the spread grows with speed
kah3.test(dist ~ speed, data = cars)
kah.robust.test(dist ~ speed, data = cars)

# all tests side by side
run.all.het(dist ~ speed, data = cars)

# an outlier fools least squares but not the robust test
set.seed(2)
x  <- runif(60)
y0 <- 1 + x + rnorm(60)
y  <- y0; y[which.min(x)] <- 12
c(clean = kah3.test(y0 ~ x)$p.value,       outlier = kah3.test(y ~ x)$p.value)
c(clean = kah.robust.test(y0 ~ x)$p.value, outlier = kah.robust.test(y ~ x)$p.value)

Origin

The three-group tests were proposed in the doctoral thesis of Ahmed El-Kotory (Alexandria University), where their critical values were tabulated by simulation. This package replaces those tables: the least squares version follows Hartley's (1950) maximum F-ratio exactly, and the robust version is referred to an effective-degrees-of-freedom approximation, a Monte Carlo reference or a bootstrap.

References

Authors

Ahmed El-Kotory and Ebrahim Khaled Ebrahim (maintainer), Department of Statistics, Faculty of Business, Alexandria University.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("KOTORY")

0.1.0 by Ebrahim Khaled Ebrahim, 9 hours ago


https://github.com/ebrahimkhaled/KOTORY


Report a bug at https://github.com/ebrahimkhaled/KOTORY/issues


Browse source code at https://github.com/cran/KOTORY


Authors: Ahmed El-Kotory [aut] , Ebrahim Khaled Ebrahim [aut, cre] (ORCID:


Documentation:   PDF Manual  


GPL-3 license


Imports robustbase, stats

Suggests lmtest, skedastic, testthat


See at CRAN