Djpengo
Djpengo

Reputation: 388

Rugarch external regressors in mean/variance

What is the proper formatting of the variable provided to external.regressors = ..? My data looks like this:

           regressor     dependent
2008-01-04         3  0.0243990059
2008-01-08         3  0.0057341705
2008-01-09         3  0.0047333058
2008-01-10         3  0.0003631741
2008-01-11         3 -0.0019384547
2008-01-14         3 -0.0016992358

I am using the Rugarch package to estimate an ARMA(2,0)-GARCH(1,1) process with an external regressor in both the mean and varince. As (of course) I am dealing with the Time series, my data is formatted as zoo.

If I provide the zoo variable as here:

garch.spec <- ugarchspec(
  variance.model = list(model="sGARCH", garchOrder = c(1,1), 
external.regressors = regressor),
  mean.model = list(armaOrder = c(2, 0), include.mean = TRUE),
)

I get the following error:

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

If I, instead specify the regressors as external.regressors = as.matrix(coredata(regressor)) The error doesn't show up and I am able to estimate the model with

ugarchfit(garch.spec, dependent)

Where dependent is a zoo variable. The results, however, don't make sense.

I believe I don't get how the datatypes work here. I believe garch should be able to work with zoo files and have read the package description but did not find anything helpful. Any suggestions, please?

Upvotes: 2

Views: 4352

Answers (1)

Julius Vainora
Julius Vainora

Reputation: 48211

In ?ugarchspec we find

external.regressors - A matrix object containing the external regressors to include in the variance equation with as many rows as will be included in the data (which is passed in the fit function).

So, if df contains your example data, using

garch.spec <- ugarchspec(
  variance.model = list(model = "sGARCH", garchOrder = c(1, 1), external.regressors = matrix(df$regressor)),
  mean.model = list(armaOrder = c(2, 0), include.mean = TRUE))
ugarchfit(garch.spec, df$dependent)

works. That is the correct usage of external.regressors and questions on how satisfactory the results are most likely are related to methodology and more suitable for Stats.SE.

Upvotes: 1

Related Questions