I am trying to fit a custom GARCH model by QMLE in R. I have written out the log likelihood function and am now working on optimizing it. However, choosing an optimization algorithm has proven to be difficult. I have tried the optimizers in the optim package, but they seem unstable for this purpose. I have also tried to use the Rsolnp package, which is the default in rugarch, but since I would like to include an expression for the gradient in the function call, this is also unviable. Does anybody know which package I should look into? I need:

  1. Ability to provide upper and lower bounds for the parameters.
  2. Ability to provide a gradient function.

I recently came across a question on here where the asker tried to use the function fmincon from the package pracma. Perhaps somebody knows if this could be advisable?


1 Answer 1


One huge problem with GARCH models is that sometimes extremely changes in parameter values can lead to absurdities such as conditional variance paths exploding or plummeting below zero.

One way to quickly solve that problem is to force the conditional variance process to be bound within an interval. When you filter out the conditional variance process, you can add one line of code:

h[t+1] = max( hmin, min(h[t+1], hmax) )

This line will force your conditional variance to stay within that range at all times. You can then add a line of code to have some kind of flag that will warn you if this happened. If you are working with stock market indexes, for example, you could guess that annualized volatility will not fall below 1% and will not rise above 500%. It would be surprising to see a high likelihood associated with these extremes. Obviously, for other data, other values would be warranted, but having the option could help smooth a bit the optimization process.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.