bruesch_pagan_test: Run a Bruesch-Pagan Test

View source: R/linreg-homoscedasticity.R

bruesch_pagan_testR Documentation

Run a Bruesch-Pagan Test

Description

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

Usage

bruesch_pagan_test(object, ..., .alpha = 0.05)

## S3 method for class 'lm'
bruesch_pagan_test(object, ..., .alpha = 0.05)

## S3 method for class ''_lm''
bruesch_pagan_test(object, ..., .alpha = 0.05)

## S3 method for class ''_glm''
bruesch_pagan_test(object, ..., .alpha = 0.05)

Arguments

object

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

...

Further arguments passed to lmtest::bptest().

.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: goldfeld_quandt_test()

Examples

library(tidytest)

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

bruesch_pagan_test(mod_lm_fit)

#> `linear_reg` Method
library(parsnip)

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

bruesch_pagan_test(mod_linreg_fit)

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