Declare: Time Series• Define and format: time variable – datevar_name,”dmy” or – Quarterlyvar_name, “yq” – format: format var_name %d • Declare database as time series – Menu: statistics
Trang 1Introduction to VARs and Structural VARs:
Estimation & Tests Using Stata
Bar-Ilan University 26/5/2009
Avichai Snir
Trang 2Background: VAR
• Background:
• Structural simultaneous equations
– Lack of Fit with the data
Trang 3Simple VAR: Sims (1980)
• Symmetric
– Lags of the dependent variables
– Same Number of Lags
t t
t t
t t
t t
t t
t t
t t
t t
t t
t t
t t
t t
y y
y y
y y
y
y y
y y
y y
y
y y
y y
y y
y
, 3 2
, 3 3 2
, 2 2 2
, 1 4 1
, 3 3 1
, 2 2 1
, 1 1 0
,
31
, 2 2
, 3 3 2
, 2 2 2
, 1 4 1
, 3 3 1
, 2 2 1
, 1 1 0
,
2
, 1 2
, 3 3 2
, 2 2 2
, 1 4 1
, 3 3 1
, 2 2 1
, 1 1 0
γ γ
γ γ
γ γ
ε β
β β
β β
β β
ε α
α α
α α
α α
+ + +
+ +
+ +
+
=
+ + +
+ +
+ +
+
=
+ + +
+ +
+ +
t if
Trang 4Simple VAR: Matrix Form
• In Matrix Form:
• is a vector of the Dependent Variables
• is a Matrix of Coefficients
• is a Matrix in Lagged Variables
• is a Vector of White Noise Errors
• is a Matrix of exogenous variables (constant,…)
( )
t t
t t
y I
y y
y
ε
ε α
+ Α
= Γ
−
+ +
Γ + Γ
+
L
Simply or
1 1
Trang 50
0 0
0
0
0 0
: :
: :
0 0
0 0
0
0
0 0
0 0
: :
: :
0 0
0 0
0 0
0
0
0 0
0
0
0 0
: : :
3 , 3 2
, 3 1
, 3
3 , 3 2
, 3 1
,
3
3 , 2 1
, 2
3 , 2 2
, 2 1
, 2
2 , 2 1
,
2
1 , 1
3 , 1 2
, 1 1
, 1
3 , 1 2
, 1 1
,
1
3 , 3 2 , 3 1 , 3 3
, 2 2
, 2 1 , 2 3
, 1 2 , 1 1 , 1
1 , 1
2 , 3
1 , 3
1 , 2
2 , 2
1 , 2
3 , 1
2 , 1
1 , 1
σ σ
σ
σ σ
σ
σ σ
σ σ
σ
σ σ
σ
σ σ
σ
σ σ
σ
ε ε
ε ε
ε ε
ε ε
ε
ε ε ε
ε ε ε
ε ε ε
'
ε
ε t t
Covariance Matrix
Trang 6Contemporary Variance Matrix
3 , 3 2
, 3 1
, 3
3 , 2 2
, 2 1
, 2
3 , 1 2
, 1 1
, 1
σ σ
σ
σ σ
σ
σ σ
σ
Trang 7Issues Before Estimation
Trang 8Testing Stationarity
• We have data on Canada 1966Q1-2002Q1
– GDP
– Consumer Price Index (CPI)
– Household Consumption (consumption)
1966Q3
65.47 18.41
38.46
1966Q2
64.58 18.24
37.47
1966Q1
62.53 18.04
36.91
Descriptor GDP
CPI Consumption
Trang 9Declare: Time Series
• Define and format: time variable
– date(var_name,”dmy”) or
– Quarterly(var_name, “yq”)
– format: format var_name %d
• Declare database as time series
– Menu: statistics time series setup & utilities declare dataset to be time series data
Trang 10Declaring Time series
Trang 11Declare Time Series
Trang 12• Convenience
• Differences are in percentage
Trang 13• Menu: Graphics easy graphs line graph
• Follow the wizard…
Trang 17• Data don’t look stationary
• Formal test required
• Common tests (Greene, 636-646):
Trang 18• Choose a test and follow the menu
– Augmented Dickey Fuller
– DF-GLS for a Unit root
– Phillips-Peron unit root
Trang 19Choosing a test
Trang 20Running a Test
• Augmented Dickey-Fuller Test
– 6 lags
– Including Trend
Trang 21• Cannot reject the null at 5%
Trang 22Create First Differences
• Cannot Reject Unit root: Data is I(1)
Trang 23Check the new graphs
Trang 26Is it stationary now? (PP test)
The differenced data seems to be stationary
Trang 27– Test if the restricted model is significantly
outperformed by the non restricted model
),
|(
),
, ,,
|( yt yt−1 yt−2 xt −1 xt−2 = E yt yt−1 yt−2
E
Trang 28Granger Test
• Run simple VAR between the variables of interest
• Choose
– Variables
– Lag Length
Trang 29Granger Test: Running VAR
Trang 30Testing in Stata
Granger causality test
Trang 31Granger Test
• Choose variables
Trang 32Granger Test: Results
• We can reject that Inflation Granger Cause
Household Consumption
• We cannot reject that Household Consumption Granger Cause Inflation
Trang 33Optimal Lag Length
• Sometimes, we have theory to guide us
• Often, we do not
– Likelihood Ratio Test (LR)
– Akaike Information Criterion
– Bayesian (Schwartz) Information Criterion
•
Trang 34Likelihood Ratio (LR) test
General to simple approach: Run VAR with p lags Use the LR test If the test rejects the null, then stop Otherwise run p-1 lags and compare with p-2…
equations of
Number M
matrix ariance
ed unrestrict
W
matrix ariance
restricted W
M W
W T
unres
res
unresres
ln
λ
Trang 35Information Criteria
• Two information Criteria: Akaike (AIC) and Bayesian (BIC) Find the information criteria for lag length 1 to p Choose the lag length that minimizes the information criteria that you chose
,,
2)
(
,
,,
cov
)()
(
|)ln(|
2
BICfor
TAICfor
T
IC
equationsof
numberM
nsobservatioof
number
T
lagsof
numberp
Matrixariance
The
W
T
TICM
pMW
=
λ
Trang 36Tests in Stata
Lag-Order Selection statistics
Trang 37Running test
• Choose Variables
• Choose maximum lags
Trang 38Lag Length: Results
We go with the LR and AIC and say 6
(why not?)
Trang 39Run Simple VAR
• We run a simple VAR (not structural, no assumptions on order of variables)
between Household Consumption,
Inflation and GDP
• To do so:
series Basic Vector
Autoregression Model
Trang 40Simple VAR
• Choose
– Variables
– Lag Length
• Choose how to plot the response functions:
– Irf (simply uses the covariance matrix, minimum order)
– Orf (orthogonalized the Covariance matrix to set order)
– FEVD: Variance Decomposition Tables (In a
graph form)
Trang 41Simple VAR
Trang 42Results: Table of Coefficients
Trang 43Impulse Response Function
v arbas ic , dc ons , dc ons v arbas ic , dc ons , inf lat ion v arbas ic , dc ons , y
v arbas ic , inf lat ion, dc ons v arbas ic , inf lat ion, inf lat ion v arbas ic , inf lat ion, y
v arbas ic , y , dc ons v arbas ic , y , inf lat ion v arbas ic , y , y
95% CI orthogonali zed irf
s tep
Graphs by irf name, impuls e v ariable, and res pons e v ariable
Trang 44Simple VAR: Variance Decomposition Table
Trang 45Generating After Estimation
• generate after estimation:
Trang 46To get the results
• If you want to use some of the results:
• Coefficients
• Number of observations
• Etc…
– Stata keeps them under the ereturn command
– To get them type e(variable_name)
– To see all the variables that you can choose from:
• ereturn list
Trang 47Examples
Trang 48More than simple VAR
• More than a simple VAR:
– Adding Exogenous Variables
– Constraining blocks of variables to equal zero
• Use Menu: Statistics multivariate
time series Vector Autoregression Model
• Generating Impulse Responses:
IRF & Variance Decomposition Analysis
Trang 49More than simple VAR
• Adding constraints on the A or B matrix
– A: y Matrix, B: errors matrix
– Short and long run constraints
• skip lags
Structural Autoregression Model
• Stata runs the VAR with the restrictions
• Caveat 1: Too many constraints can lead to failures in the convergence process
• Caveat 2: You need enough constraints to
Trang 51Structural VAR: Results
Trang 52Structural VAR: Results
v arbas ic , dc ons , dc ons v arbas ic , dc ons , inf lat ion v arbas ic , dc ons , y
v arbas ic , inf lat ion, dc ons v arbas ic , inf lat ion, inf lat ion v arbas ic , inf lat ion, y
v arbas ic , y , dc ons v arbas ic , y , inf lat ion v arbas ic , y , y
95% CI orthogonali zed irf
s tep
Graphs by irf name, impuls e v ariable, and res pons e v ariable
Trang 53Structural VARs
• Structural VAR: VAR that is the result
of a structural model
• Goal: Obtaining the Structural
parameters out of the Estimated
Reduced Form
• Required: Number of Constraints
Trang 54Model: Inflation and GDP
• Assume we have a simple model of the
form:
iables random
t independen noise
White
lation
GDP y
y y
y y
t t
t t
t t
t t
t
t t
t t
var ,
,
inf
1 3
2 1
0
1 2
1 1
+ +
=
+ +
β β
β β
π
ε π
α α
α
Trang 55We can write it:
t t
t t
t
t t
t
t
y y
y
y
υ π
β β
β β
π
ε π
α α
α
+ +
+
=
−
+ +
2 0
1
1 2
1 1
0
Trang 56t t
β
α π
1 0
0
1 1
0 1
t t
π β
β
α β
π
1
1 1
1 1
1 0
0 1
0 1
1
0 1
1 0 1
Trang 57Inverting the Matrix gives
0 1
Trang 58We find:
( ) ( ) t ( ) t ( t t )
t
t t
t t
y
y
y
υ ε
β π
β α
β β
α β β
α β
π
ε π
α α
α
+ +
+ +
+ +
+
=
+ +
3 2
1 1
2 1
1 0
0 1
1 2
1 1
0
So we can write in VAR form:
t t
t t
t t
θ θ
θ π
ε π
α α
α
+ +
+
=
+ +
1 1
0
1 2
1 1
0
Trang 590 1
θ β
α β
θ β
α β
θ β
α β
= +
= +
= +
So we have three equations and four unknowns…
Trang 60Hakuna Matata
• We also have the covariance matrix:
• So we have a fourth equation:
1 ,
1
, 1
, ,
,
, ,
t
υ σ
β σ
β
σ β
σ σ
σ
σ
σ
ε ε ε
ε
ε ε ε
ε η
η η
ε
η ε ε
ε
η ε
ε
σ
Trang 61Run the VAR
• Note that because we assume that the “real”
covariance matrix has the triangular form:
• We can use the OIRF that Stata gives us (Cholesky factorization) to watch the Structural impulse
ε
ε
ε
σ σ
β
σ
, ,
1
Trang 62Run the VAR (1 lag)
Trang 63Study the Impulse Responses
Trang 64Get the coefficients
0
α2α
0
θ
Trang 65Get the Errors matrix
ε
ε
σ ,
ε ε
σ
β1 ,
Trang 66We find:
614
0 142
0 086
0 625
0
142
0 622
0 086
0 195
0
0043
0 0574
0 086
0 0005972
0
086
0 00008145
0
000007018
0 )
, cov(
2 1 2
3
1 1 1
2
0 1 0
0
, 1
β
α β θ
β
α β θ
Trang 68To test a restricted Model
• Run a non restricted model
• Test the null by using the LR test on the difference between the restricted and
unrestricted model
ns restrictio of
Number M
matrix ariance
ed unrestrict
W
matrix ariance
restricted W
M W
W T
unres
res
unres res
ln
λ