There are several problems with your code.
- This is not a
reprex
. You have not included the calls to the libraries. Please go through the following link. A reproducible example helps others to help you.
-
As I said earlier, you don't need
matrix(cbind(rIBM,rBP), ncol = 2)
. Ifcbind(rIBM, rBP)
is good enough, why will you do the extra typing? Moreover, you confused with the brackets and your code read thedistribution.model
,start.pars
andfixed.pars
undermean.model
, which is not the case. -
names(rx) <- c("rIBM", "rBP", "GOOG", "rt")
would have been enough. -
Please format your code before uploading. It helps.
I modified your code and got the following. I don't have knowledge on DCC models, so can't interpret the results or can't say whether it's right or wrong. You'll have to judge that yourself.
library(quantmod)
#> Loading required package: xts
#> Loading required package: zoo
#>
#> Attaching package: 'zoo'
#> The following objects are masked from 'package:base':
#>
#> as.Date, as.Date.numeric
#> Loading required package: TTR
#> Version 0.4-0 included new data defaults. See ?getSymbols.
library(rmgarch)
#> Loading required package: rugarch
#> Loading required package: parallel
#>
#> Attaching package: 'rugarch'
#> The following object is masked from 'package:stats':
#>
#> sigma
#>
#> Attaching package: 'rmgarch'
#> The following objects are masked from 'package:xts':
#>
#> first, last
startDate <- as.Date("2007-01-03")
endDate <- as.Date("2019-02-28")
getSymbols("IBM", from = startDate, to = endDate)
#> 'getSymbols' currently uses auto.assign=TRUE by default, but will
#> use auto.assign=FALSE in 0.5-0. You will still be able to use
#> 'loadSymbols' to automatically load data. getOption("getSymbols.env")
#> and getOption("getSymbols.auto.assign") will still be checked for
#> alternate defaults.
#>
#> This message is shown once per session and may be disabled by setting
#> options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
#>
#> WARNING: There have been significant changes to Yahoo Finance data.
#> Please see the Warning section of '?getSymbols.yahoo' for details.
#>
#> This message is shown once per session and may be disabled by setting
#> options("getSymbols.yahoo.warning"=FALSE).
#> [1] "IBM"
getSymbols("GOOG", from = startDate, to = endDate)
#> [1] "GOOG"
getSymbols("BP", from = startDate, to = endDate)
#> [1] "BP"
getSymbols("T", from = startDate, to = endDate)
#> [1] "T"
head(IBM)
#> IBM.Open IBM.High IBM.Low IBM.Close IBM.Volume IBM.Adjusted
#> 2007-01-03 97.18 98.40 96.26 97.27 9196800 70.11556
#> 2007-01-04 97.25 98.79 96.88 98.31 10524500 70.86525
#> 2007-01-05 97.60 97.95 96.91 97.42 7221300 70.22369
#> 2007-01-08 98.50 99.50 98.35 98.90 10340000 71.29050
#> 2007-01-09 99.08 100.33 99.07 100.07 11108200 72.13392
#> 2007-01-10 98.50 99.05 97.93 98.89 8744800 71.28333
str(IBM)
#> An 'xts' object on 2007-01-03/2019-02-27 containing:
#> Data: num [1:3059, 1:6] 97.2 97.2 97.6 98.5 99.1 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:6] "IBM.Open" "IBM.High" "IBM.Low" "IBM.Close" ...
#> Indexed by objects of class: [Date] TZ: UTC
#> xts Attributes:
#> List of 2
#> $ src : chr "yahoo"
#> $ updated: POSIXct[1:1], format: "2019-03-12 18:45:37"
chartSeries(IBM)
rIBM <- dailyReturn(IBM)
rBP <- dailyReturn(BP)
rGOOG <- dailyReturn(GOOG)
rt <- dailyReturn(T)
chartSeries(rIBM)
rx <- data.frame(rIBM, rBP, rGOOG, rt)
names(rx) <- c("rIBM", "rBP", "GOOG", "rt")
nspec <- ugarchspec(variance.model = list(model = "sGARCH",
garchOrder = c(1, 1),
submodel = NULL,
external.regressors = matrix(cbind(rIBM, rBP), ncol = 2),
variance.targeting = FALSE),
mean.model = list(armaOrder = c(0, 0),
external.regressors = cbind(rIBM, rBP)),
distribution.model = "norm",
start.pars = list(),
fixed.pars = list())
nspec2 <- multispec(replicate(4, nspec))
ncl1 <- makePSOCKcluster(4)
nmultft <- multifit(nspec2, rx, cluster = ncl1)
(nspecmv <- dccspec(uspec = nspec2,
dccOrder = c(1, 1),
external.regressors = cbind(rIBM, rBP),
distribution = 'mvnorm'))
#>
#> *------------------------------*
#> * DCC GARCH Spec *
#> *------------------------------*
#> Model : DCC(1,1)
#> Estimation : 2-step
#> Distribution : mvnorm
#> No. Parameters : 40
#> No. Series : 4
Hope this helps.