bickel: Bickel's Test for Heteroskedasticity in a Linear Regression...

View source: R/bickel.R

bickelR Documentation

Bickel's Test for Heteroskedasticity in a Linear Regression Model

Description

This function implements the method of \insertCiteBickel78;textualskedastic for testing for heteroskedasticity in a linear regression model, with or without the scale-invariance modification of \insertCiteCarroll81;textualskedastic.

Usage

bickel(
  mainlm,
  fitmethod = c("lm", "rlm"),
  a = "identity",
  b = c("hubersq", "tanhsq"),
  scale_invariant = TRUE,
  k = 1.345,
  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".

fitmethod

A character indicating the method to be used to fit the regression model. This can be "OLS" for ordinary least squares (the default) or "robust" in which case a robust fitting method is called from rlm.

a

A character argument specifying the name of a function to be applied to the fitted values, or an integer m in which case the function applied is f(x) = x^m. Defaults to "identity" for identity.

b

A character argument specifying a function to be applied to the residuals. Defaults to Huber's function squared, as recommended by \insertCiteCarroll81;textualskedastic. Currently the only supported functions are "hubersq" (for Huber's function squared) and "tanhsq" (for b(x)=\mathrm{tanh}(x)^2.)

scale_invariant

A logical indicating whether the scale-invariance modification proposed by \insertCiteCarroll81;textualskedastic should be implemented. Defaults to TRUE.

k

A double argument specifying a parameter for Huber's function squared; used only if b == "hubersq". This is not to be confused with the argument k2 that could be passed to rlm if the regression is fitted using robust methods. k defaults to 1.345.

statonly

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

...

Optional arguments to be passed to rlm

Details

Bickel's Test is a robust extension of Anscombe's Test \insertCiteAnscombe61skedastic in which the OLS residuals and estimated standard error are replaced with an M estimator. Under the null hypothesis of homoskedasticity, the distribution of the test statistic is asymptotically standard normally distributed. The test is two-tailed.

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

discussions of this test in \insertCiteCarroll81;textualskedastic and \insertCiteAli84;textualskedastic.

Examples

mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
bickel(mtcars_lm)
bickel(mtcars_lm, fitmethod = "rlm")
bickel(mtcars_lm, scale_invariant = FALSE)


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