Introducing shocks in a VAR

Questions and discussions on Vector Autoregressions
fchang
Posts: 5
Joined: Wed Oct 23, 2024 4:31 pm

Introducing shocks in a VAR

Unread post by fchang »

Hello,

I have been trying to introduce shocks in a 6 Variable VAR with Exogenous variables to simulate the effects of interest rate decisions in GDP and CPI.I have monthly data from 1997:1 to 2024:7.

*VAR Setup

Code: Select all

system(model=canvar2)
variables rgdpagr cpiagr t0yrate n0ebill exrateagr m1ppagr
lags 1 to 3
det constant rgdpgrus cpigrus n0ebillus t0yrateus m1ppgrus popexogenousgr wtiexogenousgr
end(system)
estimate(resids=residsexo)
*Forecast until 2026:6

Code: Select all

forecast(model=canvar2,steps=24,from=2024:07,results=canvar2_fore)
At this point, I wanted to see the effect of two consecutive interest rate drops in the forecast of both CPI and GDP, one in October for 50 bps and another in December of 25 bps. I tried doing in with a loop but it didn't work.
*Introduction of shocks to simulate interest rate decisions from central banks

Code: Select all

do t = 2024:7, 2026:06
   if t == 2024:10
      compute shocks = ||0, 0, 0, -0.5, 0, 0||  ;
   elseif t == 2024:12
      compute shocks = ||0, 0, 0, -0.25, 0, 0|| ;
   else
      compute shocks = ||0, 0, 0, 0, 0, 0||     ;
   endif
   
   forecast(model=canvar2, from=t, to=t, result=canvar2shocktest, shock=shocks)
end do t
I was wondering if anyone had suggestions on how I could do something like this? I am relatively new to coding
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Introducing shocks in a VAR

Unread post by TomDoan »

Use either the MATRIX option or the PATHS option to force shocks over multiple steps. Something like

set rshocks 2024:7 2026:6 = %if(t==2024:10,-0.5,%if(t==2024:12,-.25,0))
forecast(model=canvar2, from=2024:7,to=2026:6,result=canvar2shocktest,paths)
# * * rshocks * * *
fchang
Posts: 5
Joined: Wed Oct 23, 2024 4:31 pm

Re: Introducing shocks in a VAR

Unread post by fchang »

Hi Tom,

This was really helpful, thanks a ton!

Regards,
fchang
Posts: 5
Joined: Wed Oct 23, 2024 4:31 pm

Re: Introducing shocks in a VAR

Unread post by fchang »

TomDoan wrote: Thu Oct 24, 2024 8:54 am Use either the MATRIX option or the PATHS option to force shocks over multiple steps. Something like

set rshocks 2024:7 2026:6 = %if(t==2024:10,-0.5,%if(t==2024:12,-.25,0))
forecast(model=canvar2, from=2024:7,to=2026:6,result=canvar2shocktest,paths)
# * * rshocks * * *
----------------------------
Hi Tom,

Thanks for this. I had an additional question about the order of the variables in the VAR (In my model the current order of the variables is: rgdp cpi t0yrate n0ebill exrate m1pp.

However, my transmission mechanism the order would be: Overnight rate impacts long-term rate, which impacts money, which impacts exchange rate, then gdp, and finally CPI. If this is the case, should I reorder as follows? n0ebill t0yrate m1pp exrate rgdp cpi.

Would this make sense?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Introducing shocks in a VAR

Unread post by TomDoan »

The forecasts themselves are unaffected by the order of the variables. Where the order may matter is if you want the other variables to have contemporaneous responses to your input shocks. The description above has the shocks affecting only the interest rates at the time. Things are more complicated if you want to allow the variables that are "downstream" of the shocked variable to move with it.
Post Reply