[R-SIG-Finance] Simulating an In-Mean Garch (1, 1) model with Rugarch.
alexios ghalanos
alexios at 4dscape.com
Fri Feb 21 11:13:46 CET 2014
There does not appear to be a problem, and rugarch does take into
consideration everything you defined in your specification.
Please follow the guidelines and consider using a reproducible example
as I do below:
library(rugarch)
# reproducible means using data available to the package or
# simulated data with the seed provided.
data(sp500ret)
##############################################################################
# arch in sigma^2
spec <- ugarchspec( variance.model=list(model="sGARCH",
garchOrder=c(1,1)),mean.model=list(armaOrder=c(0,0), include.mean=T,
archm=T, archpow=2) ,
distribution.model="norm",start.pars = list(), fixed.pars =
list(archm=-0.5))
fit <- ugarchfit(garch11_spec, as.xts(sp500ret), fit.control =
list(stationarity = 1, fixed.se = 1))
sim <- ugarchsim(garch11_fit, n.sim = 4516, n.start = 0, m.sim = 2,
startMethod = "unconditional", rseed = 123)
# Extract the simulated matrices
sigmasim = sigma(sim)
xsim = fitted(sim)
residsim = sim at simulation$residSim
# The equation replicated:
# first run (m.sim=1)
x = coef(fit)["mu"] + -0.500000*sigmasim[,1]^2 + residsim[,1]
# Equal to what rugarch returns:
all.equal(as.numeric(sim at simulation$seriesSim[,1]), as.numeric(x))
>TRUE
# second run (m.sim=2)
x = coef(fit)["mu"] + -0.500000*sigmasim[,2]^2 + residsim[,2]
all.equal(as.numeric(sim at simulation$seriesSim[,2]), as.numeric(x))
>TRUE
##############################################################################
# arch in sigma
spec <- ugarchspec( variance.model=list(model="sGARCH",
garchOrder=c(1,1)),mean.model=list(armaOrder=c(0,0), include.mean=T,
archm=T, archpow=1 ) ,
distribution.model="norm",start.pars = list(), fixed.pars =
list(archm=-0.5))
fit <- ugarchfit(spec, as.xts(sp500ret), fit.control = list(stationarity
= 1, fixed.se = 1))
sim <- ugarchsim(fit, n.sim = 4516, n.start = 0, m.sim = 2, startMethod
= "unconditional", rseed = 123)
sigmasim = sigma(sim)
xsim = fitted(sim)
residsim = sim at simulation$residSim
x = coef(fit)["mu"] + -0.500000*sigmasim[,1] + residsim[,1]
all.equal(as.numeric(sim at simulation$seriesSim[,1]), as.numeric(x))
>TRUE
x = coef(fit)["mu"] + -0.500000*sigmasim[,2] + residsim[,2]
all.equal(as.numeric(sim at simulation$seriesSim[,2]), as.numeric(x))
>TRUE
-Alexios
On 21/02/2014 03:03, Benny André Byremo wrote:
> Hello Everybody
> I am posting here because I think I have a problem with performing a simulation with the rugarch package in R.
> I want to simulate a mean model consisting of a half variance and a variance model equal to the Garch (1,1) model, but I do not think the ugarchsim function take into consideration the half variance in the mean model automatically. Is that correct? If thats the case what do I I have to do to get it correct? The reason for it is that the simulated values is far to big to be correct. The mean model is:
> r_t = u -0.5sigma_t + epsilon_t
> and the variance equation is:
> sigma^2_t = w + a*epsilon_t + b*sigma^2_t-1.
> The specification with the ugarchspec:
> garch11_spec <- ugarchspec( variance.model=list(model="sGARCH", garchOrder=c(1,1)),mean.model=list(armaOrder=c(0,0), include.mean=T, archm=T, archpow=2 ) , distribution.model="norm",start.pars = list(), fixed.pars = list(archm=-0.5))
> and this is fitted with the ugarchfit function where r.xts is the data object:
> garch11_fit <- ugarchfit(garch11_spec, r.xts, fit.control = list(stationarity = 1, fixed.se = 1))
> The possible "problem child" is specified as follows:
> garch11_sim <- ugarchsim(garch11_fit, n.sim = 4516, n.start = 0, m.sim = 10000, startMethod = "unconditional", rseed = 123) names(garch11_sim at simulation)
>
> I have tried to look for help in the documentation for the package and in the package vignette without success, so all help would be appreciated.
>
> Greetings
>
>
>
>
>
>
>
>
>
> [[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