Introduction to time series and stationarity

ARIMA Models in Python

James Fulton

Climate informatics researcher

Motivation

Time series are everywhere

  • Science
  • Technology
  • Business
  • Finance
  • Policy
ARIMA Models in Python

Course content

You will learn

  • Structure of ARIMA models
  • How to fit ARIMA model
  • How to optimize the model
  • How to make forecasts
  • How to calculate uncertainty in predictions
ARIMA Models in Python

Loading and plotting

import pandas as pd
import matplotlib as plt

df = pd.read_csv('time_series.csv', index_col='date', parse_dates=True)
date            values
2019-03-11    5.734193    
2019-03-12    6.288708    
2019-03-13    5.205788    
2019-03-14    3.176578
ARIMA Models in Python

Trend

fig, ax = plt.subplots()
df.plot(ax=ax)
plt.show()

ARIMA Models in Python

Seasonality

ARIMA Models in Python

Cyclicality

ARIMA Models in Python

White noise

White noise series has uncorrelated values

  • Heads, heads, heads, tails, heads, tails, ...
  • 0.1, -0.3, 0.8, 0.4, -0.5, 0.9, ...
ARIMA Models in Python

Stationarity

Stationary

  • Trend stationary: Trend is zero

Not stationary

ARIMA Models in Python

Stationarity

Stationary

  • Trend stationary: Trend is zero
  • Variance is constant

Not stationary

ARIMA Models in Python

Stationarity

Stationary

  • Trend stationary: Trend is zero
  • Variance is constant
  • Autocorrelation is constant

Not stationary

ARIMA Models in Python

Train-test split

# Train data - all data up to the end of 2018
df_train = df.loc[:'2018']

# Test data - all data from 2019 onwards
df_test = df.loc['2019':]
ARIMA Models in Python

Let's Practice!

ARIMA Models in Python

Preparing Video For Download...