Using own simulations in package rugarch
1. Did you read the documentation on ugarchpath or ugarchsim? "custom.dist: Optional density with fitted object from which to simulate." The custom.dist option allows for defining a custom density which exists in the users workspace with methods for ?r? (sampling, e.g. rnorm) and ?d? (density e.g. dnorm). It must take a single fit object as its second argument. Alternatively, custom.dist can take any name in the name slot (e.g.?sample?) and a matrix in the fit slot with dimensions equal to m.sim (columns) and n.sim (rows). The usefulness of this becomes apparent when one is considering the copula-GARCH approach or the bootstrap method. 2. A simple search of this mailing list's archives would also have answered your question with an example: https://stat.ethz.ch/pipermail/r-sig-finance/2012q2/010305.html 3. rugarch.test1g in the rugarch.tests folder also contains an example of this. -Alexios
On 04/11/2013 12:52, Stefan.Jaeschke at rwe.com wrote:
Hi there,
I am currently preparing an out-of-sample backtest (one-day-ahead) by carefully using the methods ugarchfilter and ugarchpath. In a next step I would need to simulate my own dataset. I would like to simulate from a bivariate copula and then applying the inverse cumulative distribution functions of each leg separately. This looks as follows (excerpt):
library(rugarch)
library(copula)
n <- 1000
dcop <- gumbelCopula(2.961, dim = 2)
simgumcop <- rcopula(dcop,n)
simgumcop[,1] = qdist(distribution = "sged", simgumcop[,1], mu = 0, sigma = 1, skew = skew_WTI, shape = shape_WTI)
simgumcop[,2] = qdist(distribution = "sged", simgumcop[,2], mu = 0, sigma = 1, skew = skew_Brent, shape = shape_Brent)
Now it would like to put those simulations back in the backtesting framework package. Is there a way to incorporate those samples in the ugarchpath (i.e. I provide the simulations and ugarchpath is doing the rest)? Or maybe another function that can help?
for(i in 1:100){
# filter the data upto time T+i-1 with the coefficients
# estimated from the model upto time T
filt = ugarchfilter(specf, data = nrenditen[1:(1001+i-1)], n.old = 1001)
# use lagged values prior to the next forecast:
path = ugarchpath(specf, n.sim=1, m.sim= numsim, presigma = tail(sigma(filt),3), prereturns = nrenditen[(1001+i-3):(1001+i-1)], preresiduals = tail(residuals(filt),3))
fsim[,i] = as.numeric(fitted(path))
}
Many thanks in advance.
Mit freundlichen Gr??en / Kind regards
Stefan J?schke
RWE Supply & Trading GmbH
Risk Origination & Industrial Sales (MFM-R)
Altenessener Str. 27
45141 Essen
Germany
Phone +49 201 5179-1674
Mobile +49 162-2596816
Email stefan.jaeschke at rwe.com
____________________________________________________ Supervisory Board: Peter Terium (Chairman) Management Board: Stefan Judisch (CEO), Dr Markus Krebber, Alan Robinson Headquarters: Essen Registered at Local District Court, Essen Commercial Registry No.: HRB 14327 Sales Tax ID No.: DE 8130 22 070 Please consider the environment before printing this e-mail [[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.