Learn R Programming

skedastic (version 1.0.0)

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

Description

This function implements the method of Bickel78;textualskedastic for testing for heteroskedasticity in a linear regression model, with or without the scale-invariance modification of Carroll81;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 Carroll81;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 Carroll81;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

Value

An object of class "htest". If object is not assigned, its attributes are displayed in the console as a tibble using tidy.

Details

Bickel's Test is a robust extension of Anscombe's Test Anscombe61skedastic 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.

References

See Also

discussions of this test in Carroll81;textualskedastic and Ali84;textualskedastic.

Examples

Run this code
# NOT RUN {
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
bickel(mtcars_lm)
bickel(mtcars_lm, fitmethod = "rlm")
bickel(mtcars_lm, scale_invariant = FALSE)

# }

Run the code above in your browser using DataLab