Originally posted by William Lisowski
View Post
Code:
g t=_n tsset t sum grcon2_q sum grcon2_q , detail gen double ret=grcon2_q generate double et = . generate double ht = . generate double nt = . generate double st = . generate double kt = . drop if _n==1 capture program drop garchsk program garchsk version 17 args lnf a1 b0 b1 b2 c0 c1 c2 g0 g1 g2 tempvar et yt ht nt st kt psi gam * initialize variables qui gen double `yt'=$ML_y1 qui replace `et'=0.0 qui sum `yt', detail qui replace `ht'=r(Var) qui replace `nt'=`et'/sqrt(`ht') qui replace `st'=r(skewness) qui replace `kt'=r(kurtosis) * make garch11 for var, skew , kurtosis. There is AR1 in the mean equation (for et) qui replace `et'=`yt'-`a1'*`yt'[_n-1] if _n>1 qui replace `ht'=`b0'+`b1'*(`et'[_n-1])^2 + `b2'*`ht'[_n-1] if _n>1 qui replace `nt'=`et'/sqrt(`ht') if _n>1 qui replace `st'=`c0'+`c1'*(`nt'[_n-1])^3 + `c2'*`st'[_n-1] if _n>1 qui replace `kt'=`g0'+`g1'*(`nt'[_n-1])^4 + `g2'*`kt'[_n-1] if _n>1 * make Gram-Charlier liklelihood(lnf) qui gen double `psi'= 1 + (`st'/6) * ((`nt'^3)-(3*`nt'))+((`kt'-3)/24)*(`nt'^4 - (6*`nt'^2) + 3) qui gen double `gam'= 1+ ((`st'^2)/6) +(((`kt'-3)^2)/24) qui replace `lnf'= -0.5*ln(`ht')-0.5*(`nt'^2) +ln(`psi'^2)-ln(`gam') end ml model lf garchsk (a1: ret= ) /b0 /b1 /b2 /c0 /c1 /c2 /g0 /g1 /g2, technique(bhhh) robust ml init /b0=0.0023 /b1=0.0387 /b2=0.9586 /c0=-0.0458 /c1=0.0085 /c2=-0.0227 /g0=3.0471 /g1=0.0055 /g2=0.0882 ml search ml max ml model lf garchsk (a1: ret= ) /b0 /b1 /b2 /c0 /c1 /c2 /g0 /g1 /g2, technique(bhhh) robust ml init /b0=0.0023 /b1=0.0387 /b2=0.9586 /c0=-0.0458 /c1=0.0085 /c2=-0.0227 /g0=3.0471 /g1=0.0055 /g2=0.0882 ml report
Thanks in advance,
Comment