• Keine Ergebnisse gefunden

Solution to Series 9

N/A
N/A
Protected

Academic year: 2022

Aktie "Solution to Series 9"

Copied!
4
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Dr. M. Dettling Applied Time Series Analysis SS 2014

Solution to Series 9

1. a) We use the log-transformation, we have seasonal data and a trend.

> d.airshort1 <- log(d.airshort)

> d.airshort2 <- diff(d.airshort1, lag=12)

> d.airshort3 <- diff(d.airshort2, 1)

> f.acf(d.airshort3)

Time

series

1950 1951 1952 1953 1954 1955 1956 1957

−0.15−0.050.050.15−0.51.0

Lag k

Auto−Korr.

0.0 0.5 1.0 1.5 −0.40.2

Lag k

part. Autokorr

0.08333333 1.00000000

ASARIM A(0,1,1)(0,1,1)12 could be an appropriate model.

> s1.air <- arima(d.airshort1,order=c(0,1,1),seasonal=c(0,1,1))

> s1.air Call:

arima(x = d.airshort1, order = c(0, 1, 1), seasonal = c(0, 1, 1)) Coefficients:

ma1 sma1 -0.394 -0.613 s.e. 0.117 0.108

sigma^2 estimated as 0.00151: log likelihood = 149, aic = -292

> f.acf(s1.air$residuals)

Time

series

1950 1952 1954 1956

−0.100.000.10−0.21.0

Lag k

Auto−Korr.

0.0 0.5 1.0 1.5 −0.20.2

Lag k

part. Autokorr

0.08333333 1.00000000

The residuals look ok.

> t.pr <- predict(s1.air, n.ahead=48)

> plot(log(d.air), xlim=c(1950,1961), ylim=c(4.5,7.5))

> t.u <- t.pr$pred+1.96*t.pr$se

> t.l <- t.pr$pred-1.96*t.pr$se

> lines(t.pr$pred, col="red")

> lines(t.u, col="green", lty=2)

> lines(t.l, col="green", lty=2)

(2)

2

Time

log(d.air)

1950 1952 1954 1956 1958 1960

4.55.05.56.06.57.07.5

b) > fit <- HoltWinters(d.airshort1)

> t.pr <- predict(fit, 48, prediction.interval=T)

> plot(log(d.air), xlim=c(1950,1961), ylim=c(4.5,7.5))

> lines(t.pr[,"fit"], col="red")

> lines(t.pr[,"upr"], col="green", lty=2)

> lines(t.pr[,"lwr"], col="green", lty=2)

Time

log(d.air)

1950 1952 1954 1956 1958 1960

4.55.05.56.06.57.07.5

> f.acf(residuals(fit))

Time

series

1950 1951 1952 1953 1954 1955 1956 1957

−0.100.000.10−0.21.0

Lag k

Auto−Korr.

0.0 0.5 1.0 1.5 −0.2

Lag k

part. Autokorr

0.08333333 1.00000000

The residuals look ok.

Trend extrapolation:

c) > fit <- stl(d.airshort1, s.window="periodic")

> trend <- fit$time.series[,2]

> ## Least Squares for trend over the last 4 years

> yy <- window(trend, start=c(1953,1))

> xx <- time(yy)

> reg <- lm(yy~xx)

> ## Trend Extrapolation

> kk <- 48

> trend.ex <- rev(trend)[1]+((1:kk)/12)*coef(reg)[2]

> trend.ex

[1] 5.85 5.86 5.87 5.88 5.89 5.90 5.91 5.92 5.93 5.95 5.96 [12] 5.97 5.98 5.99 6.00 6.01 6.02 6.03 6.04 6.05 6.06 6.08 [23] 6.09 6.10 6.11 6.12 6.13 6.14 6.15 6.16 6.17 6.18 6.19 [34] 6.21 6.22 6.23 6.24 6.25 6.26 6.27 6.28 6.29 6.30 6.31 [45] 6.33 6.34 6.35 6.36

(3)

3

Saisonal effect:

> ## saisonality

> saison <- fit$time.series[,1]

> saisy <- window(saison, start=c(1953,1))

> sais.ex <- ts(saisy, start=c(1957,1), end=c(1960,12), freq=12) Remainder:

> ## remainder

>

> remainder <- fit$time.series[,3]

> f.acf(remainder)

Time

series

1950 1952 1954 1956

−0.100.000.05−0.2

Lag k

Auto−Korr.

0.0 0.5 1.0 1.5 −0.30.3

Lag k

part. Autokorr

0.08333333 1.00000000

Remainder looks like an AR(3) model.

> fit.rem <- arima(remainder, order=c(3,0,0))

> f.acf(resid(fit.rem))

Time

series

1950 1952 1954 1956

−0.050.000.05−0.21.0

Lag k

Auto−Korr.

0.0 0.5 1.0 1.5 −0.20.2

Lag k

part. Autokorr

0.08333333 1.00000000

Residuals look good. Forecast of remainder:

> pred <- predict(fit.rem, n.ahead=48)

> rem.ex <- pred$pred

Putting everything together (trend, seasonality, remainder):

> ## everything together

> series.ex <- trend.ex+sais.ex+rem.ex

> ## Plotting

> plot(log(d.air), xlim=c(1950,1961), ylim=c(4.5,7.5))

> lines(series.ex, col="red", lwd=2)

Time

log(d.air)

1950 1952 1954 1956 1958 1960

4.55.05.56.06.57.07.5

(4)

4

d) All of the three methods seem to overestimate this particular time series a little. Probably exponential smoothing works best.

e) No solution.

Referenzen

ÄHNLICHE DOKUMENTE

The model without the predictor smoking fits sufficiently well. Moreover, the result of the Chi-squared test for the Null deviance and both deviance based individual tests

Yes it seems that the diet B results in clearly bigger coagulation. Furthermore the variance within group is smaller than the variance between group, thus the effect is expected to

Disregarding these, the mean of the residuals is negative, so the zero expectation assumption seems to be violated.. The constant variance assumption seems to be fine (without

The model without the predictor smoking fits sufficiently well. Moreover, the result of the Chi-squared test for the Null deviance and both deviance based individual tests

This means if we calculate exp(r.pred$pred), we get the predicted values on the original scale. In Part b), however, the formation of differences needs reversing (by taking

1. a) An experimenter wishes to compare four treatments in blocks of two runs. Find a BIBD with six blocks. Find a BIBD with seven blocks. Analyze these data in a split plot anova..

Der Traininszustand (Variable “Exercise”) scheint gem¨ ass dem Plot etwas erstaunlicherweise keinen Einfluss auf die Herzfrequenz zu haben. Weiter scheint es, dass zwis- chen

Applied Statistical Regression Dr. Thus a line with slope c and axis intercept d is drawn in this subtask. Which means the line drawn is described by the equation x = cy + d, i.e..