Time Series: A Data Analysis Approach
Q Using R S
Instructor’s Manual
R.H. Shumway and D.S. Stoffer
! Please Do Not Reproduce !
We assume that astsa version 1.8.8 or higher has been installed. It must be loaded by issuing the command
library(astsa) at the beginning of an R session. All the data are loaded when the package is loaded. See the package
notes and changelog at https://github.com/nickpoison/astsa/blob/master/NEWS.md.
Complete Chapter Solutions Manual
are included (Ch 1 to 8)
** Immediate Download
** Swift Response
** All Chapters included
,Contents
1 Chapter 1 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Chapter 2 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Chapter 3 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4 Chapter 4 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5 Chapter 5 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
6 Chapter 6 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7 Chapter 7 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
8 Chapter 8 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Appendix A Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
, Chapter 1
1.1 Code for (a)-(c):
w = rnorm(150,0,1) # 50 extra to avoid startup problems
xa = filter(w, filter=c(0,-.9), method="recursive")[-(1:50)] # AR
xb = 2*cos(2*pi*(1:100)/4) + rnorm(100,0,1) # sinusoid + noise
xc = log(jj)
va = filter(xa, rep(1,4)/4, sides=1) # moving average
vb = filter(xb, rep(1,4)/4, sides=1) # moving average
vc = filter(xc, rep(1,4)/4, sides=1) # moving average
par(mfrow=c(3,1), mar=c(3,3,2,1))
tsplot(xa, main="autoregression")
lines(va, col=2)
tsplot(xb, main="sinusoid + noise")
lines(vb, col=2)
tsplot(xc, main="Johnson & Johnson")
lines(vc, col=2)
(d) Seasonal adjustment is a filter to remove obvious seasonal periodicities (e.g., quarterly or annual fluctuations) so that other
interesting dynamics may be observed.
(e) All 3 time series generated had a primary period of 4 (1 cycle every 4 time points). The filter that averages 4 contiguous time
points removes the periodic behavior and accentuates the “trend” (no trend in the first two, linear trend in the third series).
1.2 (a)
par(mfrow=2:1)
tsplot(EQ5, main="Earthquate")
tsplot(EXP6, main="Explosion")
(b)
ts.plot(EQ5, EXP6, col=1:2)
legend('topleft', lty=1, col=1:2, legend=c('EQ', 'EXP'))
(c) The major differences are how quickly the signal dies out in the explosion versus the earthquake and the larger amplitude of the
signals in the explosion.
1.3 Part (a) code is
par(mfrow=c(3,3))
for (i in 1:9){
x = cumsum(rnorm(500))
tsplot(x) }
Part (b) will be similar:
par(mfrow=c(3,3))
for (i in 1:9){
x = filter(rnorm(500), filter=rep(1/3,3))
tsplot(x) }
(c) The major difference between the two is that the moving averages look the same in each plot, whereas the random walks are
different, some increase while some decrease.
1.4 For part (a) use tsplot(gdp) and note that it looks like a random walk with drift.
For part (b) and (c), the growth rate looks like white noise (or moving average is ok). The code is