goldfeld_quandt_test: Run a Goldfeld-Quandt Test

View source: R/linreg-homoscedasticity.R

goldfeld_quandt_testR Documentation

Run a Goldfeld-Quandt Test

Description

A wrapper around lmtest::gqtest() that standardizes the inputs and outputs.

Usage

goldfeld_quandt_test(object, alternative = "two.sided", ..., .alpha = 0.05)

## S3 method for class 'lm'
goldfeld_quandt_test(object, alternative = "two.sided", ..., .alpha = 0.05)

## S3 method for class ''_lm''
goldfeld_quandt_test(object, alternative = "two.sided", ..., .alpha = 0.05)

## S3 method for class ''_glm''
goldfeld_quandt_test(object, alternative = "two.sided", ..., .alpha = 0.05)

Arguments

object

A model object (such as a fitted lm object).

alternative

Passed to the alternative argument of lmtest::gqtest() (one of "two.sided", "greater", or "less". Default is "two.sided").

...

Further arguments passed to lmtest::gqtest().

.alpha

(Optional) Critical p-value used to determine test conclusion. The default is 0.05 (5%).

Details

The hypotheses for this test are:

  • Null: Variances are Equal (Homoscedastic)

  • Alternative: Variances are Not Equal (Heteroscedastic)

Value

A tibble with columns test, statistic, p_value, result, outcome, and .notes with extra information.

See Also

Other homoscedasticity tests: bruesch_pagan_test()

Examples

library(tidytest)

#> `lm` Method
mod_lm_fit <- lm(mpg ~ disp + wt + hp, data = mtcars)

goldfeld_quandt_test(mod_lm_fit)

#> `linear_reg` Method
library(parsnip)

mod_linreg_fit <- linear_reg() %>%
  set_engine("lm") %>%
  fit(mpg ~ disp + wt + hp, data = mtcars)

goldfeld_quandt_test(mod_linreg_fit)

RobbyLankford/tidytest documentation built on Jan. 27, 2024, 7:36 a.m.