2

I have a problem with a GARCH model in python. My code looks as follow

import sys
import numpy as np
import pandas as pd
from arch import arch_model

sys.setrecursionlimit(1800)

spotmarket = pd.read_excel("./data/external/Spotmarket.xlsx", index=True)

l = spotmarket['Price'].pct_change().dropna()

returns = 100 * l
returns.plot()
plt.show()

model=arch_model(returns, vol='Garch', p=1, o=0, q=1, dist='Normal')
results=model.fit()
print(results.summary())

The first part of the code works well. I have end of the day prices in a separate excel table and want to model them with a GARCH model. The problem is, that I get the error message The optimizer returned code 9. The message is: Iteration limit exceeded See scipy.optimize.fmin_slsqp for code meaning. Has someone an idea, how I can handle the problem with the iteration limit? Thank you!

Pyrmon55
  • 183
  • 1
  • 3
  • 14

1 Answers1

0

Reading the source code (here), you can pass additional parameters to the fit method. Internally, scipy.optimize.minimize (doc) is called and the parameters of interest to you are probably maxiter and ftol which are part of options dictionary passed to fit. Try manually changing the default values (max_iter=100 and ftol= 1e-06) to new ones that might lead to convergence. Example:

results=model.fit(options={'maxiter': 200})
Supreet Sethi
  • 1,780
  • 14
  • 24
Jan K
  • 4,040
  • 1
  • 15
  • 16
  • 1
    Thank you @Jan! But it doesn't work...I've tried my model with less data and then it works. I don't understand why this happened, because when I use data from yahoo finance, which is much more than my data, it worked too. – Pyrmon55 Jun 03 '18 at 11:11