Search code examples
pythonvarstatsmodels

How to generate the actual results of an IRF() function in python?


I am unable to generate the actual underlying values of the IRFs. See code of a simple VAR model.

import numpy as np
import statsmodels.tsa as sm
model = VAR(df_differenced.astype(float))
results = model.fit()
irf = results.irf(10)

I can generate the resulting IRF plots just fine with this code:

irf.plot(orth=False)

But, I can't generate the underlying values. I'd like to do so to have precise figures. Visually interpreting IRFs is not that accurate. Using the summary() did not provide me this information.

I would really appreciate some help. Thanks in advance.


Solution

  • You need to use the irfs property or cum_effects (cumulative irf). results.irf returns an IRAnalysis object. The documentation is below the standard where it should be.

    import numpy as np
    import statsmodels.tsa as sm
    import pandas as pd
    
    df = pd.DataFrame(np.random.standard_normal((300,3)))
    model = VAR(df)
    results = model.fit()
    irf = results.irf(10)
    print(irf.irfs)
    print(irf.cum_effects)