[R-SIG-Finance] rugarch and copulas
ludovic.theate
ludovic.theate at gmail.com
Wed Nov 21 10:27:20 CET 2012
Alexios,
Sorry but I've got a last problem.
I firstly simulated independant trajectories of my processes, and I find
acceptable results.
Then I tried to simulate correlated trajectories using the following
function (as we discussed last week) :
##########################
# Sim_Cop_Garch Function #
##########################
sim_cop_garch <- function(mfit,cop,nsim,horizon){
ncur = length(mfit)
result <- NULL
for(j in 1:nsim){
# Simulation of nsim random values of the copulas: these are uniform
#uni_res <- rCopula(horizon,cop) # FIRST TRY
uni_res <- matrix(runif(horizon*ncur),ncol=ncur,nrow=horizon) # SECOND TRY
# Inverse-transform : uniform values are transformed into appropriate values
(e.g. norm, sstd,...)
innov = matrix(NA, ncol = ncur, nrow = horizon)
for(i in 1:ncur){
gdist = mfit[[i]]@model$modeldesc$distribution
lambda = ifelse(mfit[[i]]@model$modelinc[18]>0,
mfit[[i]]@fit$ipars["ghlambda",1], 0)
skew = ifelse(mfit[[i]]@model$modelinc[16]>0,
mfit[[i]]@fit$ipars["skew",1], 0)
shape = ifelse(mfit[[i]]@model$modelinc[17]>0,
mfit[[i]]@fit$ipars["shape",1], 0)
innov[,i] = qdist(gdist,uni_res[,i] , mu = 0, sigma = 1, lambda = lambda,
skew = skew, shape = shape)}
# Simulation of the ARIMA-GARCH model using the previously generated
innovations
one_simul <- matrix(NA,ncol=ncur,nrow=1)
for(i in 1:ncur){
test <- ugarchsim(mfit[[i]],n.sim=horizon,m.sim=1,
custom.dist=list(name="sample",distfit=matrix(innov[,i],ncol=1,nrow=horizon)))@simulation$seriesSim[horizon,1]
one_simul[,i] <- exp(diffinv(test))[2] }
result <- rbind(result,one_simul)
}
return(result)
}
The results I got for a Gaussian copula were clearly incorrect. So I
modified the function to skip the copula-generated uniform random numbers
(with the "first try" comment ) and I used the runif method instead. (with
the "second try" comment) Even when I do this, I find impossible results,
so the problem doesn't come from the copula.
I think I have maybe misunderstood the behavior of the custom.dist option in
the ugarchsim method. Could you please have a look and tell me if you see
something wrong ? Thanks a lot.
Kind regards,
Ludovic
--
View this message in context: http://r.789695.n4.nabble.com/rugarch-and-copulas-tp4647300p4650268.html
Sent from the Rmetrics mailing list archive at Nabble.com.
More information about the R-SIG-Finance
mailing list