Dear all,
when I try to calculate IRFs by hand my calculations differ from the calculations made by Eviews. Is that due to Eviews or me?
So I have a VAR(1) and want to trace a S.D. shock through the system. I use Cholesky decomposition on the variance covariance matrix which gives me my P matrix which is lower triangular. I multiply the MA-coefficient matrix Φ_i with P (we know Φ_i = A^i ....so A containing the coefficients). For period 1 I get the same as Eviews, for period 2 also but for period 3 I get different results. Here are my calculations:
Any ideas on how to get the same results as Eviews (I use Eviews 9.5)
Many thanks!!!
Calculating IRFs by hand differ from Eviews
Moderators: EViews Gareth, EViews Moderator
-
EViews Matt
- EViews Developer
- Posts: 583
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Calculating IRFs by hand differ from Eviews
Hello,
Using your definitions for matrices A and P, my calculations match that of EViews. It's not apparent to me how you arrived at your value for Φ_2.
Using your definitions for matrices A and P, my calculations match that of EViews. It's not apparent to me how you arrived at your value for Φ_2.
Re: Calculating IRFs by hand differ from Eviews
Opps your right, I must have had a typo somewhere! Thank you!
One follow up question: When I dont have a Var(1) but a Var(p), how would I calculate the IRFs then? I tried to calculate the IRFs for a Var(2) but couldn't get the IRFs again for period 3. I calulated Θ_2 = Φ_2*P where Φ_2 = A^2, so Θ_2=((A_t-1)^2)*P + ((A_t-2)^2)*P. Is that the wrong way to calculate the Φ_2 matrix?
note: Θ is my matrix containing the IRFs and remember that A^i = Φ_i where A contains the estimated coefficients from my reduced form VAR-model.
One follow up question: When I dont have a Var(1) but a Var(p), how would I calculate the IRFs then? I tried to calculate the IRFs for a Var(2) but couldn't get the IRFs again for period 3. I calulated Θ_2 = Φ_2*P where Φ_2 = A^2, so Θ_2=((A_t-1)^2)*P + ((A_t-2)^2)*P. Is that the wrong way to calculate the Φ_2 matrix?
note: Θ is my matrix containing the IRFs and remember that A^i = Φ_i where A contains the estimated coefficients from my reduced form VAR-model.
-
EViews Matt
- EViews Developer
- Posts: 583
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Calculating IRFs by hand differ from Eviews
Hello,
VARs in additional lags are a little trickier, but let me describe one way to calculate such IRFs by hand. If you're really interested in the subject, you may want to pick up a good econometric text for full details. First, I assume you initially had a VAR(1) of the form:
y_t = A * y_(t-1) + P * u_t
including the Cholesky decomposition P, so u_t is the vector of shocks at time t. Define the impulse response function at horizon h as the following partial derivative:
IRF(h) = d(y_(t+h)) / d(u_t)
where d() is the partial derivative, not the difference function as in EViews. Now, you already worked through calculating IRF(0), IRF(1), and IRF(2) for the VAR(1), but I'll go through that process again analytically instead of numerically.
IRF(0) = d(y_t) / d(u_t) = d(A * y_(t-1) + P * u_t) / d(u_t) = d(P * u_t) / d(u_t) = P * d(u_t) / d(u_t) = P
IRF(1) = d(y_(t+1)) / d(u_t) = d(A * y_t + P * u_(t+1)) / d(u_t) = d(A * y_t) / d(u_t) = A * d(y_t) / d(u_t) = A * IRF(0) = A * P
IRF(2) = d(y_(t+2)) / d(u_t) = d(A * y_(t+1) + P * u_(t+2)) / d(u_t) = d(A * y_(t+1)) / d(u_t) = A * d(y_(t+1)) / d(u_t) = A * IRF(1) = A^2 * P
To summarize:
IRF(0) = P
IRF(1) = A * IRF(0) = A * P
IRF(2) = A * IRF(1) = A^2 * P
This has a lovely little recurrence relation:
IRF(0) = P
IRF(h) = A * IRF(h-1) for h >= 1
which has a simple closed form:
IRF(h) = A^h * P for h >= 0
You can easily look up the above closed form, but the recurrence relation form is just as useful for numerically carrying out the calculations. We can go through a similar derivation for the IRF of a VAR(2). First, the form for a VAR(2) would be:
y_t = A_1 * y_(t-1) + A_2 * y_(t-2) + P * u_t
Next, the IRF for the first few horizons. I'll only go so far as to show the steps for constructing the recurrence relation.
IRF(0) = d(y_t) / d(u_t) = d(A_1 * y_(t-1) + A_2 * y_(t-2) + P * u_t) / d(u_t) = P * d(u_t) / d(u_t) = P
IRF(1) = d(y_(t+1)) / d(u_t) = d(A_1 * y_t + A_2 * y_(t-1) + P * u_(t+1)) / d(u_t) = d(A_1 * y_t) / d(u_t) = A_1 * d(y_t) / d(u_t) = A_1 * IRF(0)
IRF(2) = d(y_(t+2)) / d(u_t) = d(A_1 * y_(t+1) + A_2 * y_t + P * u_(t+2)) / d(u_t) = A_1 * d(y_(t+1)) / d(u_t) + A_2 * d(y_t) / d(u_t) = A_1 * IRF(1) + A_2 * IRF(0)
IRF(3) = d(y_(t+3)) / d(u_t) = d(A_1 * y_(t+2) + A_2 * y_(t+1) + P * u_(t+3)) / d(u_t) = A_1 * d(y_(t+2)) / d(u_t) + A_2 * d(y_(t+1)) / d(u_t) = A_1 * IRF(2) + A_2 * IRF(1)
To summarize:
IRF(0) = P
IRF(1) = A_1 * IRF(0)
IRF(2) = A_1 * IRF(1) + A_2 * IRF(0)
IRF(3) = A_1 * IRF(2) + A_2 * IRF(1)
The recurrence relation is:
IRF(0) = P
IRF(1) = A_1 * P
IRF(h) = A_1 * IRF(h-1) + A_2 * IRF(h-2) for h >= 2
From here, I hope you can see how this would generalize to the recurrence relation for the IRF of a VAR(p).
VARs in additional lags are a little trickier, but let me describe one way to calculate such IRFs by hand. If you're really interested in the subject, you may want to pick up a good econometric text for full details. First, I assume you initially had a VAR(1) of the form:
y_t = A * y_(t-1) + P * u_t
including the Cholesky decomposition P, so u_t is the vector of shocks at time t. Define the impulse response function at horizon h as the following partial derivative:
IRF(h) = d(y_(t+h)) / d(u_t)
where d() is the partial derivative, not the difference function as in EViews. Now, you already worked through calculating IRF(0), IRF(1), and IRF(2) for the VAR(1), but I'll go through that process again analytically instead of numerically.
IRF(0) = d(y_t) / d(u_t) = d(A * y_(t-1) + P * u_t) / d(u_t) = d(P * u_t) / d(u_t) = P * d(u_t) / d(u_t) = P
IRF(1) = d(y_(t+1)) / d(u_t) = d(A * y_t + P * u_(t+1)) / d(u_t) = d(A * y_t) / d(u_t) = A * d(y_t) / d(u_t) = A * IRF(0) = A * P
IRF(2) = d(y_(t+2)) / d(u_t) = d(A * y_(t+1) + P * u_(t+2)) / d(u_t) = d(A * y_(t+1)) / d(u_t) = A * d(y_(t+1)) / d(u_t) = A * IRF(1) = A^2 * P
To summarize:
IRF(0) = P
IRF(1) = A * IRF(0) = A * P
IRF(2) = A * IRF(1) = A^2 * P
This has a lovely little recurrence relation:
IRF(0) = P
IRF(h) = A * IRF(h-1) for h >= 1
which has a simple closed form:
IRF(h) = A^h * P for h >= 0
You can easily look up the above closed form, but the recurrence relation form is just as useful for numerically carrying out the calculations. We can go through a similar derivation for the IRF of a VAR(2). First, the form for a VAR(2) would be:
y_t = A_1 * y_(t-1) + A_2 * y_(t-2) + P * u_t
Next, the IRF for the first few horizons. I'll only go so far as to show the steps for constructing the recurrence relation.
IRF(0) = d(y_t) / d(u_t) = d(A_1 * y_(t-1) + A_2 * y_(t-2) + P * u_t) / d(u_t) = P * d(u_t) / d(u_t) = P
IRF(1) = d(y_(t+1)) / d(u_t) = d(A_1 * y_t + A_2 * y_(t-1) + P * u_(t+1)) / d(u_t) = d(A_1 * y_t) / d(u_t) = A_1 * d(y_t) / d(u_t) = A_1 * IRF(0)
IRF(2) = d(y_(t+2)) / d(u_t) = d(A_1 * y_(t+1) + A_2 * y_t + P * u_(t+2)) / d(u_t) = A_1 * d(y_(t+1)) / d(u_t) + A_2 * d(y_t) / d(u_t) = A_1 * IRF(1) + A_2 * IRF(0)
IRF(3) = d(y_(t+3)) / d(u_t) = d(A_1 * y_(t+2) + A_2 * y_(t+1) + P * u_(t+3)) / d(u_t) = A_1 * d(y_(t+2)) / d(u_t) + A_2 * d(y_(t+1)) / d(u_t) = A_1 * IRF(2) + A_2 * IRF(1)
To summarize:
IRF(0) = P
IRF(1) = A_1 * IRF(0)
IRF(2) = A_1 * IRF(1) + A_2 * IRF(0)
IRF(3) = A_1 * IRF(2) + A_2 * IRF(1)
The recurrence relation is:
IRF(0) = P
IRF(1) = A_1 * P
IRF(h) = A_1 * IRF(h-1) + A_2 * IRF(h-2) for h >= 2
From here, I hope you can see how this would generalize to the recurrence relation for the IRF of a VAR(p).
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Calculating IRFs by hand differ from Eviews
One suggestion. For higher order lags, it's often easier to write the VAR in companion form so that it's a VAR(1) and then proceed accordingly.
Re: Calculating IRFs by hand differ from Eviews
Wow, thanks for the answer Matt, really helped a lot!
Who is online
Users browsing this forum: No registered users and 2 guests
