DCC-GARCH Likelihood Terms and Estimation Speed
Summary
The thread addresses implementation questions for two-step estimation of a dynamic conditional correlation GARCH model. In the second-stage likelihood, the log of the determinant of the conditional correlation matrix is a scalar, as is the quadratic form involving the inverse matrix and residual vector. If the first term appears as a matrix in Python, the answer suggests that an elementwise absolute-value operation may have been used where a determinant was intended.
For reducing estimation time, the response points to established R packages for univariate and multivariate GARCH fitting, which can be called from Python and support clustered processing. It also mentions another R package for DCC fitting. The discussion offers a diagnostic and implementation avenues, but provides no benchmark, code, or evidence about which option will be fastest for a particular dataset or setup. The likelihood expression and model assumptions should still be checked against the intended DCC specification.
Key ideas
- The determinant of the conditional correlation matrix is a scalar likelihood term.
- An elementwise absolute-value operation can produce the matrix output that confused the questioner.
- Established R GARCH packages can be accessed from Python as alternatives to custom optimization.
- The thread gives no comparative performance results for the suggested estimation approaches.
Tags
Full text
# 2-step estimation of DCC GARCH model in Python
# 2-step estimation of DCC GARCH model in Python
Embedded in this thread are multiple questions. I'm currently im the process of implementing a DCC GARCH forecast model on quantopian (a python-powered trading platform).
The two step consists of first estimating the conditional volatility over time $D_t$ (as canonicalized by Engle). I apply the traditional log-likelihood with the minimize function from scipy package. For 2nd step, it is the same except I run into a bit of ambiguity:
Consider the log-likelihood for the 2nd step $L(\phi|\hat{\theta})\propto \sum_{t=1}^{T}log(|R_{t}|)+\epsilon_t^{'}R_t^{-1}\epsilon_t$. The first term evaluates to an N by N matrix while the second term evaluates to a scalar. Thus, the likelihood for each timestep is an N by N matrix. In implementation, only a scalar is expected to be return, do I just sum all the terms in $log(|R_t|)$ when calculating the actual likelihood?
Furthermore, the current time it takes for the minimize function to converge takes too long, any advice on faster estimation techniques is appreciated.
## Answer by Oleg Melnikov (score 4)
https://quant.stackexchange.com/a/21684
If $\log{(|R_t|)}$ is your first term, I'm not sure why this is a matrix. Modulus (determinant herein) applied to a matrix $R_t$ gives a scalar. If your implementation in python produces a matrix, that's likely because modulus is treated as an element-wise abs() function for each element of a matrix.
It may be easier and faster to use `rugarch` (univariate GARCH) and `rmgarch` (multivariate GARCH) packages in R to fit DCC model parameters. You can access these from within Python. These packages allow an easy speed up with clustered processing. Alternatively, there is a `ccgarch` package in R allowing DCC fitting.
Calling R from Python is numerously discussed here, here, and in many other posts.
Unstarched website has many helpful DCC GARCH examples.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.