Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: MGARCH DCC in panel settings - error?


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: MGARCH DCC in panel settings - error?
Date   Fri, 16 Mar 2012 11:10:55 +0000

I can't comment on your -mgarch- use. I don't think anyone can comment easily on comparison with OxMetrics without seeing much more detail. 

In terms of cycling over panels, this can be simplified, but note that -- naturally -- this is not tested by me because I do not have your data. 
-forval- is more natural here. 

use "etf.sticker_quotes_upd_32.dta", clear
drop if ret == .
sort permno date
duplicates drop permno date, force
egen id=group(permno)
su id, meanonly
local max = r(max) 
save etf.sticker_quotes_upd_32_2 

qui forval i = 1/`max' { 
	  use "etf.sticker_quotes_upd_32_2.dta", clear
        keep if id == `i'
        gen date_n=_n
        tsset date_n
        l permno in 1/2 
di "{title: results for `i'}"
di 
        noisily  mgarch dcc (ret vwretd = , noconstant) ///
  , arch(1) garch(1)  technique(bhhh) iterate(4000)
         predict H* if e(sample), variance
         generate double corr_ret_vwretd = H_ret_vwretd / (  sqrt(H_ret_ret) *sqrt(H_vwretd_vwretd))
         outsheet using DCC_`i'.csv , comma 
 }

On similar technique see

FAQ     . . . . . . . . . . Making foreach go through all values of a variable
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        8/05    Is there a way to tell Stata to try all values of a
                particular variable in a foreach statement without
                specifying them?
                http://www.stata.com/support/faqs/data/foreach.html

Nick 
n.j.cox@durham.ac.uk 

Arsenio Staer

Hi Nick and Rafal,

Thank you for the answers! I approached this following way

================================= begin example =============================
use "etf.sticker_quotes_upd_32.dta", clear
sort permno date
duplicates drop permno date, force
egen id=group(permno)
su id, meanonly
scalar max_r = `r(max)'
foreach i of num 1/`=max_r' { /* instead of forvalues which has to have a numeric range? */
        use "etf.sticker_quotes_upd_32.dta", clear
        sort permno date
        qui egen id=group(permno)
        drop if id != `i'
        duplicates drop permno date, force
        drop if ret == .
        gen date_n=_n
        tsset date_n
        l permno in 1/2 if id==`i'
        noisily  mgarch dcc (ret vwretd = , noconstant) ///
 if id == `i' , arch(1) garch(1)  technique(bhhh) iterate(4000)
         predict H* if e(sample), variance
         generate double corr_ret_vwretd = H_ret_vwretd / (  sqrt(H_ret_ret) *sqrt(H_vwretd_vwretd))
         outsheet using DCC_`i'.csv , comma 

 }

================================== end example ==============================

Apologize if the code above looks unformatted.

I found out that, the series need to be -tsset- but can't be -xtset-
at least in my case, any mgarch command on -xtset- dataset gives that
error in the previous message. So i create a new dataset based on the
group and -tsset- it in the loop and run the estimation and output the
DCC time series which I'm interested in. This is an proof of concept
on the return data then i will run it on the other variables.

I'm working on the estimation itself, somehow can't achieve
convergence. The same model in OxMetrics achieves convergence in
seconds with similar log likelihood values. But that's a different
matter altogether.


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index