[R-SIG-Finance] Question about dccsim

alexios alexios at 4dscape.com
Mon Jul 27 12:20:09 CEST 2015


Hi,

It should.

For preZ use:
preZ = tail(residuals(fit1)/sigma(fit1),1)
NOT
preZ = tail(fit1 at mfit$stdresid, 1)

I'm guessing you looked at the code for startMethod="sample"
which used this (wrongly). This has been fixed now in
the version 1.3-0 on bitbucket.

As a test, we can perform the following in-sample check,
which also illustrates the use of dccsim using a specification
object:

######################################################
library(rmgarch)
data(dji30retw)
Dat = dji30retw[, 1:3, drop = FALSE]
cnames = colnames(Dat)
uspec = ugarchspec(mean.model = list(armaOrder = c(2,1), include.mean =
FALSE), variance.model = list(garchOrder = c(2,1), model = "gjrGARCH"),
distribution.model = "norm")
spec = dccspec(uspec = multispec( replicate(3, uspec) ), dccOrder = 
c(1,1), distribution = "mvnorm")
fit = dccfit(spec, data = Dat, fit.control = list(eval.se=FALSE))

uspec2 = ugarchspec(mean.model = list(armaOrder = c(2,1), include.mean =
FALSE), variance.model = list(garchOrder = c(2,1), model = "gjrGARCH"),
distribution.model = "norm")
vspec = vector(mode = "list", length = 3)
midx = fit at model$midx
mpars = fit at model$mpars
for(i in 1:3){
vspec[[i]] = uspec2
setfixed(vspec[[i]])<-as.list(mpars[midx[,i]==1, i])
}
dccfix = as.list(coef(fit, "dcc"))
spec2 = dccspec(uspec = multispec( vspec ),
dccOrder = c(1,1),  distribution = "mvnorm",
fixed.pars = dccfix)

presigma = sigma(fit)[1:2,]
preresiduals = residuals(fit)[1:2,]
prereturns = as.matrix(Dat[1:2,])

sim = dccsim(fitORspec = spec2, n.sim = 1, n.start = 0, m.sim = 1,
presigma = presigma, preresiduals = preresiduals, prereturns = 
prereturns, preQ = rcor(fit, type = "Q")[,,2], Qbar = fit at mfit$Qbar,
		preZ = (residuals(fit)/sigma(fit))[2,],rseed = c(100), mexsimdata = 
NULL, vexsimdata = NULL)

# the in-sample forecast for T+3 == simulated 1-ahead at T+2
all.equal(rcov(fit)[,,3], rcov(sim)[,,1],check.attributes=FALSE)
 >TRUE
###################################################################

As regards the rseed, yes there is an error if you don't explicitly 
provide it. I'll look into this when I have more time.

The summary for simulated DCC objects is indeed empty...feel free to 
contribute a patch which will show something more meaningful.

Regards,

Alexios

On 26/07/2015 22:58, Rods wrote:
> Hi,
>
> I'm wondering why dccsim is giving a different 1 step ahead H matrix from
> dccforecast. Shouldn't these be the same? Running the code below, you can
> see that only the diagonal matches. Also, if I remove the rseed argument
> I'm getting an error, is it just me? Lastly, if you just run "sim1", you
> get an empty summary.
>
> Thanks in advance,
> -------------------------------------------------------------------------------------
>
>      data(dji30retw)
>      Dat = dji30retw[, 1:3, drop = FALSE]
>
>
>      cnames = colnames(Dat)
>      uspec = ugarchspec(mean.model = list(armaOrder = c(2,1), include.mean =
> FALSE), variance.model = list(garchOrder = c(1,1), model = "gjrGARCH"),
> distribution.model = "norm")
>      spec1 = dccspec(uspec = multispec( replicate(3, uspec) ), dccOrder =
> c(1,1),
>               distribution = "mvnorm")
>      fit1 = dccfit(spec1, data = Dat, out.sample = 100, fit.control = list(
> eval.se=FALSE))
>      T = dim(Dat)[1]-100
>
>
>      forc2 = dccforecast(fit1, n.ahead = 1, n.roll = 10)
>      presigma = tail( sigma(fit1 ), 2 )
>      preresiduals = tail( residuals(fit1), 2 )
>      prereturns = tail( as.matrix(Dat[1:T,]), 2 )
>
>
>      sim1 = dccsim(fitORspec = fit1, n.sim = 2, m.sim = 500, startMethod =
> "unconditional",
>              presigma = presigma, preresiduals = preresiduals, prereturns =
> prereturns,
>              preQ = last(rcor(fit1, type = "Q"))[,,1], Qbar = fit1 at mfit$Qbar,
>
>              preZ = tail(fit1 at mfit$stdresid, 1), rseed=c(152))
>
>
>      sim1 at msim$simH[[1]][,,1]
>      forc2 at mforecast$H[[1]]
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>
>



More information about the R-SIG-Finance mailing list