0

I have a model which takes time series stock return data and categorises by the size of the return. The sizes of the categories are defined by number of standard deviations. I currently use the cut function to do this, my code is:

Division <- cut(return, br=c(min(return),-2*sd(return),-1*sd(return),-0.5*sd(return),0*sd(return),0.5*sd(return),1*sd(return),2*sd(return),max(return)))

This works fine and everything seems ok. So the next thing I'd like to do is treat these divisions as dummy variables in an EGARCH model. I simply thought of specifying in the normal way but this does not work. The code I use is:

spec = ugarchspec(variance.model = list(model = "eGARCH", garchOrder = c(2,2)), mean.model = list(armaOrder = c(0,0), include.mean = TRUE))

fit = ugarchfit(spec = spec, data = Division)

The error I get is:

Error in if (mean(data) == 0) { : missing value where TRUE/FALSE needed

Any help on what I am trying to do would be appreciated.

  • The error means you have `NA` in Division. Why are you doing that kind of modeling? I suspect ugarchfit will take your "categories" as continuous variable. If that is the case the results will be misleading. – Robert Jul 12 '15 at 11:58

1 Answers1

0

One way to pass the error is including the min in the category:

Division <- cut(return, br=c(min(return)*1.01,-2*sd(return),-1*sd(return),-0.5*sd(return),0*sd(return),0.5*sd(return),1*sd(return),2*sd(return),max(return)*1.01))
Robert
  • 5,038
  • 1
  • 25
  • 43