How to solve the singular matrix error in R?

I have tried to fit a dcc-garch model on 100 randome time series. To boost the performance, I have also used makePSOCKcluster Then I encountered the following error:

Error in solve.default(A) : 
  system is computationally singular: reciprocal condition number = 1.83252e-21

I have searched online, seems it is caused by a singular matrix. I have checked the determinant of my matrix, it is 0. So how could I solve this problem?

Here is my code, how can I improve it to fit the model?

start_time <- Sys.time()
#create randome 100 time series 
d <- data.frame(replicate(100,sample(0:1000,100,rep=TRUE)))
lst1 <- lapply(d, ts, start = 1909, end = 2009)

# convert t to matrix or data frame which is now a list to use in dcc.fit
df <- do.call(cbind,lst1)
####c <- cov(df)
####det(c)
# fit dcc-Grach
#install.packages("rmgarch")
library(parallel)
require(rmgarch)
garch100.spec <- ugarchspec(mean.model = list(armaOrder=c(0,0)),variance.model = list(garchOrder=c(1,1),model="sGARCH"),distribution.model = "std")
uspec = multispec(replicate(100,garch100.spec))
                  
                  
dcc.garch100.spec = dccspec(uspec = uspec,dccOrder = c(1,1),distribution = "mvt")

cl = makePSOCKcluster(4)
multf = multifit(uspec,df,cluster= cl)

#dcc.fit <- dccfit(dcc.garch100.spec, data=df)
#Trying to make use of multicore
dcc.fit <- dccfit(dcc.garch100.spec, data=df, fit.control = list(eval.se = TRUE), fit = multf, cluster = cl)

dcc.fit

stopCluster(cl)

end_time <- Sys.time()
print(end_time-start_time) 

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.