ts_adf_test: Augmented Dickey-Fuller Test for Time Series Stationarity

View source: R/stat-adf-test.R

ts_adf_testR Documentation

Augmented Dickey-Fuller Test for Time Series Stationarity

Description

This function performs the Augmented Dickey-Fuller test to assess the stationarity of a time series. The Augmented Dickey-Fuller (ADF) test is used to determine if a given time series is stationary. This function takes a numeric vector as input, and you can optionally specify the lag order with the .k parameter. If .k is not provided, it is calculated based on the number of observations using a formula. The test statistic and p-value are returned.

Usage

ts_adf_test(.x, .k = NULL)

Arguments

.x

A numeric vector representing the time series to be tested for stationarity.

.k

An optional parameter specifying the number of lags to use in the ADF test (default is calculated).

Value

A list containing the results of the Augmented Dickey-Fuller test:

  • test_stat: The test statistic from the ADF test.

  • p_value: The p-value of the test.

Author(s)

Steven P. Sanderson II, MPH

See Also

Other Statistic: ci_hi(), ci_lo()

Examples

# Example 1: Using the AirPassengers dataset
ts_adf_test(AirPassengers)

# Example 2: Using a custom time series vector
custom_ts <- rnorm(100, 0, 1)
ts_adf_test(custom_ts)


healthyR.ts documentation built on Nov. 15, 2023, 9:07 a.m.