dccsim-methods: function: DCC-GARCH Simulation

Description Usage Arguments Details Value Author(s) Examples

Description

Method for creating a DCC-GARCH simulation object.

Usage

1
2
3
4
dccsim(fitORspec, n.sim = 1000, n.start = 0, m.sim = 1, startMethod = c("unconditional", "sample"), 
		presigma = NULL, preresiduals = NULL, prereturns = NULL, preR = NULL, preH = NULL, rseed = NULL, 
		mexsimdata = NULL, vexsimdata = NULL, parallel = FALSE, 
		parallel.control = list(pkg = c("multicore", "snowfall"), cores = 2), VAR.fit = NULL, ...)

Arguments

fitORspec

A DCCspec or DCCfit object created by calling either dccspec with fixed parameters or dccfit.

n.sim

The simulation horizon.

n.start

The burn-in sample.

m.sim

The number of simulations.

startMethod

Starting values for the simulation. Valid methods are ‘unconditional’ for the expected values given the density, and ‘sample’ for the ending values of the actual data from the fit object.

presigma

Allows the starting sigma values to be provided by the user.

prereturns

Allows the starting return data to be provided by the user.

preresiduals

Allows the starting residuals to be provided by the user.

preR

Allows the starting correlation to be provided by the user.

preH

Allows the starting covariance to be provided by the user.

rseed

Optional seeding value(s) for the random number generator. For m.sim>1, it is possible to provide either a single seed to initialize all values, or one seed per separate simulation (i.e. m.sim seeds). However, in the latter case this may result in some slight overhead depending on how large m.sim is.

mexsimdata

A list (equal to the number of asset) of matrices of simulated external regressor-in-mean data with row length equal to n.sim + n.start. If the fit object contains external regressors in the mean equation, this must be provided else will be assumed to be zero.

vexsimdata

A list (equal to the number of asset) of matrices of simulated external regressor-in-variance data with row length equal to n.sim + n.start. If the fit object contains external regressors in the variance equation, this must be provided else will be assumed to be zero.

parallel

Whether to make use of parallel processing on multicore systems.

parallel.control

The parallel control options including the type of package for performing the parallel calculations (‘multicore’ for non-windows O/S and ‘snowfall’ for all O/S), and the number of cores to make use of.

VAR.fit

An optional VAR.fit list returned from calling the varxfilter function. This is for the dispatch method with DCCspec object since the DCCfit object will already contain all necessary information for the VAR model.

...

.

Details

In order to pass a correct spec to the filter routine, you must ensure that it contains the appropriate ‘fixed.pars’ in both the multivariate DCC part of the spec as well as the multiple univariate spec part. An illustrative example is contained below.

Value

A DCCsim object containing details of the DCC-GARCH simulation.

Author(s)

Alexios Ghalanos

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
## Not run: 
data(dji30ret)
Dat = dji30ret[, 1:4, drop = FALSE]
uspec1 = ugarchspec(mean.model = list(armaOrder = c(1,0)), variance.model = list(model = "apARCH"), 
		distribution.model = "norm")
uspec2 = ugarchspec(mean.model = list(armaOrder = c(2,0)), variance.model = list(model = "gjrGARCH"), 
		distribution.model = "norm")
uspec3 = ugarchspec(mean.model = list(armaOrder = c(0,0)), variance.model = list(model = "sGARCH"), 
		distribution.model = "norm")
uspec4 = ugarchspec(mean.model = list(armaOrder = c(1,0)), variance.model = list(model = "sGARCH",
		garchOrder = c(2, 1)), distribution.model = "norm")

uspec = c( uspec1, uspec2, uspec3, uspec4 )
spec = dccspec(uspec = multispec( uspec ), dccOrder = c(1,1), distribution = "mvt")

# fit the model
fit = dccfit(data = Dat, spec = spec, out.sample = 100, solver = "solnp", 
	fit.control = list(scale = TRUE, eval.se = FALSE))

# simulation takes either fit or spec (check both)
spec2 = spec
# fix the dcc parameters
spec2@mspec$optimization.model$fixed.pars = coef(fit, type = "dcc")
# fix the garchpars
for(i in 1:4) spec2@uspec@spec[[i]]@optimization.model$fixed.pars = coef(fit@ufit@fit[[i]])

preR = cor(as.matrix(Dat))
presigma = tail( sigma(fit@ufit), 2 )
preresiduals = tail( residuals(fit@ufit), 2 )
prereturns = tail( as.matrix(Dat), 2 )

# also possible to obtain uncvariance by supplying parameters
# showMethods("uncvariance")
uncv = sapply(fit@ufit@fit, FUN = function(x) uncvariance(x))
preH = diag(sqrt(uncv)) 
		
sim1 = dccsim(fitORspec = fit, n.sim = 1000, n.start = 100, m.sim = 2, startMethod = "sample", 
	presigma = presigma, preresiduals = preresiduals, prereturns = prereturns, preR = preR, preH = NULL, 
	rseed = c(100, 200), mexsimdata = NULL, vexsimdata = NULL)

sim2 = dccsim(fitORspec = spec2, n.sim = 1000, n.start = 100, m.sim = 2, 
	presigma = presigma, preresiduals = preresiduals, prereturns = prereturns, preR = preR, preH = preH, 
	rseed = c(100, 200), mexsimdata = NULL, vexsimdata = NULL)

R1 = rcor(sim1, sim = 1)
R2 = rcor(sim2, sim = 1)
H1 = rcov(sim1, sim = 2)
H2 = rcov(sim2, sim = 2)

# now replicate the conditions for the sample start
sim3 = dccsim(fitORspec = fit, n.sim = 1000, n.start = 100, m.sim = 2, startMethod = "sample", 
		presigma = NULL, preresiduals = NULL, prereturns = NULL, preR = preR, preH = NULL, 
		rseed = c(100, 200), mexsimdata = NULL, vexsimdata = NULL)

# prereturns should be NULL
sim4 = dccsim(fitORspec = spec2, n.sim = 1000, n.start = 100, m.sim = 2, 
		presigma = presigma, preresiduals = preresiduals, prereturns = NULL, preR = preR, preH = preH, 
		rseed = c(100, 200), mexsimdata = NULL, vexsimdata = NULL)

R3 = rcor(sim3, sim = 2)
R4 = rcor(sim4, sim = 2)
H3 = rcor(sim3, sim = 1)
H4 = rcor(sim4, sim = 1)

cat("\nDCC Simulation Tests:\n")
cat("\nFit and Spec based Simulation DCC model Conditional Correlation check1:\n")
cat("\nn = 1\n")
print(R1[, , 1] == R2[, , 1])
cat("\nn = 100\n")
print(R1[, , 100] == R2[, , 100])
cat("\nFit and Spec based Simulation DCC model Conditional Covariance check1:\n")
cat("\nn = 1\n")
print(H1[, , 1] == H2[, , 1])
cat("\nn = 100\n")
print(H1[, , 100] == H2[, , 100])
cat("\nFit and Spec based Simulation DCC model Conditional Correlation check2:\n")
cat("\nn = 1\n")
print(R3[, , 1] == R4[, , 1])
cat("\nn = 100\n")
print(R3[, , 100] == R4[, , 100])
cat("\nFit and Spec based Simulation DCC model Conditional Covariance check2:\n")
cat("\nn = 1\n")
print(H3[, , 1] == H4[, , 1])
cat("\nn = 100\n")
print(H3[, , 100] == H4[, , 100])

## End(Not run)

rgarch documentation built on May 31, 2017, 3:20 a.m.