szroeter {skedastic}R Documentation

Szroeter's Test for Heteroskedasticity in a Linear Regression Model

Description

This function implements the method of Szroeter (1978) for testing for heteroskedasticity in a linear regression model.

Usage

szroeter(mainlm, deflator = NA, h = SKH, 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".

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).

h

A non-decreasing function taking as its argument the index i of observations from 1 to n. Defaults to SKH, which is equivalent to h(i)=2(1-\cos \frac{\pi i}{n+1}). The function must be able to take a vector argument of length n.

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. The test statistic is a ratio of quadratic forms in the OLS residuals. It is a right-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

Szroeter J (1978). “A Class of Parametric Tests for Heteroscedasticity in Linear Econometric Models.” Econometrica, 46(6), 1311–1327.

Examples

mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
szroeter(mtcars_lm, deflator = "qsec")


[Package skedastic version 2.0.2 Index]