View source: R/utils-doublediff-stationary.R
util_doublediff_ts | R Documentation |
This function attempts to make a non-stationary time series stationary by applying double differencing. It iteratively increases the differencing order until stationarity is achieved.
util_doublediff_ts(.time_series)
.time_series |
A time series object to be made stationary. |
The function calculates the frequency of the input time series using the stats::frequency
function.
It then applies double differencing incrementally until the Augmented Dickey-Fuller test indicates
stationarity (p-value < 0.05) or until the differencing order reaches the frequency of the data.
If double differencing successfully makes the time series stationary, it returns the stationary time series and related information as a list with the following elements:
stationary_ts: The stationary time series after double differencing.
ndiffs: The order of differencing applied to make it stationary.
adf_stats: Augmented Dickey-Fuller test statistics on the stationary time series.
trans_type: Transformation type, which is "double_diff" in this case.
ret: TRUE to indicate a successful transformation.
If the data requires more double differencing than its frequency allows, it informs the user and suggests trying differencing with the natural logarithm instead.
If the time series is already stationary or the double differencing is successful, it returns a list as described in the details section. If additional differencing is required, it informs the user and returns a list with ret set to FALSE, suggesting trying differencing with the natural logarithm.
Steven P. Sanderson II, MPH
Other Utility:
auto_stationarize()
,
calibrate_and_plot()
,
internal_ts_backward_event_tbl()
,
internal_ts_both_event_tbl()
,
internal_ts_forward_event_tbl()
,
model_extraction_helper()
,
ts_get_date_columns()
,
ts_info_tbl()
,
ts_is_date_class()
,
ts_lag_correlation()
,
ts_model_auto_tune()
,
ts_model_compare()
,
ts_model_rank_tbl()
,
ts_model_spec_tune_template()
,
ts_qq_plot()
,
ts_scedacity_scatter_plot()
,
ts_to_tbl()
,
util_difflog_ts()
,
util_doubledifflog_ts()
,
util_log_ts()
,
util_singlediff_ts()
# Example 1: Using a time series dataset
util_doublediff_ts(AirPassengers)
# Example 2: Using a different time series dataset
util_doublediff_ts(BJsales)$ret
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.