You are on page 1of 22

Stat 153: Lecture 1 – Parametric Fitting

Sören Künzel

srk@berkeley.edu

Monday 31st October, 2016

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 1 / 13
Google Trend

Google Trends Data for UC Berkeley


100
Berkeley Search Popularity

80
60
40
20
0

0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 2 / 13
Google Trend

Google Trends Data for UC Berkeley


100
Berkeley Search Popularity

80
60
40
20
0

0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 2 / 13
White Noise
white noise

30
10
−10

Series noise
−30

0 50 100 150 200 250 300


0.8

Weekly Time
ACF

0.4
0.0

Series noise
0 5 10 15 20
0.10

Lag
Partial ACF

−0.10 0.00

5 10 15 20

X1 , . . . , Xn are called white noise if they have mean zero, variance 2 and
are uncorrelated.
Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 3 / 13
Trend and Seasonality

X t = m t + s t + 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.

White noise is in a sense the worst case. Whenever we have more


structure we try to exploit it for better predictions

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 4 / 13
Trend and Seasonality

no seasonality with seasonality


150

100

50

no trend
0

−50

−100

150

100

50

with trend
0

−50

−100

0 100 200 300 0 100 200 300

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 5 / 13
Exploiting Trend and Seasonality

Trend, mt Seasonality, st
Parametric Parametric
(e.g. fit a quadratic model) (e.g fit sinusoidal functions)
Non-parametrically Non-parametrically
(linear filters) (e.g. ŝi = ave(Xi , Xi+d , . . .))
Di↵erencing Di↵erencing

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 6 / 13
Parametric Trend Estimation

Google Trends Data for UC Berkeley


100

1.) Choose a model,


90

e.g.
Berkeley Search Popularity

Y = 1 t + 2 t 2 +c
80
70
60
50
40
30

0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 7 / 13
Parametric Trend Estimation

Google Trends Data for UC Berkeley


100

1.) Choose a model,


90

e.g.
Berkeley Search Popularity

Y = 1 t + 2 t 2 +c
80
70

2.) Fit the model


60
50
40
30

0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 7 / 13
Parametric Trend Estimation

Google Trends Data for UC Berkeley


100

1.) Choose a model,


90

e.g.
Berkeley Search Popularity

Y = 1 t + 2 t 2 +c
80
70

2.) Fit the model


3.) Predict
60
50
40
30

0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 7 / 13
Parametric Trend Estimation

Google Trends Data for UC Berkeley


100

1.) Choose a model,


90

e.g.
Berkeley Search Popularity

Y = 1 t + 2 t 2 +c
80
70

2.) Fit the model


3.) Predict
60

4.) Test the model,


50

using plots, CV,


40

AIC, BIC, etc.


30

0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 7 / 13
Parametric Seasonality Estimation

Seasonality Model
X t = s t + Zt

st has period d: st+d = st .

Parametric
Use a linear model to estimate a and b in
k
X
ŝt = a0 + (aj cos(2⇡ft/d) + bj sin(2⇡ft/d)).
f =1

k  d/2 is the tuning parameter and has to be chosen.

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 8 / 13
Non–Parametric Seasonality Estimation

Google Trends Data for UC Berkeley

1.) Remove the fitted


100

trend
90
Berkeley Search Popularity

80
70
60
50
40
30

0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 9 / 13
Non–Parametric Seasonality Estimation

Google Trends Data for UC Berkeley

1.) Remove the fitted


30

trend
20
Popularity − Fitted Trend

10
0
−10

0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 9 / 13
Non–Parametric Seasonality Estimation

Google Trends Data for UC Berkeley

1.) Remove the fitted


30

trend
2.) Choose a model,
20
Popularity − Fitted Trend

e.g.
10

k = 26
0
−10

0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 9 / 13
Non–Parametric Seasonality Estimation

Google Trends Data for UC Berkeley

1.) Remove the fitted


30

trend
2.) Choose a model,
20
Popularity − Fitted Trend

e.g.
10

k = 26
3.) Fit the model
0
−10

0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 9 / 13
Non–Parametric Seasonality Estimation

Google Trends Data for UC Berkeley

1.) Remove the fitted


30

trend
2.) Choose a model,
20
Popularity − Fitted Trend

e.g.
10

k = 26
3.) Fit the model
0

4.) Predict
−10

0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 9 / 13
Non–Parametric Seasonality Estimation

Google Trends Data for UC Berkeley

1.) Remove the fitted


30

trend
2.) Choose a model,
20
Popularity − Fitted Trend

e.g.
10

k = 26
3.) Fit the model
0

4.) Predict
5.) Test the model,
−10

using plots, CV,


AIC, BIC, etc.
0 50 100 150 200 250 300

Weekly Time

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 9 / 13
Non-Parametric Seasonality Estimation

Seasonality Model
X t = s t + Zt

st has period d: st+d = st .

Non-Parametric Estimator
Note that s is completely determined by s1 , . . . , sd and thus estimate for
i 2 {1, . . . , d} :
ŝi = average(xi , xi+d , xi+2d , . . .)

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 10 / 13
Combining Trend Estimator and Seasonality Estimator

Google Trends Data for UC Berkeley


100
90
Berkeley Search Popularity

80
70
60
50
40
30

0 50 100 150 200 250 300

Sören Künzel (UC Berkeley) Stat Weekly Time


153: Lecture 1 Monday 31st October, 2016 11 / 13
Combining Trend Estimator and Seasonality Estimator

Google Trends Data for UC Berkeley


100
90
Berkeley Search Popularity

80
70
60
50
40
30

0 50 100 150 200 250 300

Sören Künzel (UC Berkeley) Stat Weekly Time


153: Lecture 1 Monday 31st October, 2016 11 / 13
Data Transformation
The idea is to first transform the data to stabilize the variance. The
analysis and prediction is then done for the transformed data.
logarithmic transformation: Yt = log(Xt )
p
square root transformation Yt = Xt

4
50
40

3
log(crime)
30
crime

2
20

1
10

0
0

0 50 100 150 200 250 300 0 50 100 150 200 250 300

Sören Künzel (UC Berkeley) Stat 153: Lecture 1 Monday 31st October, 2016 12 / 13

You might also like