HW1 Solutions
Problem 1
part (a)
#load librariers
library(astsa)
#par(mfrow=2:1)
tsplot(EQ5, main="Earthquake")
Earthquake
Time
EQ
5
0 500 1000 1500 2000
−
0.
4
−
0.
2
0.
0
0.
2
0.
4
tsplot(EXP6, main="Explosion")
1
Explosion
Time
EX
P6
0 500 1000 1500 2000
−
0.
4
−
0.
2
0.
0
0.
2
0.
4
Observe that, for the erthquake data, the mean of the series appears to be stable while the volatility of phase
2 is larger than the volatility of phase 1. For the explosion data, the mean of the series also appears to be
stable; however, the volatility of data exhibits clustering. The highly volatile happens at the beginning of
phaes 1 and phase2.
part (b)
ts.plot(EQ5, EXP6, col=1:2)
legend("topleft", lty=1, col=1:2, legend=c("EQ", "EXP"))
Time
0 500 1000 1500 2000
−
0.
4
0.
0
0.
4 EQ
EXP
2
part (c)
• Model (i)
s = c(rep(0,125), 10*exp(-((1:125))/25)*cos(2*pi*1:125/4)) # part (b)
x = ts(s + rnorm(250, 0, 1))
tsplot(x, main = "Model (i)")
Model (i)
Time
x
0 50 100 150 200 250
−
5
0
5
• Model (ii)
s = c(rep(0,125), 10*exp(-((1:125))/250)*cos(2*pi*1:125/4)) # part (b)
x = ts(s + rnorm(250, 0, 1))
tsplot(x, main="Model (ii)")
3
Model (ii)
Time
x
0 50 100 150 200 250
−
10
−
5
0
5
10
Note that The first signal bears a resemblance to the two arrival phases in the explosion. The second signal
decays more slowly and looks more like the earthquake. The periodic behavior is emulated by the cosine
function which will make one cycle every four points.
Problem 2
For a moving average process of the form
xt =
1
4(wt−1 + 2wt + wt+1)
where wt are independent with zero means and variance σ2w , determine the autocovariance and autocorre-
lation functions as a function of lag h and sketch the ACF as a function of h.
Th autocovariance function is
γx(t, t+ h) = Cov(xt, xt+h)
we will look at this covariance lag by lag, i.e.,
if h = 0
γ(t, t) = Cov(xt, xt) = V ar(xt) =
V ar(wt−1) + 4V ar(wt) + V ar(wt+1)
16 =
σ2w + 4σ2w + σ2w
16 =
3
8σ
2
w
if |h| = 1
4
γ(t, t+ 1) = Cov(xt, xt+1) = Cov(
wt−1 + 2wt + wt+1
4 ,
wt + 2wt+1 + wt+2
4 )
= Cov(wt, wt)8 +
Cov(wt+1, wt+1)
8
= σ
2
w
4
if |h| = 2
γ(t, t+ 2) = Cov(xt, xt+2) = Cov(
wt−1 + 2wt + wt+1
4 ,
wt+1 + 2wt+2 + wt+3
4 )
= Cov(wt+1, wt+1)16
= σ
2
w
16
and if |h| > 2, the subscripts of the white noises inside the covariance will not match, so the covariance will
be zero. hence putting it all together:
γ(h) = γ(t, t+ h) =
3
8σ
2
w h = 0
1
4σ
2
w |h| = 1
1
16σ
2
w |h| = 2
0 |h| > 2
to find the autocorrelation function we will use
ρ(h) = γ(h)
γ(0)
i.e.,
ρ(h) =
1 h = 0
2
3 |h| = 1
1
6 |h| = 2
0 |h| > 2
5
0.00
0.25
0.50
0.75
1.00
−4 −2 0 2 4
lag
a
cf
population
Problem 3
For (Xt : t ∈ Z), where Xt = µ+ wt − .75wt−2, {wt} ∼ IIDN(0, σ2),
The mean function is:
µt = E[µ+ wt − .75wt−2] = µ.
Note that:
Cov(Xt, Xt) = Cov(µ+ wt − .75wt−2, µ+ wt − .75wt−2)
= Cov(wt − .75wt−2, wt − .75wt−2)
= V ar(wt) + 0.752V ar(Wt−2)
= (1 + 0.5625)σ2 = 1.5625σ2.
and
Cov(Xt+1, Xt) = Cov(µ+ wt+1 − .75wt−1, µ+ wt − .75wt−2)
= Cov(wt+1 − .75wt−1, wt − .75wt−2)
= Cov(wt+1, wt)− .75Cov(wt+1, wt−2)− .75Cov(wt−1, wt) + .752Cov(wt−1, wt−2)
= 0.
and
6
Cov(Xt+2, Xt) = Cov(µ+ wt+2 − .75wt, µ+ wt − .75wt−2)
= Cov(wt+2 − .75wt, wt − .75wt−2)
= Cov(wt+2, wt)− .75Cov(wt+2, wt−2)− .75Cov(wt, wt) + .752Cov(wt, wt−2)
= −0.75σ2.
and
Cov(Xt+3, Xt) = Cov(µ+ wt+3 − .75wt+1, µ+ wt − .75wt−2)
= Cov(wt+3 − .75wt+1, wt − .75wt−2)
= 0.
7
学霸联盟