li_yao: Li-Yao ALRT and CVT Tests for Heteroskedasticity in a Linear...

View source: R/li_yao.R

li_yaoR Documentation

Li-Yao ALRT and CVT Tests for Heteroskedasticity in a Linear Regression Model

Description

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

Usage

li_yao(mainlm, method = c("cvt", "alrt"), baipanyin = TRUE, 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 \insertCiteLi19;textualskedastic should be implemented. Possible values are "alrt" (approximate likelihood-ratio test) and "cvt" (coefficient-of-variation test). Default is "cvt". Partial matching is used.

baipanyin

A logical. Should the central limit theorem of \insertCiteBai16;textualskedastic be used to determine the p-value for the coefficient-of-variation test (assuming normally distributed errors)? If FALSE, the asymptotic null distribution in \insertCiteLi19;textualskedastic is used, which requires the assumption that the design variables are random and normally distributed. This argument is ignored if method is "alrt".

statonly

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

Details

These two tests are straightforward to implement; in both cases the test statistic is a function only of the residuals of the linear regression model. Furthermore, in both cases the test statistic is asymptotically normally distributed under the null hypothesis of homoskedasticity. Both tests are right-tailed. These tests are designed to be especially powerful in high-dimensional regressions, i.e. when the number of explanatory variables is large.

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

Examples

mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
li_yao(mtcars_lm, method = "alrt")
li_yao(mtcars_lm, method = "cvt")
li_yao(mtcars_lm, method = "cvt", baipanyin = FALSE)
# Same as first example
li_yao(list("e" = mtcars_lm$residuals), method = "alrt")


skedastic documentation built on May 29, 2024, 12:20 p.m.