# 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.

## 1 Answer

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.

• This is a really old post but thank you very much for taking your time still to answer it. I realized that it was the determinant function after I posted this thread. However, I find your links on implementing R in python to be really interesting so I'll look more into that field regardless :) – Kevin Pei Nov 17 '15 at 1:45
• You are welcome. Hopefully, this will help others implement DCC as well. – Oleg Melnikov Nov 18 '15 at 0:44