Richard
Richard

Reputation: 189

Implementation of DCC-GARCH

I have some issues implementing the DCC-GARCH in R. When I run the following code in R, I always get the same error message that says:

Error in UseMethod("convergence") : no applicable method for 'convergence' applied to an object of class "try-error"

Unfortunately I have no idea how to fix this...

    install.packages("fGarch")
    install.packages("rugarch")
    install.packages("rmgarch")
    library(fGarch)
    library(rmgarch)
    library(rugarch)
    library(tseries)
    library(zoo)

    #Daten runterladen
    ibm <- get.hist.quote(instrument = "DB",  start = "2005-11-21",
                  quote = "AdjClose")
    sys<- get.hist.quote(instrument = "^STOXX50E",  start = "2005-11-21",
                 quote = "AdjClose")

    #Returns
    retibm<-diff(log(ibm))
    retsys<-diff(log(sys))

    # univariate normal GARCH(1,1) for each series
    garch11.spec = ugarchspec(mean.model = list(armaOrder = c(0,0)), 
                      variance.model = list(garchOrder = c(1,1), 
                                            model = "sGARCH"), 
                      distribution.model = "norm")

    # dcc specification - GARCH(1,1) for conditional correlations
    dcc.garch11.spec = dccspec(uspec = multispec( replicate(2, garch11.spec) ), 
                       dccOrder = c(1,1), 
                       distribution = "mvnorm")
    dcc.garch11.spec

    MSFT.GSPC.ret = merge(retsys,retibm)
    plot(MSFT.GSPC.ret)
    dcc.fit = dccfit(dcc.garch11.spec, data = MSFT.GSPC.ret)

I wasn't sure if this subforum was the right one, but it seemed more appropiate than the quantitative finance forum. If it is the wrong one, I apologize.

Upvotes: 3

Views: 3368

Answers (1)

Julius Vainora
Julius Vainora

Reputation: 48241

The problem is caused by a somewhat nonstandard behaviour of merge. When merging by column names, we have all = FALSE by default. However, when merging by row names, as in this case, it seems that we have all = TRUE and, hence, MSFT.GSPC.ret contains NA values.

So, using either

MSFT.GSPC.ret <- merge(retsys, retibm, all = FALSE)

or

dcc.fit <- dccfit(dcc.garch11.spec, data = na.omit(MSFT.GSPC.ret))

solves the problem.

Upvotes: 6

Related Questions