Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent

#### CHAPTER 2 MULTIVARIATE GARCH MODEL ####
###Load required packages for running Multivariate model 

I'm trying to estimate the DCC model but I have this problem can someone help me please?

install.packages(c("quantmod","rugarch","rmgarch"))   # only needed in case you have not yet installed these packages non mi ricordo per sicurezza installa tuttooooooo

library(quantmod)
library(rugarch)
library(rmgarch)
install.packages("mgarchBEKK")
library(mgarchBEKK)
# important DCC ESTIMATION
install.packages("ccgrach")
library(ccgarch)


setDefaults(getSymbols,src='yahoo')

startDate = as.Date("2006-01-04") #Specify period of time we are interested in
endDate = as.Date("2022-12-23")
getSymbols("^GDAXI", from = startDate, to = endDate)

getSymbols("^SSMI", from = startDate, to = endDate)

getSymbols("^FCHI", from = startDate, to = endDate)

getSymbols("^FTAS", from = startDate, to = endDate)

GDAXI -> TS
names(TS) <- c("Open","High","Low","Close","Volume","Adjusted")
gdaxi<-TS$Adjusted
length(gdaxi)

SSMI -> TS1
names(TS1) <- c("Open","High","Low","Close","Volume","Adjusted")
ssmi<-TS1$Adjusted
length(gdaxi)


FCHI -> TS2
names(TS2) <- c("Open","High","Low","Close","Volume","Adjusted")
fchi<-TS2$Adjusted
length(fchi)

FTAS -> TS3
names(TS3) <- c("Open","High","Low","Close","Volume","Adjusted")
ftas<-TS3$Adjusted
length(ftas)

data<-cbind(log(gdaxi),log(fchi),log(ftas), log(ssmi))
colnames(data)=c("GDAXI", "FCHI","FTAS", "SSMI")
View(data)
sum(is.na(data))
data<-na.omit(data)
plot(data)

data<-cbind(diff(log(gdaxi)),diff(log(fchi)),diff(log(ftas)),diff(log(ssmi)))
colnames(data)=c("GDAXI", "FCHI","FTAS", "SSMI")
View(data)
sum(is.na(data))
data<-na.omit(data)
sum(is.na(data))

####DCC MODEL###

##### Specify DCC MODEL ### 
# 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(3,garch11.spec) ),
 dccOrder = c(1,1), 
 distribution = "mvnorm")
dcc.garch11.spec


###### ESTIMATE DCC MODEL ###
data1<-data.frame(data)
data<-as.data.frame(data)### NOT THE SAME lag 
str(data)
nrow(data)
# 4083
NROW(na.omit(data))
dim(data) 
nrow(GDAXI)#4234
nrow(FCHI)#4267
nrow(FTAS)#4215
nrow(SSMI)#4202
dcc.fit= dccfit(dcc.garch11.spec, data=data)
dcc.fit
class(dcc.fit)
slotNames(dcc.fit)
names(dcc.fit@mfit)
###### Estimate DCC Model######
names(dcc.fit@model)
dcc.fit
plot(dcc.fit)

#Make a plot selection (or 0 to exit): 
#Conditional Mean (vs Realized Returns)
#Conditional Sig ( mavs Realized Absolute Returns)
# Conditional Covariance
#Conditional Correlation
#EW Portfolio Plot with conditional density VaR limi

#####DCC Forecasts####
# 100-step ahead forecasts of conditional covariances
# and conditional correlations
dcc.fcst = dccforecast(dcc.fit, n.ahead =100)
class(dcc.fcst)
slotNames(dcc.fcst)
class(dcc.fcst@mforecast)
names(dcc.fcst@mforecast)
dcc.fcst
plot(dcc.fcst)
##BEKK MODEL##

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.