yuce: Yüce's Test for Heteroskedasticity in a Linear Regression...

View source: R/yuce.R

yuceR Documentation

Yüce's Test for Heteroskedasticity in a Linear Regression Model

Description

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

Usage

yuce(mainlm, method = c("A", "B"), 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 presented in \insertCiteYuce08;textualskedastic should be implemented. Possible values are "A" (the chi-squared test) and "B" (the t-test). Partial matching is used and the argument is not case-sensitive.

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. The first test statistic has an asymptotic chi-squared distribution and the second has an asymptotic t-distribution. In both cases the degrees of freedom are n-p. The chi-squared test is right-tailed whereas the t-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

Examples

mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
yuce(mtcars_lm, method = "A")
yuce(mtcars_lm, method = "B")


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