It should be emphasized that we are not looking at how one variable (oil prices, for example) affects another variable (GDP, for example). We can easily look at the coefficients to know that. What we are looking for are how unexpected changes that directly affect oil prices affect GDP. In a sense, we are looking at shocks coming from the error term related to oil prices, and how such shocks change GDP.

Now, we're not going to discuss impulse response functions the easy way. Before we go into using STATA to compute the impulse response functions, we're going to look at the econometrics behind it. The formula for an IRF is:

Ψ

_{i}= Φ

_{i}

*B*Λ

^{-1}^{½}

where

*B*is the matrix of coefficients of all the variables at time

^{-1}*t*; Λ

^{½}is the lower Cholesky decomposition of the variance-covariance matrix of e

_{t}(both Λ and Λ

^{½}are diagonal matrices with zero non-diagonal elements); and, Φ

_{i}is another matrix that contains the effects of a one-unit increase in innovation at date

*t*(e

_{t}) on the value of the y variable at time

*t+s*:

For example, if we have two variables, (y

_{t}, x

_{t}), and we're looking at how the error terms, (e

^{y}

_{t}, e

^{x}

_{t}), affect each of the two variables, the IRF can be summarized as:

Of course, the elements of the matrix are different at each point in time, as we will see shortly.

Now, let's put numbers behind the IRF. Suppose we are analyzing a vector autoregression (VAR) system. We are interested in the following structural vector autoregression (SVAR):

where

*z*.

_{t}= (y_{t},x_{t})'But of course, if we want to estimate an SVAR, we instead estimate an observationally equivalent reduced-form vector autoregression (RFVAR) simply because they're easier to estimate:

where Σ is the variance of the error term of the RFVAR (ε).

Now, since both forms of VAR are equivalent, it should be that:

Assuming invertibility is verified (the matrix of coefficients is nonsingular--it has a determinant), we can derive the series of Φ

_{i}by looking at the MA(∞) representation of

*z*:

_{t}Finally, for the last element of the IRF (Λ

^{½}), we make use of the following formula:

then we apply a Cholesky decomposition to get Λ

^{½}. In STATA, we use the CHOLESKY function to derive the Cholesky decomposition of a matrix. For example, given that Λ is:

To derive the Cholesky decomposition in STATA, we simply use the following commands:

matrix a=(4,0\0,3.75)

matrix b=cholesky(a)

The first line is where I input the 2X2 matrix and name it

**a**, and

**b**is the resulting Cholesky decomposition.

Alternatively, we can get Λ

^{½}directly by applying another formula:

Σ

^{½}is the lower Cholesky decomposition of the variance-covariance matrix of the RFVAR error term (ε

_{t}). Applying the formula, we get:

Now, we can apply the formula to get the IRF. Suppose we want to compute the responses for

*t*= 0, 1, 2:

For example, if we want to know the responses of (

*y*) to

_{t}__one__standard deviation shock in (

*e*), we get 0 for the first period, -½(15)

^{x}_{t}^{½}for the second period, and 0 for the third period.

Now, the we have the algebra and the econometrics out of the way, let's look at implementing these in STATA. It's way more simpler than the procedure above.

Let us use the data from our previous GDP-oil price analysis. Using that data (already in first-difference log forms), we run the original

**VAR**command with 4 lags:

Before we proceed, we can check if we do need four lags by obtaining lag-order selection statistics. The STATA command

**VARSOC**shows four information criteria (I'll discuss more of this tomorrow) that shows how many lags are the most appropriate:

It seems that we only need a single lag (check the lags with the *). So, rerunning the

**VAR**with only one lag, we get:

Then as a post-estimation command, we run STATA's

**IRF**command after the VAR estimation:

The first line is needed as STATA needs an active file to where the results of the impulse response analyses are kept.

As the footnotes indicate, the first column displays the responses of GDP to one standard deviation shock in e

^{GDP}. The second column show response of oil to a shock in e

^{GDP}. For the third and fourth columns, the effects of a shock in e

^{oil}on GDP and oil, respectively, are shown. The table shows up to nine time periods (quarters in this case).

The

**NOCI**option is there to suppress reporting of the confidence interval. Of course, you can show the intervals by not including this option. Another option that might be useful for you is

**STDERROR**, which shows the standard errors.

STATA provides a very convenient tool to do impulse response analysis. The

**IRF**command can also create graphs which is useful if you prefer a visual look instead of looking at the numbers.

Could you please clarify how the IRF is interpreted? e.g. a 1% shock to GDP results in a 0.68% increase in oil? I've seen examples online (in SVAR models) where the IRF is multiplied by 100, but that seems counterintuitive when both variables are logged (and would suggest very high responses here!).

ReplyDeleteThanks.

Perfect explanation!!! Thank you very much!

ReplyDeletewhere is the reply from the author?

Deleteit depends on how you define variables when you put them into the VAS SVAR regression.

ReplyDeleteHi. This explanation looks wonderful! However, none of the images seem to work... Is there anyway you would be able to re-upload them?

ReplyDeleteWould be super helpful!

All the best and many thanks for the help

Thank you for informing me, Marziyeh. I have already fixed the problem.

ReplyDeleteHey Wayne. i tried to send you a personal message but unfortunately I could not.I was wondering if you know or have done before imposing sign restrictions on the impulse response functions in a SVAR model using STATA.I searched everywhere but not results.

DeleteHi there. I am currently using IRF's for my dissertation for Economics. I am trying to set an active file but it says there is no active file or that it cannot be opened even when I have used the irf create commands. I was wondering if you could be of any help? Thanks in advance.

ReplyDeleteI cannot see the response to the first post. Could you kindly re-post.

ReplyDeleteI wonder why the impulse response number in calculation manually is different from Stata result?

ReplyDeleteHi, I want to set the impulse to -0.25 basis points instead of the default size of the shock. Do you know how I can proceed? Thanks!

ReplyDeleteHi is there is a certian command to choose the ordering

ReplyDeleteHi is there is a certian command to choose the ordering

ReplyDelete