a problem with external regressors in rugarch
Alec, The ugarchfit method calls R's arima in order to quickly calculate a set of starting values prior to the joint ARMA-GARCH estimation. From arima's documentation: "If am xreg term is included, a linear regression (with a constant term if include.mean is true and there is no differencing) is fitted with an ARMA model for the error term" You've included: 1. An intercept (matrix of 1's)...this is how 'include.mean' in arima routine is interpreted. 2. All the days of the week (X) This results in perfect multicollinearity, which means that it is not possible to invert the matrix and solve the problem (which is why leaving one out works). This is typically known as the "dummy variable trap". Therefore: 1. Leave one (day) out 2. Pass a demeaned dataset and set include.mean=FALSE -Alexios
On 04/10/2013 03:01, Alec Schmidt wrote:
Hi everyone,
I'm struggling with adding external regressors X to arma+garch model using
the following script:
spec1121ex = ugarchspec(variance.model = list(model = "sGARCH", garchOrder
= c(2,1)),
mean.model = list(armaOrder = c(1,1), include.mean =
TRUE, external.regressors = X),
distribution.model = "std")
fit1121ex<-ugarchfit(data=rt[,1], spec=spec1121ex)
The regressor matrix X (currently) has the following form:
head(X) [,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 1
[2,] 1 0 0 0 0
[3,] 0 1 0 0 0
[4,] 0 0 1 0 0
[5,] 0 0 0 1 0
[6,] 0 0 0 0 1
When I run ugarchfit, I get an error:
Error in optim(init[mask], armaCSS, method = optim.method, hessian = TRUE, :
non-finite value supplied by optim
I make X from the table rtn
head(rtn) SPY Mon Tue Wed Thu Fri
2009-01-05 -0.001189061 1 0 0 0 0 2009-01-06 0.006640603 0 1 0 0 0 2009-01-07 -0.030479920 0 0 1 0 0 2009-01-08 0.004134247 0 0 0 1 0 2009-01-09 -0.021711980 0 0 0 0 1 2009-01-12 -0.024224590 1 0 0 0 0
X<-matrix(cbind(rtn[,2], rtn[,3], rtn[,4], rtn[,5], rtn[,6]), ncol=5)
Surprisingly sript runs fine if I choose ncol<5, e.g.
X<-matrix(cbind(rtn[,3], rtn[,4], rtn[,5], rtn[,6]), ncol=4)
or
X<-matrix(cbind(rtn[,2], rtn[,3], rtn[,4], rtn[,5]), ncol=4)
Thanks a lot,