Issues fitting basic models with rmgarch

Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Issues fitting basic models with rmgarch

Ezequiel Antar
Hello. Any help with the issues below would be much appreciated!


# There are two main issues with rmgarch::cgarchfit

# 1) I cannot reconcile the correlations and likelihood in some (basic)
cases

# 2) I cannot use a marginal model with no estimated parmeters (constant
vol, normal, and zero mean)



rm(list = ls())

library(rmgarch)

library(mvtnorm)



data(dji30retw)

z.t <- dji30retw[, 1:2]



# 1) Cannot reconcile the correlations and likelihood: an example

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Univariate model: z = mu + sigma * N(0,1)

uspec.each <- ugarchspec(mean.model = list(armaOrder = c(0,0)),

                         variance.model = list(model = "iGARCH", garchOrder
= c(1,1)),

                         distribution.model = "norm",

                         fixed.pars = list(alpha1 = 0, omega = 0))



# Copula model: Gaussian copula, constant correlations

mspec <- cgarchspec(uspec = multispec(replicate(ncol(z.t), uspec.each)),

                    distribution.model = list(copula = "mvnorm",
time.varying = FALSE, transformation = "parametric"))



cgarch <- cgarchfit(spec = mspec, data = z.t)



# These two likelihoods should be the same, but they are not:

likelihood(cgarch) # 3767.693

sum(dmvnorm(z.t, mean = coef(cgarch, type = 'garch'), sigma =
rcov(cgarch)[,,1], log = TRUE)) # 3771.734



# These two correlations should be the same, but they are not:

rcor(cgarch)[1,2] # 0.4099081

cor(z.t)[1,2] # 0.4170385



# 2) Cannot use a marginal model with no estimated parmeters

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Univariate model: z = 0 + sigma * N(0,1)

uspec.each <- ugarchspec(mean.model = list(armaOrder = c(0,0)),

                         variance.model = list(model = "iGARCH", garchOrder
= c(1,1)),

                         distribution.model = "norm",

                         fixed.pars = list(mu = 0, alpha1 = 0, omega = 0))



mspec <- cgarchspec(uspec = multispec(replicate(ncol(z.t), uspec.each)),

                    distribution.model = list(copula = "mvnorm",
time.varying = FALSE, transformation = "parametric"))



# Attempt 1:

# ~~~~~~~~~~

cgarch <- cgarchfit(spec = mspec, data = z.t)

# Error in UseMethod("convergence") :

#  no applicable method for 'convergence' applied to an object of class
"c('uGARCHfilter', 'GARCHfilter', 'rGARCH')"

# Note: the problem is that when no parameters are estimated, ugarchfit
(used by cgarchfit) returns an uGARCHfilter instead of uGARCHfit object



# Attempt 2: fit univariate models first, using fit.control = list(fixed.se =
TRUE), so that ugarchfit returns an uGARCHfit object

# ~~~~~~~~~~

mfit <- multifit(multispec = multispec(replicate(ncol(z.t), uspec.each)),
data = z.t, fit.control = list(fixed.se = TRUE))



cgarch <- cgarchfit(spec = mspec, data = z.t, fit = mfit)

# Error in array(x, c(length(x), 1L), if (!is.null(names(x)))
list(names(x),  :

#                                                                   'data'
must be of a vector type, was 'NULL'


<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] 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.