<div class="gmail_quote"><div class="gmail_quote"><div class="gmail_quote"><div><div></div><div><div class="gmail_quote">Dear Rmetrics Core Team,<br>I sent this message a couple of times to r-help group but unfortunately did not get any response that would be helpful...so I decided to write directly to the maintainer of the package 'fGarch'.<br>


<div><div></div><div><br><br>I have a rather complex problem... I will have to explain 
everything in detail because I cannot solve it by myself...i just ran 
out of ideas. So here is what I want to do:<br>I take quotes of two 
indices - S&P500 and DJ. And my first aim is to estimate 
coefficients of the DCC-GARCH model for them. This is how I do it:<br>
<br><br><span style="color:rgb(51, 51, 255)">library(tseries)</span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">p1 = get.hist.quote(instrument = "^gspc",start = "2005-01-07",end = "2009-09-04",compression = "w", quote="AdjClose")</span><br style="color:rgb(51, 51, 255)">






<span style="color:rgb(51, 51, 255)">p2 = get.hist.quote(instrument = "^dji",start = "2005-01-07",end = "2009-09-04",compression = "w", quote="AdjClose")</span><br style="color:rgb(51, 51, 255)">






<span style="color:rgb(51, 51, 255)">p = cbind(p1,p2)</span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">y = diff(log(p))*100</span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">y[,1] = y[,1]-mean(y[,1])  </span><br style="color:rgb(51, 51, 255)">






<span style="color:rgb(51, 51, 255)">y[,2] = y[,2]-mean(y[,2])</span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">T = length(y[,1])</span><br style="color:rgb(51, 51, 255)"><br style="color:rgb(51, 51, 255)">






<span style="color:rgb(51, 51, 255)">library(ccgarch)</span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">library(fGarch)</span><br style="color:rgb(51, 51, 255)"><br style="color:rgb(51, 51, 255)">






<span style="color:rgb(51, 51, 255)">f1 = garchFit(~ garch(1,1), data=y[,1],include.mean=FALSE)</span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">f1 = f1@fit$coef</span><br style="color:rgb(51, 51, 255)">






<span style="color:rgb(51, 51, 255)">f2 = garchFit(~ garch(1,1), data=y[,2],include.mean=FALSE)</span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">f2 = f2@fit$coef</span><br style="color:rgb(51, 51, 255)">






<br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">a = c(f1[1], f2[1]) </span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">A = diag(c(f1[2],f2[2]))</span><br style="color:rgb(51, 51, 255)">






<span style="color:rgb(51, 51, 255)">B = diag(c(f1[3], f2[3])) </span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">dccpara = c(0.2,0.6) </span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">dccresults = dcc.estimation(inia=a, iniA=A, iniB=B, ini.dcc=dccpara,dvar=y, model="diagonal")</span><br style="color:rgb(51, 51, 255)">






<span style="color:rgb(51, 51, 255)"></span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">dccresults$out</span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">DCCrho = dccresults$DCC[,2]</span><br style="color:rgb(51, 51, 255)">






<span style="color:rgb(51, 51, 255)">matplot(DCCrho, type='l')</span><br><br><br>dccresults$out deliver me the estimated coefficients of the DCC-GARCH model. I had also some questions about this part but it is not connected with the package 'tseries' so I am not going to ask you for help here.<br>



</div></div><span style="color:rgb(51, 204, 0)"><font color="#000000"><font style="color:rgb(0, 153, 0)" color="#33ff33"></font></font></span><div><br>Ok. This would be it when it comes to DCC-GARCH.<br>


<br>Now, using conditional correlation obtained from the DCC-GARCH 
model, I want to test for structural shifts in conditional correlations.
 To be precise, I want to test whether the conditional correlations 
significantly increase in the turmoil period / during the Subprime 
crisis.<br>
The regression model is AR(1)-GARCH(1,1), using a dummy variable specified as:<br>

<p class="MsoNormal"><br></p><p class="MsoNormal"><br></p><p class="MsoNormal">*** the equations, you can find in the attachment ***</p><p class="MsoNormal"><br></p><p class="MsoNormal"><br></p>
<p class="MsoNormal">where the first equation is the conditional correlation among the two indices during the Subprime crisis, <font size="6">D</font>t is a dummy variable for the turmoil period, and the second equation (<font size="6">h</font>ij,t) is the conditional variance of <font size="6">e</font>ij,t<br>






<span></span></p>

<br>The aim is, of course, to find the estimates of the regression model
 on structural shifts in the conditional correlations obtained in the 
DCC-GARCH model.<br><br>I found an information that there is no function
 for AR(1)-GARCH(1,1) regression model. That's why, apparently, it has to be done in 
two steps:<br><br>
1) estimate the AR parameters<br>2) estimate the GARCH part of the model on the residuals from the AR model<br><br>And this would be my rather poor idea of how to do it...<br><br><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">library(timeSeries)</span><br style="color:rgb(51, 51, 255)">






<span style="color:rgb(51, 51, 255)">library(fSeries)</span><br></div><span style="color:rgb(51, 51, 255)">library(tseries)</span><div><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">step1 = arma(DCCrho, order = c(1,0), include.intercept = TRUE)</span><br>



<span style="color:rgb(51, 51, 255)">step1$res</span><br style="color:rgb(51, 51, 255)">


<span style="color:rgb(51, 51, 255)">step11 = na.remove(step1$res)</span><br style="color:rgb(51, 51, 255)"><span style="color:rgb(51, 51, 255)">step2 = garch (step11, order = c(1,1), include.intercept = TRUE)</span><br>






<br><br></div><span style="color:rgb(51, 204, 0)"><div>To be honest I have no clue 
how whther it is correct. I do not even now why do I get a missing value as a result 
of step1 (step1$res[1]) and how to account for it? Above, I just removed
 it but then I have a smaller number of observations...and this is 
probably wrong.<br></div>
And then these GARCH estimates on the residuals...does the code for that make sense at all?<br><br><br><font color="#000000">I also had another idea, to apply the following code instead of the one written above:<br><br><span style="color:rgb(51, 51, 255)">garchFit(formula = ~ arma(1,0) + garch(1,1), data=DCCrho, include.mean=TRUE)</span><br>


</font><div><br><font color="#000000">But I am not sure if this is delivering me the coefficients I am looking for.</font><br><font color="#000000"><br>Hopefully, you will find time to
 give me a hand because I have to solve the problem and I reached the 
point where I cannot move forward without someone's help. <br>
<br></font><span style="color:rgb(51, 204, 0)"><font color="#000000">Thank you very much in advance for looking at/checking what I wrote and helping me</font></span><font color="#000000">.<br></font></div>
</span><br>Best regards<br><font color="#888888"><font color="#888888">Marcin Płóciennik</font>
</font></div><br>
</div></div></div><br>
</div><br>
</div><br>