I am trying to fit my own GARCH(1,1) model using python. I have read numerous papers at this point looking for the log likelihood function of the parameters that I need to optimize. To further confuse matters, each different thing I read comes up with a slightly different variation.

This paper discusses a little bit on the nature of the parameters. Namely, they are normally distributed.

The most clear explanation of this fit comes from Volatility Trading by Euan Sinclair. Given the equation for a GARCH(1,1) model:

$\sigma_t^2 = \omega + \alpha r_{t-1}^2 + \beta\sigma_{t-1}^2$

Where $r_t$ is the t-th log return and $\sigma_t$ is the t-th volatility estimate in the past. Given this, the author hand-waves the log-likelihood function:

$\sum \limits_{i=1}^t [-ln(\sigma_t^2) - \frac{r_t^2}{2\sigma^2_i}]$

However, unfortunately he doesnt indicate how this needs to be used, nor how it is derived. I understand using MLE $\gamma, \alpha, \beta$ need to be deduced. Somehow I will need to use the derivatives of this function to get the results.

Is there an explanation that can lead me to being able to implement this myself? Everything I've seen so far falls woefully short of explaining the entire process, and every paper and book I read derives a different LL equation.

  • 1
    $\begingroup$ I have already answered this fully in the Quantitative Finance (QF) forum of SE. See quant.stackexchange.com/questions/9351/… $\endgroup$
    – user32398
    Sep 19, 2018 at 23:35
  • 1
    $\begingroup$ In your question the author of the question notices the same thing. Why are there so many different formulas? Which one do I choose and why? $\endgroup$
    – CL40
    Sep 20, 2018 at 1:32
  • 1
    $\begingroup$ Additionally, this question is for AR(1)-GARCH(1,1). What is the difference between this and GARCH(1,1)? $\endgroup$
    – CL40
    Sep 20, 2018 at 1:38
  • 1
    $\begingroup$ I guess a third question for you while im asking them - you didn't specify an optimization. I have seen people use "Solver" in excel, which is a linear programming solver. I have also seen gradient descent used. Is there a reason to prefer one over the other for this problem? $\endgroup$
    – CL40
    Sep 20, 2018 at 2:59
  • 1
    $\begingroup$ You would need to look at those original papers to learn about the difference between AR(1)/GARCH(1,1) and GARCH(1,1). Use the formula in the SOLUTION for maximizing the likelihood, if you want to follow the same solution. You have to understand that the "quants" visiting the QF forum, when learning that function maximization is required, would merely, go "okay -- I'll use my favorite maximizer." $\endgroup$
    – user32398
    Sep 21, 2018 at 22:58

1 Answer 1


I explain how to get the log-likelihood function for the GARCH(1,1) model in the answer to this question.

The GARCH model is specified in a particular way, but notation may differ between papers and applications. The log-likelihood may differ due to constants being omitted (they are irrelevant when maximizing).

The MLE is typically found using a numerical optimization routine.

A quick implementation example in python:

  1. define relevant packages:

enter image description here

  1. define algorithm

enter image description here

  1. check if output is reasonable

enter image description here

  • $\begingroup$ Hi Johan, hope you are doing well, I used your code to estimate the parameters of the standard GARCH(1,1) but the estimated coefficients that your code produces are entirely different from the estimations of rugarch, garch and fGarch packages in R. Is there a reason for that as I'm trying to estimate GARCH(1,1) from "scratch" myself. Thanks in advance. $\endgroup$
    – Blg Khalil
    Apr 18, 2020 at 21:29
  • $\begingroup$ I have compared the results with the ARCH packages from python. Two things that may explain differences: 1) The above estimation does not include a constant in the return equation 2) The initialization of $\sigma_0^2$ may differ from the packages. $\endgroup$ Apr 21, 2020 at 7:38
  • $\begingroup$ With the two possible explanations, has anyone figured out how the code above can be made equal to the estimations made by rugarch, garch, and fGarch? Where exactly are the discrepancies in the code occurring, and which of these implementations is most correct? $\endgroup$
    – develarist
    Dec 11, 2020 at 18:10
  • $\begingroup$ @develarist you could consult the source code of the given packages and compare the code with the python code given above $\endgroup$ Dec 12, 2021 at 17:33

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.