[R-SIG-Finance] Vector autoregression with Newey-West standard errors
Achim Zeileis
Achim.Zeileis at wu-wien.ac.at
Tue Jun 9 19:08:32 CEST 2009
On Tue, 9 Jun 2009, Liviu Andronic wrote:
> Dear all,
>
> I'm currently fitting vector autoregression using VAR() from package
> `vars'. It estimates VAR by using OLS, and by default it provides
> "naive" standard errors (not HC and not HAC).
The standard HAC approach only works if you have no lagged dependent
variables among the regressors. The idea is that either (1) you don't
model the autoregressive structure at all and just capture it in the
correction of the standard errors or (2) you model the autoregressive
structure by the model and need no correction of the standard errors.
> However, I would like to obtain Heteroskedasticity-Autocorrelation
> Consistent standard errors using NeweyWest() from package `sandwich',
> which handles principally `lm' and `glm' objects.
The approach in "sandwich" is fully object-oriented, see
vignette("sandwich-OOP", package = "sandwich")
> I noticed that the
> VAR() returns an object of class `varest', which contains a list of
> fitted `lm' objects. So I tried to apply NeweyWest() to individual
> `lm' components of `varest', unsuccessfully.
>
>> class(temp)
> [1] "varest"
>> class(temp$varresult$e)
> [1] "lm"
>> temp.lm <- temp$varresult$e
>> class(temp.lm)
> [1] "lm"
>> require(sandwich)
>> NeweyWest(temp.lm)
> Error in AA %*% t(X) : requires numeric matrix/vector arguments
> In addition: Warning message:
> In ar.ols(x, aic = aic, order.max = order.max, na.action = na.action, :
> model order: 1singularities in the computation of the projection
> matrixresults are only valid up to model order0
>> vcovHAC(temp.lm)
> Error in bread. %*% meat. : non-conformable arguments
>
>
> I would have expected the above to have worked. For "standard" `lm'
> objects, I never had any such issues:
That's because the internal structure of "varest" objects does not contain
`standard' "lm" objects... The constant/intercept is special cased and
hence
bread(temp$varresult$e)
meatHAC(temp$varresult$e)
are non-conformable. The warning from ar.ols() is thrown because
prewhitening is used by default which really doesn't make any sense for
VARs.
To adapt "sandwich" to a new model class, bread() and estfun() methods
need to be supplied (see the vignette above). This wouldn't be very
difficult for "varest" objects, but as pointed out above, I don't think it
is very useful.
Best,
Z
More information about the R-SIG-Finance
mailing list