Time Series Analysis and Forecasting
Time Series Analysis and Forecasting
Is it stationary?
Is there a seasonality?
Autocorrelation
Informally, autocorrelation is the similarity
between observations as a function of the time lag
between them.
Seasonality
Seasonality refers to periodic fluctuations. For
example, electricity consumption is high during the
day and low during night, or online sales increase
during Christmas before slowing down again.
Example of seasonality
Stationarity
Stationarity is an important characteristic of time
series. A time series is said to be stationary if its
statistical properties do not change over time. In
other words, it has constant mean and variance,
and covariance is independent of time.
moving average
exponential smoothing
ARIMA
Moving average
The moving average model is probably the most
naive approach to time series modelling. This model
simply states that the next observation is the mean
of all past observations.
Exponential smoothing
Exponential smoothing uses a similar logic to moving
average, but this time, a different decreasing
weight is assigned to each observations. In other
words, less importance is given to observations as
we move further from the present.
Mathematically:
Seasonal autoregressive
integraded moving average
model (SARIMA)
SARIMA is actually the combination of simpler
models to make a complex model that can model
time series exhibiting non-stationary properties and
seasonality.
Below, q would be 4.
Moving average
Let’s use the moving average model to smooth our
time series. For that, we will use a helper function
that will run the moving average model on a
specified time window and it will plot the result
smoothed curve:
Exponential smoothing
Now, let’s use exponential smoothing to see if it
can pick up a better trend.
Modelling
As outlined previously, we must turn our series into
a stationary process in order to model it. Therefore,
let’s apply the Dickey-Fuller test to see if it is a
stationary process:
SARIMA
Modelling