Copula-DCC-GARCH:rmgarch :: cgarchsim()和rmgarch :: varxforecast()

时间:2018-09-18 16:50:48

标签: r

require('rugarch')
require('rmgarch')
require('quantmod')
require('lubridate')

mbase <- getSymbols('JPY=X', from = today() %m-% years(1))
mbase <- cbind(Hi(mbase), Lo(mbase))

speclist <- filter_spec(mbase, .currency = 'JPY=X', .price_type = 'HL')
mspec <- multispec(speclist)

cSpec <- cgarchspec(
  mspec, VAR = .VAR, lag = 1, 
  lag.criterion = c('AIC', 'HQ', 'SC', 'FPE'), 
  external.regressors = NULL, #external.regressors = VAREXO, 
  dccOrder = c(1, 1), 
  distribution.model = list(
    copula = .dist.model, method = .model, transformation = .tram), 
  start.pars = list(), fixed.pars = list())

# question 1: cgarchsim()
fc1 <- cgarchsim(fit, n.sim = ..., m.sim = 1)

# question 2: p=?
fc2 <- varxforecast(X = mbase, Bcoef = fit@mfit$stdresid, p = 2, 
                    out.sample = 0, n.ahead = .ahead, n.roll = 0, 
                    mregfor = NULL)
#Error in Bcoef %*% t(Z) : non-conformable arguments

我有几个问题。

  1. 如何使用cgarchsim()
  2. p的作用是什么? Package ‘rmgarch’中的p = The number of autoregressive lags.

    a)我可以使用forecast::auto.arima(mbase)来获得滞后阶数arima(p,d,q)并检索p吗?

```

ldply(mbase, function(x) {
    forecast::auto.arima(x, seasonal=FALSE) %>% arimaorder
  })
#              .id p d q
#1     USDJPY.Open 1 1 1
#2     USDJPY.High 0 1 1
#3      USDJPY.Low 0 1 0
#4    USDJPY.Close 1 1 1
#5   USDJPY.Volume 0 0 0
#6 USDJPY.Adjusted 1 1 1

```

ldply(mbase, function(x) {
    forecast::auto.arima(x, seasonal=TRUE) %>% arimaorder
  })
#              .id p d q
#1     USDJPY.Open 1 1 1
#2     USDJPY.High 0 1 1
#3      USDJPY.Low 0 1 0
#4    USDJPY.Close 1 1 1
#5   USDJPY.Volume 0 0 0
#6 USDJPY.Adjusted 1 1 1

b)还是使用tseries::adf.test(mbase)来获取滞后顺序?

ldply(mbase, function(x) {
   tseries::adf.test(x, alternative = 'stationary')$parameter 
 })
#              .id Lag order
#1     USDJPY.Open        11
#2     USDJPY.High        11
#3      USDJPY.Low        11
#4    USDJPY.Close        11
#5   USDJPY.Volume        11
#6 USDJPY.Adjusted        11

c)如何使用varxforecast()

参考:

0 个答案:

没有答案