Practice 1 From Introductory Time Series With R
Practice 1 From Introductory Time Series With R
6000
10000
14000
1996
1998
2000
2002
Time
2004
2006
acf(ts.union(App.ts, Act.ts))
0.6
0.2
0.6
0.2
ACF
App.ts
Act.ts
0.2
0.6
Lag
0.6
Lag
0.2
ACF
3.0
2.0
1.0
0.0
Lag
Lag
0.5
0.5
0.5
0.5
ACF
app.ran.ts
0.5
1.0
1.5
2.0
2.5
3.0
0.0
0.5
1.0
1.5
2.0
act.ran.ts
2.5
3.0
2.5
3.0
0.5
0.5
Lag
0.5
Lag
0.5
ACF
0.0
3.0
2.0
1.0
0.0
0.0
Lag
0.5
1.0
1.5
Lag
2.0
0.2
0.4
0.0
ACF
0.4
0.6
Lag
***
**
***
'*' 0.05 '.' 0.1 ' ' 1
6000
2000
10000
10
50000
30000
0 10000
Cumulative sales
10
35
30
25
20
15
5
10
Complaints
1996
1997
1998
1999
2000
Time / months
plot(Comp.hw1)
25
20
15
5
10
Observed / Fitted
30
35
HoltWinters filtering
10
20
30
40
Time
Comp.hw1$SSE
## [1] 2502.028
Comp.hw2 <- HoltWinters(complaints, alpha = 0.2, beta=FALSE, gamma=FALSE)
Comp.hw2
##
##
##
##
##
##
##
##
##
##
##
##
##
Comp.hw2$SSE
## [1] 2526.39
8
1980
1985
1990
1995
Time (months)
sweetw.hw <- HoltWinters (sweetw.ts, seasonal = "mult")
sweetw.hw
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
s3
s4
s5
s6
s7
s8
s9
s10
s11
s12
1.0275900
1.1991924
1.5463100
0.6730235
0.8925981
0.7557814
0.8227500
0.7241711
0.7434861
0.9472648
sweetw.hw$coef
##
a
## 285.6890314
##
s5
##
1.5463100
##
s11
##
0.7434861
b
1.3509615
s6
0.6730235
s12
0.9472648
s1
0.9498541
s7
0.8925981
s2
0.9767623
s8
0.7557814
sweetw.hw$SSE
## [1] 477693.9
sqrt(sweetw.hw$SSE/length(sweetw))
## [1] 50.54219
sd(sweetw)
## [1] 121.3908
plot (sweetw.hw$fitted)
10
s3
1.0275900
s9
0.8227500
s4
1.1991924
s10
0.7241711
0.8
1.2
season
0.8 1.2 1.6 100
trend
300
level
100 300 500
xhat
sweetw.hw$fitted
1985
1990
Time
plot (sweetw.hw)
11
1995
Observed / Fitted
HoltWinters filtering
1985
1990
Time
data(AirPassengers)
AP <- AirPassengers
AP.hw <- HoltWinters(AP, seasonal = "mult")
plot(AP.hw)
12
1995
500
400
300
100
200
Observed / Fitted
600
HoltWinters filtering
1950
1952
1954
1956
Time
13
1958
1960
700
500
300
100
1950
1955
1960
1965
Time
Reference:
Cowpertwait, Paul SP, and Andrew V. Metcalfe. Introductory time
series withR. Springer Science & Business Media, 2009.
14