Homework 8
Note: The due date is April 29 (Tuesday). The first part of the assignment is to ask the
basic concept of the hidden Markov models. The second part is to practice the models in
the vector autoregression (VAR) class, multivariate analogues of the AR class. Any questions
about R/RStudio, email the teaching assistant. All problems below will carry equal weight.
The homework should be submitted as one PDF file. But it could be the PDF produced from
an R-Markdown file, MS Word file, handwriting, etc., or some combination thereof. I leave it
up to you in what format you submit your homework.
Problem 1. Consider the dataset polio in the R package astsa. Do the following.
(a) Draw a time plot of the data. Based on the plot, argue how many states of Xt seem to
be required.
(b) With proper starting values for the parameters of the response models, use [Link](123)
to fit a Poisson-HMM to the data; Compute stationary distribution of the states; Check the
overdispersion of the model numerically.
(c) By referring to the counts of earthquakes example, draw three plots: A time plot of the
data and estimated states, HMM smoothing probabilities of state 1, and a histogram of the
data with the two estimated Poisson densities.
Problem 2. Consider the dataset econ5 in R package astsa containing quarterly U.S.
unemployment, GNP, consumption, and government and private investment from 1948 Q3 to
1988 Q2. We focus on three variables, unemp, gnp, and consum. Do the following.
(a) For each raw time series, take the logarithm and remove the linear trend. That is, for the
raw time series {Yt }, derive
Xi,t = log(Yi,t ) − β̂0,i − β̂1,i t, i = 1, 2, 3.
Provide a time plot of the series {Xt }; Provide their ACF and partial ACF plots. For the
rest of the problems, we use this detrended, logged time series.
(b) Carry out the pre-whitening procedure for testing independence between the series. Find
whether there is any dependence between pairs of the series.
(c) What lag order p is suggested as the smallest number? Choose the smallest suggested p
and output the summary of the corresponding fitted VAR(p) model.
(d) Plot the residuals from the fitted VAR model and their ACF and partial ACF; Also check
1
their normality.
(e) Report and comment on the Granger and instantaneous causality analyses; Argue whether
the results are consistent with the estimated VAR model.
Problem 3. Let
X1,t = Z1,t , X2,t = ϕℓ X1,t−ℓ + Z2,t ,
where {(Z1,t , Z2,t )′ } ∼ WN(0, σZ2 I). Do the following.
(a) Argue that {X2,t } is white noise.
(b) For positive integer h, what is the h-step-ahead prediction of X1,T +h given X1,1 , . . . , X1,T
for h = 1, . . . , 4? Similarly, what is the h-step ahead prediction of X2,T +h given X2,1 , . . . , X2,T
for h = 1, . . . , 4?
(c) Take ℓ = 2. Given the way the series X2,t is constructed, what is the h-step-ahead
prediction of X2,T +h given the bivariate observations X1 , . . . , XT for h = 1, . . . , 4?
(d) Take σZ2 = 1 and ϕ2 = 5. With [Link](2), generate the series Xt for t = 1, . . . , T + 4
with T = 100, assuming the white noise series consists of independent normal observations
(The code for generating this series can be found in the lecture note). Leave the last 4
observations for testing. Estimate ϕ2 by regression (Do not use VAR function); Forecast the 4
observations X2,T +h , h = 1, . . . , 4 by (i) based on X2,1 , . . . , X2,T as in (b) and (ii) based on
X1 , . . . , XT as in (c); Compare the mean squared prediction errors for the two forecasting.
Problem 4. The ACVF of a VAR(1) model Xt = Φ1 Xt−1 + Zt , {Zt } ∼ WN(0, ΣZ ), can be
written as ΓX (h) = Φh1 ΓX (0), h ≥ 0, where the covariance matrix is
ΓX (0) = ΣZ + Φ1 ΣZ Φ′1 + Φ21 ΣZ (Φ′1 )2 + . . . . (1)
One cannot calculate ΓX (0) explicitly in general. As a special case, consider symmetric Φ1
and ΣZ = σZ2 I, where σZ2 is a scalar. Then
ΓX (0) = σZ2 (I + Φ2 + Φ4 + . . .) = σZ2 (I − Φ21 )−1 . (2)
Do the following in the bivariate case, d = 2.
(a) Consider
0.5 0.1
Φ1 = .
0.1 0.6
2
Check if (1) and (2) coincide by truncating the infinite sum in (1) to suitable terms, say 50.
(b) By using (2), find an explicit expression for ΓX (0) in terms of the entries ϕ11 , ϕ12 , ϕ21 , ϕ22
of a symmetric matrix Φ1 .
(c) Generate a bivariate series of length T = 1000 following the VAR(1) model from part (a)
with σZ2 = 0.25 and assuming the {Zt } follow independent normal distribution. Compute the
sample covariance matrix of the generated series. Compare it to the model covariance matrix
from (a) or (b) [Note: You can use VAR1 sim function in the lecture note.]
(d) With the generated data in (c), perform impulse response analysis on fixed investment
for 5 steps. That is, verify that the outcome of irf is identical to the first columns of Φn1 ,
n = 1, 2, 3, 4, are identical [Note: Consult with Help pages about irf and VAR].