aug_dickey_fuller_test: Run an Augmented Dickey-Fuller (ADF) Test

View source: R/tseries-stationarity.R

aug_dickey_fuller_testR Documentation

Run an Augmented Dickey-Fuller (ADF) Test

Description

The hypotheses for this test are:

A wrapper around tseries::adf.test() that standardizes the inputs and outputs.

Usage

aug_dickey_fuller_test(object, alternative = "stationary", ..., .alpha = 0.05)

## S3 method for class 'lm'
aug_dickey_fuller_test(object, alternative = "stationary", ..., .alpha = 0.05)

## S3 method for class ''_lm''
aug_dickey_fuller_test(object, alternative = "stationary", ..., .alpha = 0.05)

aug_dickey_fuller_test_vec(x, alternative = "stationary", ..., .alpha = 0.05)

Arguments

object

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

alternative

(Optional) The alternative hypothesis, either "stationary" (default) or "explosive".

...

Further arguments passed to tseries::adf.test().

.alpha

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

x

For ⁠_vec()⁠ functions, a numeric vector.

Details

  • Null: Series has a unit root

  • Alternative: Series is either stationary or has explosive root (user defined)

Value

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

See Also

Other stationarity tests: kpss_test(), phillips_perron_test()

Examples

library(tidytest)

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

aug_dickey_fuller_test(mod_lm_fit)
aug_dickey_fuller_test(mod_lm_fit, alternative = "explosive")


#> `linear_reg` Method
library(parsnip)

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

aug_dickey_fuller_test(mod_linreg_fit)
aug_dickey_fuller_test(mod_linreg_fit, alternative = "explosive")


#> Numeric Method
set.seed(1914)
resids <- rnorm(100)

aug_dickey_fuller_test_vec(resids)
aug_dickey_fuller_test_vec(resids, alternative = "explosive")


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