0

I want to calculate the half-life for an higher order AR(4) model. Basically, I want to know the pace of mean reversion of Dutch GDP growth.

I have half-life python code for an AR(1) model

For your information: grw is a dataframe with index=dates and GDP Growth for the Dutch economy

# Halflife calculation
gdp_lags = np.roll(grw['Growth_yoy'],1)

gdp_lags[0] = 0

gdp_rets = grw['Growth_yoy'] - gdp_lags

gdp_rets[0] = 0

#adds intercept terms to X variable for regression
gdp_lags2 = sm.add_constant(gdp_lags)

model = sm.OLS(gdp_rets,gdp_lags2)
results = model.fit()

halflife = -np.log(2) / results.params[1]
print(halflife)

I would like to have python code for an AR(4) model.

Bill P
  • 3,622
  • 10
  • 20
  • 32
Nora
  • 3
  • 1
  • You can look at the impulse response function directly. The IRF for AR(p) is not necessarily monotonic, so half-life might not be well defined. – Josef Oct 03 '19 at 18:22

1 Answers1

0

Since you're already using statsmodels you may want to take a look at statsmodels - ARIMA, i.e.:

from statsmodels.tsa.arima_model import ARIMA

model = ARIMA(endog=grw['Growth_yoy'], order=(4, 0, 0))  # p=4, d=0, q=0 for AR(4)
fit = model.fit()
fit.summary()
  • Thanks! I would indeed have to run an AR(4) model and store the parameters. And then I have to derive the half-life. I have found the formula for the half-life higher order AR(p) model, but don't know how to model it in python – Nora Oct 03 '19 at 14:28
  • HALF-LIFE FOR HIGHER ORDER AR(P): For higher order of AR say in AR of P order: AR(P), the model is represented by: (5)   yt = sum(Fjyt-j)+ et The approximate half-life is given by: (6)   h = - log 2 / log (1 – B) … where B = convergence speed. This may be obtained from the error correcting model of AR(P): (7)   ^yt = Byt-1 + sum(F*^yt-1 + et … where B = sum(Fj – 1) and F*j = - sum(Fk). If there is only one lag, i.e. AR(1), then the convergence speed is: B = r1 – 1. – Nora Oct 03 '19 at 14:30