[R-SIG-Finance] Vector autoregression with Newey-West standard errors
Achim.Zeileis at wu-wien.ac.at
Tue Jun 9 19:47:58 CEST 2009
On Tue, 9 Jun 2009, Matthieu Stigler wrote:
> I wasn't aware of the fact that HAC is not designed for time series model
> (thanks Achim!). But nevertheless I think that HC is still usable, well at
> least I saw it in couple of papers dealing with times series.
> So if you still want to use an HC, two solutions:
> A solve the problem (workaround):
No, there is no "problem" at least not from the "sandwich" point of view.
If you want "sandwich" to cooperate with "varest" objects, you just need
to provide the appropriate methods (essentially, bread() and estfun()) for
"varest" objects. This is a clean and non-invasive solution and not very
difficult to implement given that all this is OLS.
> The problem is actually in an inconsistency in VAR() when working with
> type=const or both, as in your case.
> See from your example:
> to get it working you should replace:
> attr(equation[[colnames(yend)[i]]]$terms, "intercept") <- 1
> attr(equation[[colnames(yend)[i]]]$terms, "intercept") <- NULL
> I'll see with Bernhard how to update it.
> B: I was working myself on a Eicker -White cov-mat and implemented it in a
> package (dev version of tsDyn) that also contains VAR, so you could use this
Thanks for the pointer. My feeling would be that if you provided
appropriate methods, you would get the HC stuff (or Eicker-White or
Eicker-Huber-White or White or HCCM or sandwich or ...) for free from
As I pointed out in my previous my, this is all documented in
vignette("sandwich-OOP", package = "sandwich")
> Achim Zeileis a écrit :
>> 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.
>>>  "varest"
>>>  "lm"
>>>> temp.lm <- temp$varresult$e
>>>  "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
>>> 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
>> are non-conformable. The warning from ar.ols() is thrown because
>> prewhitening is used by default which really doesn't make any sense for
>> 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
>> R-SIG-Finance at stat.math.ethz.ch mailing list
>> -- Subscriber-posting only.
>> -- If you want to post, subscribe first.
More information about the R-SIG-Finance