welcome to the course! - amazon s3 · arima modeling with r course outline chapter 1: time series...

28
ARIMA MODELING WITH R Welcome to the Course!

Upload: others

Post on 28-May-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA MODELING WITH R

Welcome to the Course!

Page 2: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

About Me ● Professor of Statistics

● Co-author of two texts on time series

● astsa-package

Page 3: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Time series…● … are everywhere!

● Finance

● Industrial Processes

● Nature

● Autoregressive (AR) & Moving Average (MA): ARMA

● Integrated ARMA: ARIMA

Page 4: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Course outline● Chapter 1: Time Series Data and Models

● Chapter 2: Fi!ing ARMA models

● Chapter 3: ARIMA models

● Chapter 4: Seasonal ARIMA

Page 5: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Prerequisites● Introduction to R

● Intermediate R

● Introduction to Time Series Analysis in R

Page 6: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA MODELING WITH R

Let’s get started!

Page 7: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA MODELING WITH R

First Things First

Page 8: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

About Me ● Professor of Statistics

● Co-author of two texts on time series

● astsa-package

Page 9: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Time Series Data - I> library(astsa) > plot(jj, main = "Johnson & Johnson Quarterly Earnings per Share", type = "c") > text(jj, labels = 1:4, col = 1:4)

Page 10: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Time Series Data - II> library(astsa) > plot(globtemp, main = "Global Temperature Deviations", type= "o")

Page 11: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Time Series Data - III> library(xts) > plot(sp500w, main = "S&P 500 Weekly Returns")

Page 12: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Time Series Regression ModelsRegression: , where is white noise

White Noise: ● independent normals with common variance

● is basic building block of time series

Moving Average: ( is white noise)

AutoRegression: ( is white noise)

ARMA:

Page 13: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA MODELING WITH R

Let’s practice!

Page 14: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA MODELING WITH R

Stationarity and Nonstationarity

Page 15: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Stationarity

● the mean is constant over time (no trend)

● the correlation structure remains constant over time

A time series is stationary when it is “stable”, meaning:

Page 16: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

StationarityGiven data, we can estimate by averaging

For example, if the mean is constant, we can estimate it by the sample average

Pairs can be used to estimate correlation on different lags:

for lag 1 for lag 2

Page 17: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Southern Oscillation IndexReasonable to assume stationary, but perhaps some slight trend.

Page 18: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Southern Oscillation IndexTo estimate autocorrelation, compute the correlation coefficient between the time series and itself at various lags.

Here you see how to get the correlation at lag 1 and lag 6.

Page 19: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Random Walk TrendNot stationary, but differenced data are stationary.

globtemp

diff(globtemp)

Page 20: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Trend StationarityStationarity around a trend, differencing still works!

chicken

diff(chicken)

Page 21: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Nonstationarity in trend and variabilityFirst log, then difference

Page 22: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA MODELING WITH R

Let’s practice!

Page 23: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA MODELING WITH R

Stationary Time Series: ARMA

Page 24: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Note: Special case of MA( ) is already of this form, where constants are a$er -th term.0 q

q

Wold Decomposition

Any ARMA model has this form, which means they are suited to modeling time series.

For constants

Wold proved that any stationary time series may be represented as a linear combination of white noise:

Page 25: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Generating ARMA using arima.sim()● Basic syntax:

arima.sim(model, n, …)Order of AR Order of MA

● model is a list with order of the model as c(p, d, q) and the coefficients

● n is the length of the series

Page 26: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

Generate MA(1) given by

> x <- arima.sim(list(order = c(0, 0, 1), ma = 0.9), n = 100) > plot(x)

Generating and plo!ing MA(1)

Page 27: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA Modeling with R

> x <- arima.sim(list(order = c(2, 0, 0), ar = c(0, -0.9)), n = 100) > plot(x)

Generating and plo!ing AR(2)Generate AR(2) given by

Page 28: Welcome to the Course! - Amazon S3 · ARIMA Modeling with R Course outline Chapter 1: Time Series Data and Models Chapter 2: Fi!ing ARMA models Chapter 3: ARIMA models Chapter 4:

ARIMA MODELING WITH R

Let’s practice!