<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
Hi,</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
I am currently trying to do a multivariate forecast using the DCCroll function for a portfolio of 15 stocks (Forecast length should be 400). I tried it two times (reduced the forecast length in the second run): After around 200-260 times the function broke
 down due to the fact that the "system is computationally singular". I understand that this results from linearly dependent columns , i.e. strongly correlated variables or more variables than observations (I have 1216 observations per stock and 15 stocks. So
 this should not be the problem, I assume.)</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
When I checked my return correlationmatrix and my realized volatilities correlation matrix, there were no indications that I face issues such as strong correlation.</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
Stock Return Correlation Matrix:</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<img tabindex="-1" size="25984" style="margin: 0px; max-width: 100%; cursor: pointer; height: auto" data-outlook-trace="F:1|T:1" src="cid:ac918639-6cc7-4a2d-8c0b-e239e374a1ba"><br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
Stock RV Correlation Matrix:</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<img tabindex="-1" size="25424" style="margin: 0px; max-width: 100%; cursor: pointer; height: auto" data-outlook-trace="F:1|T:1" src="cid:9e25bd6c-6468-4444-90a2-ac12d38b0319"><br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
Also what seems odd to me is that the forecast can be done  for the first 200-260 days and then it breaks down, as this suggests that the majority of the forecasting process is working. </div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
Further I already forecast the univariate realGARCH time series with the same stocks before. So I know that the first stage of the DCC estimation should work.</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
What are possible solution strategies that I can follow?</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
Best, </div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
Asse</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
This is the code I am using: </div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<b>Creating the return and rv matrix:</b></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<b><br>
</b></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
stocks.comp <- list()<br>
<div style="margin: 0px">for (i in 1:length(ticker_names))<br>
</div>
<div style="margin: 0px">{<br>
</div>
<div style="margin: 0px">  stocks.comp[[i]]<-subset(data_sentivola, data_sentivola[,"ticker"] == paste(ticker_names[i]))<br>
</div>
<div style="margin: 0px">}<br>
</div>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px">stocks.comp <- do.call(cbind, stocks.comp)<br>
</div>
<b><span style="margin: 0px"></span></b><br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<span style="margin: 0px">stocks.return<-as.data.frame(lapply("return", function(nm)<br>
</span>
<div style="margin: 0px">  stocks.comp[, colnames(stocks.comp) == nm, drop = FALSE])[[1]])<br>
</div>
<div style="margin: 0px">colnames(stocks.return)<-ticker_names<br>
</div>
<div style="margin: 0px">stocks.return<-as.xts(stocks.return, order.by=as.POSIXct(unique(data_sentivola[,"Date"]), format = "%m/%d/%Y"))<br>
</div>
<div style="margin: 0px">stocks.return <- stocks.return["2012-03-5/2016-12-30"]<br>
</div>
<div style="margin: 0px">#realized volatility<br>
</div>
<div style="margin: 0px">stocks.rv<-as.data.frame(lapply("rv", function(nm)<br>
</div>
<div style="margin: 0px">  stocks.comp[, colnames(stocks.comp) == nm, drop = FALSE])[[1]])<br>
</div>
<div style="margin: 0px">colnames(stocks.rv)<-ticker_names<br>
</div>
<div style="margin: 0px">stocks.rv<-as.xts(stocks.rv, order.by=as.POSIXct(unique(data_sentivola[,"Date"]), format = "%m/%d/%Y"))<br>
</div>
<div style="margin: 0px">stocks.rv<-as.xts(as.matrix(stocks.rv), order.by=as.POSIXct(unique(data_sentivola[,"Date"]), format = "%m/%d/%Y"))<br>
</div>
<div style="margin: 0px">stocks.rv<- stocks.rv["2012-03-5/2016-12-30"]<br>
</div>
<span style="margin: 0px">stocks.rv<- sqrt(stocks.rv)</span><br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><br>
</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><b>This is a list of external regressors that I feed into the realGARCH spec:</b></span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<span style="margin: 0px">ext_reg <- list(ext_reg1,ext_reg2, ext_reg3, ext_reg4) (only used in the first stage of estimation, hence this should not be a problem as I already did the univariate fitting)<br>
</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><br>
</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><b>This creates the different specifications that I want to use for the univariate realGARCH in the first stage estimation: data_sentivola is the initial dataset</b></span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><span style="margin: 0px">spec.comp <- list()<br>
</span>
<div style="margin: 0px">for (m in 1:4) {<br>
</div>
<div style="margin: 0px">  for (i in 1:length(ticker_names))<br>
</div>
<div style="margin: 0px">  {<br>
</div>
<div style="margin: 0px">    data_sentivola_INT<-subset(data_sentivola, data_sentivola[,"ticker"] == paste(ticker_names[i]))<br>
</div>
<div style="margin: 0px">    xts_sentivola_ticker<- as.xts(data_sentivola_INT[,c("return","rv")], order.by=as.POSIXct(data_sentivola_INT[,"Date"], format = "%m/%d/%Y"))<br>
</div>
<div style="margin: 0px">    xts_sentivola_ticker <- xts_sentivola_ticker["2012-03-5/2016-12-30"]<br>
</div>
<div style="margin: 0px">   <br>
</div>
<div style="margin: 0px">    exter_reg <- subset(as.data.frame(ext_reg[[m]][,])<br>
</div>
<div style="margin: 0px">                        ,as.data.frame(ext_reg[[m]][,])[,"ticker"]==paste(ticker_names[i]))<br>
</div>
<div style="margin: 0px">   <br>
</div>
<div style="margin: 0px">    xts_external_regressors <- exter_reg[,2:ncol(exter_reg)]<br>
</div>
<div style="margin: 0px">    xts_external_regressors <- as.xts(xts_external_regressors,<br>
</div>
<div style="margin: 0px">                                      order.by=as.POSIXct(data_sentivola_INT[,"Date"], format = "%m/%d/%Y"))<br>
</div>
<div style="margin: 0px">    xts_external_regressors <-xts_external_regressors["2012-03-5/2016-12-30"]<br>
</div>
<div style="margin: 0px">    </div>
<div style="margin: 0px">    spec.comp[[(m-1)*15 + i]] <- ugarchspec(mean.model = list(armaOrder = c(1,0), include.mean = FALSE),<br>
</div>
<div style="margin: 0px">                             variance.model = list(model = 'realGARCH', garchOrder = c(1,1)<br>
</div>
<div style="margin: 0px">                                                   , external.regressors = xts_external_regressors)<br>
</div>
<div style="margin: 0px">                             , distribution.model = "sstd")<br>
</div>
<div style="margin: 0px">  }<br>
</div>
<span style="margin: 0px">}</span><br>
</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><br>
</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><span style="margin: 0px"><b>This runs the DCCroll:</b></span></span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: black; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><span style="margin: 0px">#run DCC<br>
</span>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px">dccroll.comp <- list()<br>
</div>
<div style="margin: 0px">uspec.n = multispec(spec.comp[1:15])<br>
</div>
<div style="margin: 0px">dccspec.n = dccspec(uspec.n,  dccOrder = c(1,1), model = "DCC", distribution = "mvnorm")<br>
</div>
<div style="margin: 0px">cl = makePSOCKcluster(7)<br>
</div>
<div style="margin: 0px">clusterExport(cl,as.list(unique(c(ls(.GlobalEnv),ls(environment())))),envir=environment())<br>
</div>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px">dccroll.comp[[1]]= dccroll(dccspec.n, data = stocks.return, n.ahead = 1, forecast.length = 285,<br>
</div>
<div style="margin: 0px">        solver = "solnp", refit.every = 1, refit.window = "moving",<br>
</div>
<div style="margin: 0px">        realizedVol = stocks.rv,<br>
</div>
<div style="margin: 0px">        cluster = cl,<br>
</div>
<div style="margin: 0px">        save.fit = TRUE,<br>
</div>
<div style="margin: 0px">        save.wdir = "C:/Users/asser/Documents/Master Thesis/R-Code/FitFolder")<br>
</div>
<span style="margin: 0px">stopCluster(cl)</span></span></div>
<br>
</div>
</body>
</html>