2

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

Vasfed
  • 18,013
  • 10
  • 47
  • 53
  • Please include the code that produces the error, as well as the packages you are using. If possible also include with test dataset the produces the error so people can replicate your problem. – lmo Apr 11 '16 at 17:45
  • I am using the package rugarch The code that produces the error is as follows: 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 = FALSE, archex = FALSE), distribution.model = "norm", start.pars = list(), fixed.pars = list()) – Sotima Etienne Apr 12 '16 at 14:47
  • It's a good idea to post this information directly in your question rather than in the comments section. – lmo Apr 12 '16 at 14:49
  • Thanks Vasfed My data covers the period of Jully 1990 to January 2016. If you look in the ugach specification, that I share in my previous comment, I included an external variable dummy variable "dum" (that covers the period Jully 2008 to January 2016) which is constructed as follows : dum=as.numeric(time(pr)>=2008.500) I am not sure why using that dummy in the ugarch specification gives me that error – Sotima Etienne Apr 12 '16 at 15:13
  • 1
    I finally fixed it: I just needed to make sure that my dummy variable was specified as a matrix. I am trying to figure out why this solution works. Thanks for all those who tried to help – Sotima Etienne Apr 13 '16 at 21:51

1 Answers1

0

Try

external.regressors = data.matrix(dum)

Instead of

external.regressors = dum

It worked for me.

Martin Gal
  • 16,640
  • 5
  • 21
  • 39