wilcox_keselman: Wilcox and Keselman's Test for Heteroskedasticity in a Linear...

View source: R/wilcox_keselman.R

wilcox_keselmanR Documentation

Wilcox and Keselman's Test for Heteroskedasticity in a Linear Regression Model

Description

This function implements the nonparametric test of \insertCiteWilcox06;textualskedastic for testing for heteroskedasticity in a simple linear regression model, and extends it to the multiple linear regression model.

Usage

wilcox_keselman(
  mainlm,
  gammapar = 0.2,
  B = 500L,
  p.adjust.method = "none",
  seed = NA,
  rqwarn = FALSE,
  matchWRS = FALSE,
  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".

gammapar

A double value between 0 and 0.5 exclusive specifying the quantile value gamma. Defaults to 0.2.

B

An integer specifying the number of nonparametric bootstrap samples to use to estimate standard error(s) of the quantile difference(s). Defaults to 500L.

p.adjust.method

A character specifying the family-wise error rate method to use in adjusting p-values (if it is a multiple linear regression model). The value is passed to p.adjust. By default no adjustment is made.

seed

An integer specifying a seed to pass to set.seed for random number generation. This allows reproducibility of bootstrap results. The value NA results in not setting a seed.

rqwarn

A logical specifying whether warnings generated by rq.fit (such as 'Solution may be nonunique') should be printed (TRUE) or suppressed (FALSE). Defaults to FALSE.

matchWRS

A logical specifying whether bootstrap samples should be generated in the exact same manner as in the qhomtv2 function in WRS package. If TRUE, and seed is set to 2 and B to 100 and p.adjust.method to "none", results will be identical to those of the default settings of qhomtv2.

statonly

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

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

Rand R. Wilcox's package WRS on Github; in particular the functions qhomt and qhomtv2, which implement this method for simple and multiple linear regression respectively.

Examples

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


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