Tommaso Ferrari
2019-Aug-22 12:55 UTC
[R] DCC model estimation with t-Student distribution rmgarch
Dear all, I was analyzing and implementing the DCC model (Dynamic Conditional Correlation) for the one-day forecast calculation of the variance-covariance matrix of a system consisting of, approximately, 30 stocks. For each title I consider a historical series of logarithmic daily returns of 250 samples. In particular, I was interested in the simulation of this model using the t-Student distribution. In this regard I was using the "rugarch" and "rmgarch" packages. According to the examples found in the literature, I run my analysis in the following way: 1) specification of the univariate garch model for each stock passing the number of degrees of freedom of the t-Student distribution as input (parameter mshape) 2) multifitting of the univariate garch models 3) specification of DCC model with a multivariate t-Student distribution (degrees of freedom are not passed as input, in this case) 4) fitting of the DCC model 5) variance-covariance matrix forecasting I give an example of the code I'm running (qxts is the time series data, mshape is the number of degrees of freedom): # GARCH(1,1) specification garch11.spec = ugarchspec(mean.model = list(armaOrder = c(0, 0)), variance.model = list(garchOrder = c(1, 1), model = "sGARCH"), distribution.model = "std", fixed.pars = list(shape = mshape)) # replicate Garch(1,1) spec for both time series uspec = multispec(replicate(ncol(qxts), garch11.spec)) # Fit Garch models: hybrid -> in case of non convergence, all solvers are used multf = multifit(uspec, qxts, solver = "hybrid", fit.control = list(scale 1)) # Dcc model spec dcc.garch11.spec = dccspec(uspec = uspec, dccOrder = c(1, 1), distribution = "mvt", model = "DCC") # Fitting parameters of DCC dcc.fit = dccfit(dcc.garch11.spec, qxts, fit = multf, fit.control list(scale = TRUE)) # dcc.fit = dccfit(dcc.garch11.spec, qxts, fit = multf, fit.control list(scale = 1)) # Forecast dcc.fcst = dccforecast(dcc.fit, n.ahead = 1) varmat = rcov(dcc.fcst)[[dt_cov]][,, 1] However, using a number of degrees of freedom of 2.5, I get the following error: Error in solve.default(A) : system is computationally singular: reciprocal condition number = 1.19994e-18 If, for example, I change the degrees of freedom from 2.5 to 2.6, the error no longer appears. I would like to know if there is a way to allow the calculation to be performed even using a number of degrees of freedom equals to 2.5, as I cannot find any reference in the literature that addresses this problem. I also tried the following idea. I don't pass the number of degrees of freedom as input, but I make sure that, for each title, the number of degrees of freedom is calculated internally by the function multifit. Obviously, I get different degrees of freedom depending on the stock considered. In this case, however, passing the calculated parameters of the multifit to the dccfunction, leads to the following error: 'data' must be of a vector type, was 'NULL' even if the data sample I pass as input contains no null value. I would like to know if these problems are due solely to the numerical values of the data passed as input or if I am conceptually wrong in the implementation of the method. Thanks to all [[alternative HTML version deleted]]
Jeff Newmiller
2019-Aug-23 02:06 UTC
[R] DCC model estimation with t-Student distribution rmgarch
This seems squarely in the "asking for statistical expertise" area, rather than the "how do I make R implement this theory I understand" area, so it is off topic on this mailing list. You might be in better company on Stack Exchange. On August 22, 2019 5:55:43 AM PDT, Tommaso Ferrari <tomferri93 at gmail.com> wrote:>Dear all, >I was analyzing and implementing the DCC model (Dynamic Conditional >Correlation) for the one-day forecast calculation of the >variance-covariance matrix of a system consisting of, approximately, >30 stocks. For each title I consider a historical series of logarithmic >daily returns of 250 samples. >In particular, I was interested in the simulation of this model using >the >t-Student distribution. >In this regard I was using the "rugarch" and "rmgarch" packages. >According to the examples found in the literature, I run my analysis in >the >following way: > >1) specification of the univariate garch model for each stock passing >the >number of degrees of freedom of the t-Student distribution as input >(parameter mshape) > >2) multifitting of the univariate garch models > >3) specification of DCC model with a multivariate t-Student >distribution >(degrees of freedom are not passed as input, in this case) > >4) fitting of the DCC model > >5) variance-covariance matrix forecasting > >I give an example of the code I'm running (qxts is the time series >data, >mshape is the number of degrees of freedom): > ># GARCH(1,1) specification >garch11.spec = ugarchspec(mean.model = list(armaOrder = c(0, 0)), >variance.model = list(garchOrder = c(1, 1), model = "sGARCH"), >distribution.model = "std", fixed.pars = list(shape = mshape)) ># replicate Garch(1,1) spec for both time series >uspec = multispec(replicate(ncol(qxts), garch11.spec)) ># Fit Garch models: hybrid -> in case of non convergence, all solvers >are >used >multf = multifit(uspec, qxts, solver = "hybrid", fit.control >list(scale >1)) ># Dcc model spec >dcc.garch11.spec = dccspec(uspec = uspec, dccOrder = c(1, 1), >distribution >= "mvt", model = "DCC") ># Fitting parameters of DCC >dcc.fit = dccfit(dcc.garch11.spec, qxts, fit = multf, fit.control >list(scale = TRUE)) ># dcc.fit = dccfit(dcc.garch11.spec, qxts, fit = multf, fit.control >list(scale = 1)) ># Forecast >dcc.fcst = dccforecast(dcc.fit, n.ahead = 1) >varmat = rcov(dcc.fcst)[[dt_cov]][,, 1] > >However, using a number of degrees of freedom of 2.5, I get the >following >error: > >Error in solve.default(A) : system is computationally singular: >reciprocal >condition number = 1.19994e-18 > >If, for example, I change the degrees of freedom from 2.5 to 2.6, the >error >no longer appears. >I would like to know if there is a way to allow the calculation to be >performed even using a number of degrees of freedom equals to 2.5, as I >cannot find any reference in the literature that addresses this >problem. > >I also tried the following idea. >I don't pass the number of degrees of freedom as input, but I make sure >that, for each title, the number of degrees of freedom is calculated >internally by the function multifit. >Obviously, I get different degrees of freedom depending on the stock >considered. >In this case, however, passing the calculated parameters of the >multifit to >the dccfunction, leads to the following error: >'data' must be of a vector type, was 'NULL' >even if the data sample I pass as input contains no null value. > >I would like to know if these problems are due solely to the numerical >values of the data passed as input or if I am conceptually wrong in the >implementation of the method. > >Thanks to all > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.-- Sent from my phone. Please excuse my brevity.