View source: R/utils-difflog-stationary.R
util_difflog_ts | R Documentation |
This function attempts to make a non-stationary time series stationary by applying differencing with a logarithmic transformation. It iteratively increases the differencing order until stationarity is achieved or informs the user if the transformation is not possible.
util_difflog_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
and checks if the minimum value of the time series is greater than 0. It then applies differencing
with a logarithmic transformation 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 differencing with a logarithmic transformation 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 the transformation.
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 "diff_log" in this case.
ret: TRUE to indicate a successful transformation.
If the data either had a minimum value less than or equal to 0 or requires more differencing than its frequency allows, it informs the user and suggests trying double differencing with a logarithmic transformation.
If the time series is already stationary or the differencing with a logarithmic transformation is successful,
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_doublediff_ts()
,
util_doubledifflog_ts()
,
util_log_ts()
,
util_singlediff_ts()
# Example 1: Using a time series dataset
util_difflog_ts(AirPassengers)
# Example 2: Using a different time series dataset
util_difflog_ts(BJsales)$ret
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.