harvey_collier_test: Run a Harvey-Collier Test

View source: R/linreg-linearity.R

harvey_collier_testR Documentation

Run a Harvey-Collier Test

Description

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

Usage

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

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

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

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

Arguments

object

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

...

Further arguments passed to lmtest::harvtest().

.alpha

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

Details

The hypotheses for this test are:

  • Null: True Relationship is Linear

  • Alternative: True Relationship is Not Linear (Convex or Concave)

Value

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

See Also

Other linearity tests: ramsey_reset_test()

Examples

library(tidytest)

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

harvey_collier_test(mod_lm_fit)

#> `linear_reg` Method
library(parsnip)

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

harvey_collier_test(mod_linreg_fit)

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