'Error in modelinc[15] = dim(variance.model$external.regressors)[2] : replacement has length zero

I am trying to fit a GARCH model with external regressors. My external regressors are composed of production data and a dummy that covers a certain period (07-2008 to 01-2016). When I specify my ugarch with the dummy I have an error message:

Error in modelinc[15] = dim(variance.model$external.regressors)[2] : replacement has length zero

But when the external regressors are without the dummy, I have no problem.

Below is the dummy specification:

model1dum=ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1), 
                                           submodel = NULL, external.regressors = dum, variance.targeting = FALSE), 
            mean.model = list(armaOrder = c(1, 1), include.mean = TRUE, archm = FALSE, 
                              archpow = 1, arfima = FALSE, external.regressors = dum, archex = FALSE), 
            distribution.model = "norm", start.pars = list(), fixed.pars = list())

Thanks for your help



Solution 1:[1]

Try

external.regressors = data.matrix(dum)

Instead of

external.regressors = dum

It worked for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Martin Gal