Vector Autoregressive Models
. Lochstoer
UCLA Anderson School of Management
Winter 2022
Copyright By PowCoder代写 加微信 powcoder
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
1 Vector Autoregressive Models (VARs)
2 Worked example of VAR analysis
I Out-of-sample performance
I Optional: Impulse-Response plots and Simsíorthogonalization
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Vector Autoregressive Models (VARs)
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 3 / 60
Vector Autoregressive Models
DeÖnition
A multivariate time series rt is a VAR process of order 1
rt =Φ0+Φ1rt 1+εt, εt WN(0,Σ)
whereΦ0 isN1andΦ1 isaNNmatrix.
The covariance matrix Σ is required to be positive deÖnite.
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Bivariate Case
stack two AR(1)ís on top of each other. . .
as an example, we consider the bivariate case:
r1t = φ10 + φ11r1,t 1 + φ12r2,t 1 + ε1t r2t = φ20 + φ21r1,t 1 + φ22r2,t 1 + ε2t
φ12 measures the conditional e§ect of r2,t 1 on r1t given r1,t 1 φ12 measures the linear dependence of r1,t on r2,t 1 given r1,t 1
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Writing AR(p) models as VAR(1) Consider the following univariate AR(p) model
rt = φ0 +φ1rt 1 +φ2rt 2 +…φprt p +σεt We can write this as a VAR(1) as
rt = Φ0+Φ1rt 1+Rεt
2 rt 3 2 φ0 3 2 φ1 φ2 6 rt 1 7 6 0 7 6 1 0
6 rt 2 7 = 6 0 7+6 0 1 0 … 0 76rt 3 7+607εt 64 . . 75 64 . . 75 64 . . . . . . . . . . 75 64 . . 75 64 . . 75
rt p+1 0 0 0 … 1 0 rt p We can now analyze the AR(p) as a VAR(1), which is simple.
εt WN(0,1)
φ3 … φp 32 rt 1 3 2 σ 3 0 … 0 76 rt 2 7 6 0 7
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 6 / 60
MA Representation
condition for stationarity compute the mean
which implies that
E[rt] = Φ0 +Φ1E[rt 1] μ=(IN Φ1) 1Φ0
rewrite this system in deviations from the mean:
er t = Φ 1 er t 1 + ε t , er t r t μ
by backward substitution:
er t = ∑ Φ j1 ε t j
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Stationarity
the MA(∞) expression
rt =μ+∑Φj1εt j
implies we need Φj1 ! 0 as j ! ∞ to get stationarity
the N eigenvalues λ need to be less than one in modulus: jλIN Φ1j=0
for a complex number z = x + iy the modulus is deÖned as jzj = px2+y2
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
VEC and Kronecker products
The VEC operator stacks the columns of an m n matrix A and turns it into a mn 1 vector.
Consider a matrix A and the vec operator vec(A) given by a11
A = ( a11 a12 ) vec(A) = ( a21 ) a21 a22 a12
If A is an mn matrix and B is a pq matrix, then the Kronecker
product deÖned by A B is the mp nq block matrix:
a11B … a1nB AB=(. … .)
am1B … amnB
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 9 / 60
VEC and Kronecker products
Some useful properties of these operations:
vec(A + B) = vec(A) + vec(B) vec(ABC ) = (C 0 A)vec(B )
(A B) 1 = A 1 B 1 (A B)0 = A0 B0
More properties can be found in any matrix algebra book, see e.g. Abadir and Magnus (2005) (or Google it).
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 10 / 60
(Unconditional) variances
compute the unconditional variance:
E[ertert0] = Φ1E[ertert0]Φ10 +Σ, or equivalently:
Solve this equation:
I taketheëvecíofbothsides
I use the Kronecker product
vec(Γ0) = [Φ1 Φ1]vec(Γ0)+vec(Σ),
vec(Γ0) = [IN2 Φ1 Φ1] 1vec(Σ), . Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Γ 0 = Φ 1 Γ 0 Φ 10 + Σ ,
vec(Γ0) = vec(Φ1Γ0Φ10)+vec(Σ),
Autocovariances
compute the auto- covariances by taking expectations on the lhs and rhs:
E[ertert0 k] = Φ1E[ert kert0 k] which implies that:
Γk =Φ1Γk 1,k>0 where Γj is the lag j cross-covariance matrix
by repeated substitution, we obtain the following autocovariogram: Γ k = Φ k1 Γ 0 , k > 0
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 12 / 60
Forecasting
forecasting is very easy. Take the 1-step ahead conditional expectation: Et [rt+1] = (IN Φ1)μ + Φ1rt
doing this h steps ahead:
Et[rt+h] = (IN Φh1)μ+Φh1rt
Notice that if we take the limit as h ! ∞, we get lim Et[rt+h] = μ
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Autocorrelations
auto-covariances:
Γk =Φ1Γk 1,k>0 let D = diag[pΓ11 (0) . . . pΓNN (0)].
by pre-and post-multiplication with D:
ρk = D 1Φ1Γk 1D 1
= D 1 Φ1 DD 1 Γk 1 D 1 = Υρk 1, k>0
with Υ = D 1Φ1D
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Vector Autoregressive Models of order p
DeÖnition
A multivariate time series rt is a VAR process of order p
rt = Φ0 +Φ1rt 1 +…+Φprt p +εt, εt WN(0,Σ)
where Φ0 is N 1, Φ1,…,Φp are N N matrix and εt is a sequence of white noise random vectors.
The covariance matrix Σ is required to be positive deÖnite.
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 15 / 60
VAR(p) Model
condition for stationarity
compute the mean
E[rt] = Φ0 +Φ1E[rt 1]+…+ΦpE[rt p]
which (under stationarity) implies that:
(IN Φ1 . . . Φp ) μ = Φ0
and we can back out the mean provided that the inverse exists the autocovariances satisfy:
Γk =Φ1Γk 1+…+ΦpΓk p, k>0 . Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Vector Autoregressive Models of order 4
DeÖnition
A multivariate time series rt is a VAR process of order p = 4 if
rt =Φ0+Φ1rt 1+…+Φ4rt 4+εt, εt WN(0,Σ)
where Φ0 is a N-dimensional vector, Φ1, . . . , Φ4 are N N matrices. The variance covariance matrix is required to be positive deÖnite.
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 17 / 60
Vector Autoregressive Models of order 4
we can represent this VAR(4) as a VAR(1):
26 r t + 1 37 26 Φ 0 37 26 Φ 1 Φ 2 Φ 3 Φ 4 37 26 r t 37 26 I N 37
6 rt 7 = 6 0 7+6 IN 0 0 0 76 rt 1 7+6 0 7εt+1 4 rt 1 5 4 0 5 4 0 IN 0 0 54 rt 2 5 4 0 5
rt 2 000IN0rt 30 much easier to handle!
this is related to linear, state space models (get to this at end of class)
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 18 / 60
Estimation
in this system
rt =Φ0+Φ1rt 1+εt
each equation can be estimated separately using OLS
I errors are serially uncorrelated with constant variances
I right hand side variables are predetermined (not exogenous)
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
SpeciÖcation Test
the lag length p is an important part of VAR(p) modeling we can use the AIC to choose the lag length
the AIC of a VAR(p) model is:
AIC(i) = ln(jΣpj)+ 2N2p T
whereΣp= 1 ∑T εtεt0 T 1 t=p+1
the lag length p should be chosen to minimize the AIC run a multi-variate Q-test on residuals
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
VARs: A worked example Impulse-Responses and Sims shock orthogonalization
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 21 / 60
We will Öt a higher order VAR to the following quarterly data:
1 Excess stock market returns (CRSP)
2 The market Price-Dividend ratio (CRSP)
I Market value divided by sum of last 12 months of dividends (to avoid seasonalities)
3 Real, per capita quarterly log GDP growth The sample is 1957Q1 through 2015Q4.
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 22 / 60
Step 1: Plot the data
Always, if you can, plot the data you are using. I non-stationarities, outliers, data-errors, etc.?
Note that the DP ratio is very persistent. Otherwise, returns and gdp growth both are pretty clearly stationary. No obvious data-errors.
0.5 0 -0.5
1950 1960 0.06
0.04 0.02 0
1950 1960 0.05
Excess Market Returns
1970 1980 1990
Market D/P-ratio
2000 2010 2020
1970 1980 1990
Log GDP growth
2000 2010 2020
1970 1980 1990
2000 2010 2020
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
MatLab code for previous slide
load VAR_data
subplot(3,1,1) plot(date,ExcessMktRet) title(íExcess Market Returnsí)
subplot(3,1,2) plot(date,DP) title(íMarket D/P-ratioí)
subplot(3,1,3) plot(date,D_gdp) title(íLog GDP growthí)
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Model speciÖcation
We are interested in understanding how the equity risk premium varies with business conditions (GDP growth) and how GDP growth links to valuation ratios and stock returns
The choice of the number of lags in the VAR is a tricky one.
1 Use as few lags as you can while still capturing the main e§ects in the data (AIC, BIC). VAR(1) is a good start.
2 Overall, model speciÖcation choice is a bit of an art
Having looked a bit at the return forecasting equation, and to illustrate some of
the topics from Lecture 5, I have chosen a restricted VAR(2) See next slide for speciÖcation
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 25 / 60
Model speciÖcation
Here are the forecasting equations I want embedded in the VAR:
Re = φ(1)+φ Re+φ DP +φ ∆gdp +φ ∆gdp +σ ε ,
t+1 011t12t13t14t 1RR,t+1
DPt+1 = φ(2) +φ Rte +φ DPt +φ ∆gdpt +φ
0 21 22 23 24
∆gdpt+1 = φ(3) + φ Rte + φ DPt + φ ∆gdpt + φ
0 31 32 33 34
How do I map this into a VAR(1)?
zt+1 = φ0 + φ1zt + error
What is the zt vector? What is φ0? What is φ1?
∆gdpt 1 +σDPεDP,t+1, ∆gdpt 1 + σgdpεgdp,t+1.
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022 26 / 60
Model speciÖcation
zt = [Rte DPt ∆gdpt ∆gdpt 1]0
= hφ(1) φ(2) φ(3) 0i0 0000
26 φ11 φ12 φ13 φ14 37 φ1=64φ21 φ22 φ23 φ24 75
φ31 φ32 φ33 φ34 0010
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Model estimation
Simply estimate the parameters in each of the below using standard OLS regressions:
Re = φ(1)+φ Re+φ DP +φ ∆gdp +φ ∆gdp +σ ε , t+1 011t12t13t14t 1RR,t+1
DPt+1 = φ(2) +φ Rte +φ DPt +φ ∆gdpt +φ ∆gdpt 1 +σDPεDP,t+1, 0 21 22 23 24
∆gdpt+1 = φ(3) + φ Rte + φ DPt + φ ∆gdpt + φ ∆gdpt 1 + σgdpεgdp,t+1. 0 31 32 33 34
Save the residuals so you can estimate their variance-covariance matrix later
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 28 / 60
MatLab code for estimation
% estimate the restricted VAR(2), set it up as a VAR(1) phi0 = zeros(4,1);
phi1 = zeros(4,4);
out = LL_olsNW(ExcessMktRet(3:end),cat(2,ones(234,1),ExcessMktRet(2:end- 1),DP(2:end-1),D_gdp(2:end-1),D_gdp(1:end-2)),0);
phi0(1) = out.beta(1);
phi1(1,:) = out.beta(2:end)í;
eps1 = out.res;
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 29 / 60
MatLab code for estimation
out = LL_olsNW(DP(3:end),cat(2,ones(234,1),ExcessMktRet(2:end- 1),DP(2:end-1),D_gdp(2:end-1),D_gdp(1:end-2)),0);
phi0(2) = out.beta(1);
phi1(2,:) = out.beta(2:end)í;
eps2 = out.res;
out = LL_olsNW(D_gdp(3:end),cat(2,ones(234,1),ExcessMktRet(2:end- 1),DP(2:end-1),D_gdp(2:end-1),D_gdp(1:end-2)),0);
phi0(3) = out.beta(1);
phi1(3,:) = out.beta(2:end)í;
eps3 = out.res;
% add element that corresponds to second lag of GDP phi1(4,3) = 1;
display(phi0);
display(phi1);
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
MatLab code for estimation
In general, you may want to display R2 values and t-statís, but we are keeping it simple here:
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 31 / 60
Check for stationarity
How? Recall that all we need when we have a VAR(1) is that the Eigenvalues are less than one in modulus:
% check that the system is stationary
eigenvalues = eig(phi1);
modulus = sqrt(real(eigenvalues).^2 + imag(eigenvalues).^2)
modulus = 0.3230 0.3506 0.3506 0.9590
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Demean system for easy manipulation
Recall that the unconditional mean of a VAR(1) is: μ=(IN φ1) 1φ0
So the MatLab code is:
% Calculate unconditional mean vector: mu = (eye(4) – phi1)nphi0;
% demean all variables for simplicity
z_t = cat(2,ExcessMktRet(2:end),DP(2:end),D_gdp(2:end),D_gdp(1:end-1)) – kron(ones(length(DP)-1,1),muí);
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 33 / 60
Expected value plot: 1 quarter ahead
The VAR gives you the expected value at any future date: Et [z ̃t +k ] = φk1 zt
% plot the expected returns and the expected GDP growth series % one-period (a quarter) ahead expectations
Et1 = (phi1 * z_tí)í+ kron(ones(length(DP)-1,1),muí);
plot(date(2:end),Et1(:,1),írí) hold on plot(date(2:end),Et1(:,3),íbí) xlabel(íYearí)
title(íExpected quarterly excess return and gdp growth: one-quarter aheadí);
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 34 / 60
Expected value plot: 1 quarter ahead
Notice that the 1-period ahead forecast is quite volatile
GDP is in blue (less volatile), return is in red (more volatile)
Note the negative correlation between expected GDP growth and expected returns: The risk premium appears to be counter-cyclical!
Expected quarterly excess return and gdp growth: one-quarter ahead
0.08 0.07 0.06 0.05 0.04 0.03 0.02 0.01
0 -0.01 -0.02
1990 2000 2010 2020
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Expected value plot: 4 quarters ahead
% one year (4 quarters) ahead expectations
Et4 = (phi1^4 * z_tí)í+ kron(ones(length(DP)-1,1),muí); plot(date(2:end),Et4(:,1),írí)
plot(date(2:end),Et4(:,3),íbí)
xlabel(íYearí)
title(íExpected quarterly excess return and gdp growth: four quarters aheadí);
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 36 / 60
Expected value plot: 4 quarters ahead
Notice that the 4-period ahead forecast is less volatile
GDP is in blue (less volatile), return is in red (more volatile)
Expected returns still vary a great deal, due to e§ect of persistent PD-ratio
I Almost no forecasting power for GDP 4 quartes out… Expected quarterly excess return and gdp growth: four quarters ahead
1990 2000 2010 2020
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Expected value plot: 20 quarters ahead
% 5 years (20 quarters) ahead expectations
Et20 = (phi1^20 * z_tí)í+ kron(ones(length(DP)-1,1),muí); plot(date(2:end),Et20(:,1),írí)
plot(date(2:end),Et20(:,3),íbí)
xlabel(íYearí)
title(íExpected quarterly excess return and gdp growth: twenty quarters aheadí);
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 38 / 60
Expected value plot: 20 quarters ahead
Notice that the 20-period ahead forecast is even less volatile GDP is in blue (less volatile), return is in red (more volatile)
Expected returns still vary a great deal, again due to e§ect of highly persistent PD-ratio
I No forecasting power for GDP 20 quartes out, simply unconditional average Expected quarterly excess return and gdp growth: twenty quarters ahead
1990 2000 2010 2020
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
VARs: Out-of-sample test
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 40 / 60
Out-of-sample test
OverÖtting means we get ítoo highíR2ís in sample as we explain some of the true variation in actual residuals
Out-of-sample performance can then be bad
Related, parameters may be unstable, varying over time in reality. In such cases, the out-of-sample performance will likely su§er.
Here, present a natural out-of-sample test
Focus only on the 1-period ahead return forecasting equation
Re =φ(1)+φRe+φDP+φ∆gdp+φ∆gdp +σε
t+1 0 11t 12 t 13 t 14 t 1 RR,t+1
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 41 / 60
Out-of-sample test
1 Choose an initial training sample, for instance covering the Örst 80% of the sample. This depends on overall sample length
I Too short initial sample means the parameters are estimated with a lot of noise, which of course leads to low out-of-sample performance.
2 Using data up to an including time τ to estimate the model, get the model prediction for time τ + 1 and compare with actual outcome at time τ + 1
3 Natural metrics of Öt (expectations are averages over the out-of-sample period used (e.g, the last 20% of sample)
MSPE = E h(predicted actual )2 i
2 E h(predicted actual )2 i
Rout of sample = 1 E h(actual E [actual])2i
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 42 / 60
MatLab code for out-of-sample tests
% Örst, set an initial training sample. T = length(z_t(:,1));
train = round(T*4/5);
pred = zeros(T-train-1,1);
actual = z_t(train+1:T,1);
% do just return equation
for tt = train:T-1
out = LL_olsNW(z_t(2:tt,1),cat(2,ones(tt-1,1),z_t(1:tt-1,1), z_t(1:tt-1,2), z_t(1:tt-1,3), z_t(1:tt-1,4)),0);
pred(1+tt-train) = out.betaí* cat(2,1,z_t(tt,:))í;
MSE = mean((pred – actual).^2);
RMSE = sqrt(MSE);
R2_outofsample = 1 – MSE / mean((actual – mean(actual)).^2);
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Predicted vs Actual in out of sample period
The out of sample R2 is 1.71% for quarterly excess return forecasts The in-sample R2 for the full sample is 1.61%
While these numbers seem small, the predicted quarterly risk premium varies from about -2% to 3%!
0.2 0.15 0.1 0.05 0 -0.05 -0.1 -0.15 -0.2 -0.25 -0.3
Predicted vs actual returns in out of sample period
2004 2006 2008 2010
2012 2014 2016
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models
Winter 2022
Impulse-Response Plots (Advanced: Optional Material)
. Lochstoer UCLA Anderson School of Management () Lecture 7 Vector Autoregressive Models Winter 2022 45 / 60
Impulse-Response Plots
Recall that the MA (∞) representation of a demeaned VAR (1) is:
zt = ∑ φ1εt j,
where εt j is the, in our case, 4 1 vector of shocks at time t j:
26 σ R ε R , t j 37 εt j =64 σDPεDP,t j 75
σgdpεgdp,t j 0
Note that the last shock is always zero as it is the shock corresponding to the lagged GDP growth equation.
. Lochstoer UCLA Anderson School of Management () Lec
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com