I am using the tsa.vector_ar in Python, StatsModel Package and when I do a Forecast Error Variance Decomposition using the command FEDV I want to provide my own sigma matrix (covariance matrix of my residuals). In other words, I want to compute a generalized impulse responses. Unlike the traditional impulse response analysis, this approach does not require orthogonalization of shocks and is invariant to the ordering of the variables in the VAR. Below is the typical example of running a VAR in Python

# some example data
>>> import pandas
>>> mdata = sm.datasets.macrodata.load_pandas().data

# prepare the dates index
>>> dates = mdata[['year', 'quarter']].astype(int).astype(str)
>>> quarterly = dates["year"] + "Q" + dates["quarter"]
>>> from statsmodels.tsa.base.datetools import dates_from_str
>>> quarterly = dates_from_str(quarterly)

>>> mdata = mdata[['realgdp','realcons','realinv']]
>>> mdata.index = pandas.DatetimeIndex(quarterly)
>>> data = np.log(mdata).diff().dropna()

# make a VAR model
>>> model = VAR(data)
>>> fevd = results.fevd(5)

>>> fevd.summary()
FEVD for realgdp
      realgdp  realcons   realinv
0    1.000000  0.000000  0.000000
1    0.864889  0.129253  0.005858
2    0.816725  0.177898  0.005378
3    0.793647  0.197590  0.008763
4    0.777279  0.208127  0.014594

How can I do the above results.fevd(nsteps) command but by providing my own factor matrix to be decomposed? I know how to compute the factor matrix but I don't know how to implement the generalized impulse response with the above commands.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.