Вы находитесь на странице: 1из 24

Stat 153: Lecture 2 – Muliplicative SARIMA and CV

Sören Künzel

srk@berkeley.edu

Monday 7th November, 2016

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 1 / 14
Decreasing IQ

IQ development
120
val
100
80

2 4 6 8 10
t

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 2 / 14
Decreasing IQ

IQ development
130
120
110
val
100
90
80

2 4 6 8 10
Sören Künzel (UC Berkeley) Stat 153: Lecture
t 2 Monday 7th November, 2016 2 / 14
Decreasing IQ

IQ development
130
120
110
val
100
90
80

2 4 6 8 10
Sören Künzel (UC Berkeley) Stat 153: Lecture
t 2 Monday 7th November, 2016 2 / 14
Trend and Seasonality

Xt = mt + st + Zt

mt is the trend, e.g. mt = (t − 150)3


st is the seasonality, e.g. st = 15 sin(2πt/30)
Zt is a stationary process, e.g. Gaussian white noise.

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 3 / 14
ARIMA

ARMA(p,q)
{Xt } is said to be ARMA(p, q) with mean µ, if {Xt − µ} is ARMA(p, q),
i.e., if {Xt } is stationary and

φ(B)(Xt − µ) = θ(B)Zt

with φ(z) = 1 − φ1 z − · · · − φp z p and θ(z) = 1 + θ1 z + · · · + θq z q

ARIMA(p,d,q)
{Yt } is said to be ARIMA(p, d, q) with mean µ, if Xt = ∇d Yt is
ARMA(p, d) with mean µ.

md <- arima(dataset, order = c(p, d, q))


predict(md, 10) #predicts the next 10 values

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 4 / 14
Seasonal ARIMA

ARMA(P, Q)d
{Xt } is said to be ARMA(P, Q)d with mean µ and period d, if {Xt } is
stationary and
Φ(B d )(Xt − µ) = Θ(B d )Zt
with Φ(B d ) = 1 − φ1 B d − · · · − φP B Pd and
Θ(B d ) = 1 + θ1 B d + · · · + θQ B Qd .

{Xt } is said to be ARMA(P, Q)d with mean µ and period d, if {Xt } is


stationary and

(Xt −µ)−φ1 (Xt−d −µ)−· · ·−φP (Xt−Pd −µ) = Zt +θ1 Zt−d +· · ·+θQ Zt−Qd

md <- arima(Y, order = c(0,0,0),


seasonal = list(order = c(P, 0, Q), period = d))
predict(md, 10) #predicts the next 10 values
Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 5 / 14
Multiplicative Seasonal ARIMA

ARMA(P, Q) × (P, D)d


{Xt } is said to be a multiplicative seasonal ARMA(p, q) × (P, Q)d with
mean µ and period d, if {Xt } is stationary and

Φ(B d )φ(B)(Xt − µ) = Θ(B d )θ(B)Zt

with for polinomials Φ a polinomial of order P, φ a polinomial of order p,


Θ a polinomial of order Q, θ a polinomial of order q.

md <- arima(Y, order = c(p,d,q),


seasonal = list(order = c(P, D, Q), period = s))
predict(md, 10) #predicts the next 10 values

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 6 / 14
Example 1 and 2

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 7 / 14
Forecasting

1.) Exploratory Data Analysis (e.g. Should we remove part of the data?),
2.) Transformation,
3.) Deal with Trend and Seasonality(Parametrically, Differencing, . . . )
until we receive a stationary process,
4.) Fit ARMA (or SARMA) model to the residuals,
5.) Model diagnostic (Ljung-Box-Pierce test, AIC, BIC, CV)
6.) Forecasting

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 8 / 14
Model Selection – the General Idea
Which model is better?
350 355 360 365 370 375 380 385
co2_tr

0 20 40 60 80 100 120

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 9 / 14
Model Selection – the General Idea
Which model is better?
350 355 360 365 370 375 380 385
co2_tr

0 20 40 60 80 100 120

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 9 / 14
Model Selection – the General Idea

MSE
Suppose, we had data (x1 , . . . , xn ) and we wanted to predict
(xn+1 , . . . , xn+k ). Then the Mean Squared Error (MSE) is given by
Pn+k
i=n+1 (xi − x̂i )2
MSE = .
k
Our task is to chose the predictor with the lowest MSE.

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 10 / 14
Model Selection – the General Idea

MSE
Suppose, we had data (x1 , . . . , xn ) and we wanted to predict
(xn+1 , . . . , xn+k ). Then the Mean Squared Error (MSE) is given by
Pn+k
i=n+1 (xi − x̂i )2
MSE = .
k
Our task is to chose the predictor with the lowest MSE.
This is impossible since the xi is unobserved for i > n.

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 10 / 14
Estimating the MSE – AIC & BIC

AIC – Akaike Information Criterion


AIC = −2 log(maximum likelihood) + 2k

k is the number of parameters, e.g. for an ARIMA(p,q) with mean µ,


thus k =
n is the number of observation
maximum likelihood is big, if our model fits the data very well.

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 11 / 14
Estimating the MSE – AIC & BIC

AIC – Akaike Information Criterion


AIC = −2 log(maximum likelihood) + 2k

k is the number of parameters, e.g. for an ARIMA(p,q) with mean µ,


thus k = p + q + 2
n is the number of observation
maximum likelihood is big, if our model fits the data very well.

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 11 / 14
Estimating the MSE – AIC & BIC

AIC – Akaike Information Criterion


AIC = −2 log(maximum likelihood) + 2k

BIC – Bayesian Information Criterion


BIC = −2 log(maximum likelihood) + k log n

k is the number of parameters, e.g. for an ARIMA(p,q) with mean µ,


thus k = p + q + 2
n is the number of observation
maximum likelihood is big, if our model fits the data very well.

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 11 / 14
Estimating the MSE – CV for time series

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 12 / 14
Estimating the MSE – CV for time series

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 12 / 14
Estimating the MSE – CV for time series

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 12 / 14
Estimating the MSE – CV for time series

Suppose we wanted to compare ` competing methods {M1 , . . . , M` } and


we have weekly data for m years.
1.) Fit each method, Mi , to the first k years and pretend that the
remaining years are unknown.
2.) Predict for each fitted method the k + 1st year and compute the MSE
for the prediction.
3.) Repeat those steps for k = k0 , . . . , m − 1, and average for each
method the MSE. This average is called CV-score.
4.) Pick the model with the lowest CV score.

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 13 / 14
Estimating the MSE – CV for time series

Suppose we wanted to compare ` competing methods {M1 , . . . , M` } and


we have weekly data for m years.
1.) Fit each method, Mi , to the first k years and pretend that the
remaining years are unknown.
2.) Predict for each fitted method the k + 1st year and compute the MSE
for the prediction.
3.) Repeat those steps for k = k0 , . . . , m − 1, and average for each
method the MSE. This average is called CV-score.
4.) Pick the model with the lowest CV score.
There are many other ways how one could use the idea of CV to
select the best method and this is just one way and likely not the
best way!

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 13 / 14
Example 3

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 14 / 14
Readings

Read lecture notes 17, 18, 19 from fall (see piazza)

Sören Künzel (UC Berkeley) Stat 153: Lecture 2 Monday 7th November, 2016 15 / 14

Вам также может понравиться