bashtage / arch

ARCH models in Python
Other
1.34k stars 248 forks source link

fit() without parameter vs. warm start #625

Closed KIC closed 1 year ago

KIC commented 1 year ago

I am wondering why this package is not following the sklearn API and provide the y data in the fit method but in the constructor. The reason I am wondering is whether I can re-use a previously fitted arch model for a new slice of data i.e. by using a rolling window for backtests. Re-using already fitted parameters usually provide a much better initial guess and increases performance aka warm start.

bashtage commented 1 year ago

This package uses a scipy/statsmodels/linearmodels-api like design.

bashtage commented 1 year ago

If you want a warm start, you can do something like:

from arch.data import sp500
r = 100 * sp500.load().iloc[:,-2].pct_change().dropna()
mod = arch.arch_model(r)

last = None
for i in range(5000, len(r)):
    res = mod.fit(starting_values=last, last_obs=i, disp="off")
    last = res.params