Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

One Whose Properties Do Not Depend On The Time at Which The Series Is Observed

Download as xlsx, pdf, or txt
Download as xlsx, pdf, or txt
You are on page 1of 12

Stationary Series

Stationary time series is


one whose properties do
not depend on the time at
which the series is observed

Time series with trends, or with s


A white noise series is stationary

To check if time series is Dicky Fuller test


stationary
Ho: Time Series is not stationary
Ha: Time Series is stationary

Lag

Lag values are values from Lags


previous periods

ACF

Correlation between original series


and Lag-1 series = ACF(1)

ACF – Autocorrelation
Function represents the
ACF – Autocorrelation
Function represents the
correlation between original
series and the lags

PACF

PACF(1) = ACF(1)
PACF(2) is the correlation between Original
and Lag(2) series AFTER the influence of
PACF – Partial Lag(1) series has been eliminated
autocorrelation adjusts for PACF(3) is the correlation between Original
intervening periods and Lag(3) series AFTER the influence of
Lag(1) and Lag(2) series has been eliminated
Series

es with trends, or with seasonality, are not stationary


oise series is stationary

Fuller test
es is not stationary
ries is stationary

Lags

ACF

een original series Correlation between original series and Lag-2 series = ACF(2)
ries = ACF(1) Correlation between original series and Lag-3 series = ACF(3)
Autocorrelations decrease as lag increases
-1 <= ACF <=1
ACF(0) = 1 (Correlation of original series with itself)
PACF

tion between Original


ER the influence of
eliminated
tion between Original
ER the influence of
es has been eliminated
Differencing is done on the train dataset to check for stationarity. This step is done just to know what val
passed to the ARIMA model. We pass the actual time series i.e. train dataset (non-differenced) to train th
derived value of "d".
Note: If the train data had to be transformed to achieve stationarity, transformed data has to be passed to the
should also be transformed before performing the forecast.Then do a reverse transformation to get actu
e.g. if log tranformation was done to achieve stationarity, once we get the forecast from the model, get e
forecast as it is inverse of log. This will get forecast value as per original data.
from statsmodels.tsa.arima_model import ARIMA
Python Code
arima_model = ARIMA(train['Y'].values,order=(p,d,q)).fit()
As in regression we have some checks to be done on th residuals to confirm its assumptions
1) Residuals are normally distributed
Residual Checks 2) Mean value of residual is 0
3) There is no significant correlation between the residuals
Above checks are done using the "arima_model.plot_diagnostics()"

SARIMA
* When there is a seasonal componenet in the time series SARIMA model is built for forecasting
* "S" in SARIMA stands for seasonal component
* In a seasonal timeseries, we first need to make a note of the frequency at which the seasonality occurs w
* SARIMA needs additional 3 parameters corresponding to the seasonal aspect in the time series i.e. "P","D
* P: Seasonal autoregressive order
P=1 would make use of the first seasonally offset observation in the model, e.g. Y tF. P=2, would use the la
*
observations YtF, Y2tF.
* D: Seasonal difference order. Similarly, a D of 1 would calculate a first order seasonal difference (diff(F) c
* Q: Seasonal moving average order. Q=1 would use a first order error at seasonal offset prediction in the
* "P" can be arrived manually by viewing the "pacf" plot. But now we just need to observe the correlation
seaonality i.e. at "F", "2F", "3F" etc. and count until it becomes insignificant
* "Q" can be arrived manually by viewing the "acf" plot. But now we just need to observe the correlation w
i.e. at "F", "2F", "3F" etc. and count until it becomes insignificant
* Due to availabiality of improved computational power we can also determine "P" and "Q" values using g
Recommend to try range of values between 0 through 3 and not higher to avoid increasing complexity o
* So in SARIMA along with "p", "d", "q" parameters we need to provide "F", "P","D","Q" as well as input to
import statsmodels.api as sm

Python
Code SARIMA_model = sm.tsa.statespace.SARIMAX(train['Y'].values,
order=(p, d, q),
seasonal_order=(P, D, Q, F)).fit(maxiter=1000)
is done just to know what value of "d" has to be
et (non-differenced) to train the ARIMA model with

d data has to be passed to the ARIMA model. test data


se transformation to get actual forecasted values. For
forecast from the model, get exponent value of the
ta.
s to confirm its assumptions

s()"

built for forecasting

which the seasonality occurs within a year (F)


ect in the time series i.e. "P","D","Q"

, e.g. Y tF. P=2, would use the last two seasonally offset

r seasonal difference (diff(F) corresponds to D=1)


asonal offset prediction in the model
ed to observe the correlation when there is
t
ed to observe the correlation when there is seaonality

ine "P" and "Q" values using grid search method.


avoid increasing complexity of the model
"P","D","Q" as well as input to the model

You might also like