Time Series
Time Series
• Test the Significance of γ: If the test statistic is less than the critical value, you
reject the null hypothesis and conclude that the series is stationary.
• Kwiatkowski–Phillips–Schmidt–Shin (KPSS) Test
• These tests are used for testing a NULL Hypothesis (HO) that will
perceive the time series as stationary around a deterministic trend
against the alternative of a unit root. Since TSA is looking for
Stationary Data for its further analysis, we have to ensure that the
dataset is stationary.
• Auto-Correlation Function (ACF)
• ACF indicates how similar a value is within a given time series and the
previous value. (OR) It measures the degree of the similarity between
a given time series and the lagged version of that time series at the
various intervals we observed.
• Python Statsmodels library calculates autocorrelation. It identifies a
set of trends in the given dataset and the influence of former
observed values on the currently observed values.
• Partial Auto-Correlation (PACF)
• PACF is similar to Auto-Correlation Function and is a little challenging
to understand. It always shows the correlation of the sequence with
itself with some number of time units per sequence order in which
only the direct effect has been shown, and all other intermediary
effects are removed from the given time series.
• Noise — Noise is also known as residues or irregulars. It’s what remains
after trend and seasonality are removed. It’s short-term fluctuation
which is not predictable. Sometimes noise can be dominant compared
with trend and seasonality, making this kind of time series data harder
to forecast. The stock price is a manifest example.
• White noise is the extreme situation of noise that has no trend and
seasonality. Therefore it’s nearly impossible to predict, and it’s a kind of
stationary time-series data.
White noise
Decomposition Models
• Additive models are used when the magnitudes of the seasonal and residual values do not depend on
the level of the trend.
2
➢ Autoregressive Models
2
➢ Autoregressive Models
2
➢ Autoregressive Models
2
What Is an Autoregressive
Model?
• Autoregressive models predict future values based on past values.
• For example, an autoregressive model might seek to predict a stock's
future prices based on its past performance.
• They are widely used in technical analysis to forecast future security
prices.
• Autoregressive models implicitly assume that the future will resemble
the past.
• Therefore, they can prove inaccurate under certain market conditions,
such as financial crises or periods of rapid technological change.
AR (Auto-Regressive) Model
• The time period at t is impacted by the observation at various slots t-
1, t-2, t-3, ….., t-k. The impact of previous time spots is decided by the
coefficient factor at that particular period of time.
• The price of a share of any particular company X may depend on all
the previous share prices in the time series. This kind of model
calculates the regression of past time series and calculates the
present or future values in the series in know as Auto Regression (AR)
model.
Yt = β₁* y ₜ- + β₂* yₜ-₂ + β₃ * yₜ-₃ + ………… + βₖ * yₜ-ₖ
1
• An Autoregressive (AR) model is a type of statistical model used to describe
certain time-varying processes in nature, economics, and many other fields.
The model predicts future values based on past values of the same variable.
• Autoregressive (AR) Model: The term "autoregressive" consists of two
parts: "auto" means "self," and "regression" refers to a statistical
relationship between variables. In this model, the dependent variable is
regressed against its own previous values.
• It is called an autoregressive model because it uses the relationship
between a series of past observations to predict future values.
• An AR model of order p (denoted as AR(p)) implies that the value at any
given time is a linear combination of the past p values.
• Consider an example of a milk distribution company that produces
milk every month in the country.
• We want to calculate the amount of milk to be produced current
month considering the milk generated in the last year.
• We begin by calculating the PACF values of all the 12 lags with
respect to the current month.
• If the value of the PACF of any particular month is more than a
significant value only those values will be considered for the model
analysis.
AR (Auto-Regressive) Model
For e.g in the figure the values 1,2, 3 up to 12 displays the
direct effect(PACF) of the milk production in the current
month w.r.t the given the lag t. If we consider two
significant values above the threshold then the model will
be termed as AR(2).
Year 2000 2001 2002 2003 2004 2005 2006
Profit 60 72 75 65 80 95 102
(Rs in
lakh)
Fit a trend line to the following data by the method of least square.
(i)Calculate the estimated trend values.
(ii)Also estimate the likely profit for 2008.
Month Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Sales $000 125 145 186 131 151 192 137 157 198 143 163 204
Fit a trend line to the following data by the method of least square.
• Calculate the seasonal indices for the rain fall (in mm) data in Tamil Nadu given below by simple average method
Year Season
I II III IV
2001 118.4 260.0 379.4 70
2002 85.8 185.4 407.1 8.7
2003 129.8 336.5 403.1 12.0
2004 283.4 360.7 472.1 14.3
2005 231.7 308.5 828.8 15.9
Difference between AR to MA
• The AR model relates the current value of the series to
its past values. It assumes that past values have a
linear relationship with the current value.
• The MA model relates the current value of the series to
past white noise or error terms. It captures the shocks
or unexpected events in the past that are still affecting
the series.
• Key Characteristics
• Linearity: The AR model is a linear model, as it assumes a linear
relationship between the current value and past values.
• Stationarity: The AR model assumes that the underlying time series is
stationary, meaning its statistical properties (mean, variance,
autocorrelation) do not change over time. If the time series is not
stationary, it is usually differenced to achieve stationarity before applying
the AR model.
• Lagged Values: The model uses a specified number of lagged values,
which is denoted by ppp, the order of the model. Higher-order models
use more lagged values.
MA (Moving Average) Model
• The time period at t is impacted by the unexpected external factors at
various slots t-1, t-2, t-3, ….., t-k. These unexpected impacts are
known as Errors or Residuals.
• The impact of previous time spots is decided by the coefficient factor
α at that particular period of time.
• The price of a share of any particular company X may depend on
some company merger that happened overnight or maybe the
company resulted in shutdown due to bankruptcy.
• This kind of model calculates the residuals or errors of past time
series and calculates the present or future values in the series in know
as Moving Average (MA) model.
➢ Moving Average Models
4
➢ Moving Average Models
● A moving average
model is used for
forecasting future values,
while moving average
smoothing is used for
estimating the trend-cycle
of past values.
● Denoted as MA(q).
4
➢ Moving Average Models
4
➢ Moving Average Models
4
5
➢ ARMA and ARIMA Models
5
➢ ARMA and ARIMA Models
5
➢ ARIMA Model
5
➢ ARIMA Model
5
➢ ARIMA Model
5
➢ ARIMA Model
5
➢ ARIMA Model
5
➢ ARIMA Model
5
➢ Autocorrelation Function (ACF)
https://allisonhorst.com/time-series-acf
6
➢ Building and Evaluating an ARIMA Model
6
➢ Building and Evaluating an ARIMA Model
6
➢ Reasons to Choose and Cautions
6
➢ Reasons to Choose
6
➢ Reasons to Cautions
6
66
67