This function performs pre-processing on a time series object(ts) to treat heterocedasticity, trend and seasonality in order to make the serie stationary.
prep(tserie, homogenize.method = "log", detrend.method = "differencing",
nd = NULL, deseason.method = "differencing", nsd = NULL,
detrend.first = TRUE)
A ts object.
A string. Current methods available are "log" and "boxcox". Method "log" is set as default. If you don't want to perform this transformation, set method as "none".
A string. Current methods available are "differencing" and "sfsm". Method "differencing" is set as default. If you don't want to perform this transformation, set method as "none".
A number. Number of differences you want to apply to the "differencing" detrending method. As default its value is NULL, which means nd will be calculated internally.
A string. Current methods available are "differencing". Method "differencing" is set as default. If you don't want to perform this transformation, set method as "none".
A number. Number of seasonal differences you want to apply to the "differencing" deseasoning method. As default its value is NULL, which means nsd will be calculated internally.
A boolean. TRUE if detrending method is applied first, then deseasoning. FALSE if deseasoning method is applied first. Default is TRUE.
A list is returned of class prep
containing:
Processed ts object.
Method used for homogenizing.
Method used for detrending.
Number of differences used on detrending through differencing.
First nd
values of the original series.
Method used for deseasoning.
Number of seasonal differences used on deseasoning through differencing.
First nsd
seasons of the original series.
Processed ts object
Vector of means used in "sfsm" detrending method.
Coefficient used in "boxcox" transformation.
Start of the original time serie.
Length of the original time serie.
Returns an object prep
which stores all data needed to undo the changes later on.
This function provides an automatic way of pre-processing based on unit root tests, but this is not the perfect way to do it. You should always check manually if the given time serie is actually stationary, and modify the parameters according to your thoughts.
prep.homogenize.log
,
prep.homogenize.boxcox
,
prep.detrend.differencing
,
prep.detrend.sfsm
,
prep.deseason.differencing
,
prep.check.acf
,
prep.check.adf
# NOT RUN {
prep(AirPassengers)
prep(AirPassengers,homogenize.method='boxcox',detrend.method='none')
# }
Run the code above in your browser using DataLab