Professional Documents
Culture Documents
Yt 0 t t et
Yˆt l E Yt l Y1 , , Yt b0 b1 t l b0 Y1 , , Yt b1 Y1 , , Yt t l
eˆt l Yt l Yˆt l
Var eˆt l Yt l and Yˆt l independen t Var Yt l Var Yˆt l
t 1
2
t l
1 2
From regression analysis theory e2 e2 2
t t t 1
s 1
s
2
t 1
2
t l Note! The average of the numbers 1, 2, … , t is
1 2
e2 1 2 1 1 t t 1 t 1
t
t
t t 1
s
s 1
s t s 1
t 2 2
2
Hence, calculated prediction limits for Yt+l become
t 1
t l
Yˆt l c ˆ e 1
1 2
t 1
2
t t
s1 s 2
For t large it suffices to use the standard normal distribution and a good
approximation is also obtained even if the term
t 1
t l
1
2
t 1
2
t t
s 1 s 2 Yˆt l z 2 ˆ e
is omitted under the square root Pr N 0,1 z 2 2
ARIMA-models
l 1
Yˆt l z 2 ˆ e j 0
ˆ 2
j
Using R
ts=arima(x,…) for fitting models
beerq<-lm(beersales~time(beersales)+I(time(beersales)^2))
plot(y=rstudent(beerq),x=as.vector(time(beersales)),type="b",
pch=as.vector(season(beersales)),xlab="Time")
SAC
Spikes at or close
to seasonal lags
(or half-seasonal
lags)
SPAC
Modelling the autocorrelation at seasonal lags
Yt 1 Yt 1 p Yt p 1 Yt s P Yt Ps et
Yt 1 1B q Bq 1 1B s Q BQs et
Mixed models:
1 B B 1 B B Y
1 p
p
1
s
P
Ps
t
1 B B 1 B B e
1 q
q
1
s
Q
Q s
t
d Yt Yt 1 B Yt
d
Model dth order regular differences:
12Yt 1 B s Yt Yt Yt 12
B B 1 B 1 B
s d
Y B B e
s D
t
s
t
It does not matter whether regular or seasonal differences are taken first
ARIMA p, d , q P, D, Q s
Model specification, fitting and diagnostic checking
Clearly non-
stationary at non-
seasonal level, i.e.
there is a long-
term trend
Investigate SAC and SPAC of original data
Wt 1 B12 Yt Yt Yt 12
U t 1 B 1 B12 Yt 1 B Wt Wt Wt 1 Yt Yt 12 Yt 1 Yt 13
beer_sdiff1rdiff1 <- diff(beer_sdiff1,lag=1)
Vt 1 B 1 B12 Yt 1 B U t U t U t 1
2
Wt Wt 1 Wt 1 Wt 2 Wt 2Wt 1 Wt 2
Yt Yt 12 2Yt 1 Yt 13 Yt 2 Yt 14
beer_sdiff1rdiff2 <- diff(diff(beer_sdiff1,lag=1),lag=1)
model1 <-arima(beersales,order=c(2,2,0),
seasonal=list(order=c(0,1,1),period=12))
Series: beersales
ARIMA(2,2,0)(0,1,1)[12]
Coefficients:
ar1 ar2 sma1
-1.0257 -0.6200 -0.7092
s.e. 0.0596 0.0599 0.0755
tsdiag(model1)
standardized residuals
SPAC(standardized residuals)
Box-Ljung test
data: residuals(model1)
X-squared = 30.1752, df = 9, p-value = 0.0004096
For seasonal data with season length s the L-B test is usually calculated for
K = s, 2s, 3s and 4s
Box.test(residuals(model1), lag = 24, type = "Ljung-Box",
fitdf = 3)
Box-Ljung test
data: residuals(model1)
X-squared = 57.9673, df = 21, p-value = 2.581e-05
Box.test(residuals(model1), lag = 36, type = "Ljung-Box",
fitdf = 3)
Box-Ljung test
data: residuals(model1)
X-squared = 76.7444, df = 33, p-value = 2.431e-05
Box-Ljung test
data: residuals(model1)
X-squared = 92.9916, df = 45, p-value = 3.436e-05
Hence, the residuals from the first model are not satisfactory
model2 <-arima(beersales,order=c(1,2,1),
seasonal=list(order=c(0,1,1),period=12))
print(model2)
Series: beersales
ARIMA(1,2,1)(0,1,1)[12]
Coefficients:
ar1 ma1 sma1
-0.4470 -0.9998 -0.6352
s.e. 0.0678 0.0176 0.0930
The classical set-up uses deterministic trend functions and seasonal indices
Yt mt S t et
Examples :
12
Yt 0 1 t s , j x j t et linear tr end in monthly data
j 2
1 if t is in month j
where x j t
0 otherwise
Yt 0 1 t 2 t 2 quatadic trend, no seasonal variatio n
To extend the classical set-up with explanatory variables comprising other time
series we need another way of modelling.
Yt 0 1 Yt 1 p Yt p et 1 et 1 q et q
1 B
1 p B p
Yt 0 1
1 B 1 B q
et
B Yt 0 B et
C B b B
Yt 0 B Xt et
B B
Special case 1:
Xt relates to some event that has occurred at a certain time points (e.g. 9/11)
1 t T
X t T Pt T
0 t T
Step functions would imply a permanent change in the level of Yt . Such a change
can further be constant or gradually increasing (depending on (B) and (B) ). It
can also be delayed (depending on b )
Strep and pulse functions are used to model the effects of a particular event, as
so-called intervention.
Intervention models
For Xt being a “regular” times series (i.e. varying with time) the models are called
transfer function models