[R-SIG-Finance] Vector autoregression with Newey-West standard errors
Matthieu Stigler
matthieu.stigler at gmail.com
Tue Jun 9 19:34:56 CEST 2009
Hi
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):
The problem is actually in an inconsistency in VAR() when working with
type=const or both, as in your case.
See from your example:
model.matrix(a)
model.matrix(temp.lm)
to get it working you should replace:
attr(equation[[colnames(yend)[i]]]$terms, "intercept") <- 1
by:
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 one.
Bests
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.
>>
>>> 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
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
More information about the R-SIG-Finance
mailing list