[R] VAR with HAC

Pfaff, Bernhard Dr. Bernhard_Pfaff at fra.invesco.com
Thu Feb 17 17:32:42 CET 2011


Hello Marta,
 
arrg, sorry, I have not carefully enough read your message. Well, if you follow the cited thread further down, you will find: 
(and hereby directly quoting from: https://stat.ethz.ch/pipermail/r-sig-finance/2009q2/004274.html) 

<<snip>> 
On Tue, 9 Jun 2009, Matthieu Stigler wrote:

> 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):

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.
<<snip>>
 
and further down in this reply, Achim is referring you to the package's vignette:

<<snip>> 
vignette("sandwich-OOP", package = "sandwich")
<<snip>>

Best,
Bernhard
 
 
 
 


________________________________

	Von: Marta Lachowska [mailto:Marta at upjohn.org] 
	Gesendet: Donnerstag, 17. Februar 2011 17:01
	An: Pfaff, Bernhard Dr.; r-help at r-project.org
	Betreff: Re: AW: [R] VAR with HAC
	
	
	Thank you for your hint!
	
	I see that there was a thread discussing implementation of what I wanted to do (Newey-West standard errors in a VAR context), but that there is a conflict due to how the type = "const" is defined in the VAR command: https://stat.ethz.ch/pipermail/r-sig-finance/2009q2/004272.html that appears not to be resolved. 
	 
	Best, 
	 
	Marta
	 
	
	>>> "Pfaff, Bernhard Dr." <Bernhard_Pfaff at fra.invesco.com> 2/17/2011 4:31 AM >>>
	Hello Marta,
	
	have you read ?coeftest and ? VAR carefully enough? The function does expect a lm/glm object for x as argument. Hence, the following does work:
	
	library(vars)
	data(Canada)
	myvar <- VAR(Canada, p = 2, type = "const")
	lapply(myvar$varresult, coeftest)
	
	Best,
	Bernhard 
	
	> -----Ursprüngliche Nachricht-----
	> Von: r-help-bounces at r-project.org 
	> [mailto:r-help-bounces at r-project.org] Im Auftrag von Marta Lachowska
	> Gesendet: Mittwoch, 16. Februar 2011 16:50
	> An: r-help at r-project.org
	> Betreff: [R] VAR with HAC
	> 
	> 
	> Hello,
	> I would like to estimate a VAR model with HAC corrected 
	> standard errors. I tried to do this by using the sandwich 
	> package, for example: 
	>  
	> > library(vars)
	> > data(Canada)
	> > myvar = VAR(Canada, p = 2, type = "const") coeftest(myvar, vcov = 
	> > vcovHAC)
	> Error in umat - res : non-conformable arrays
	>  
	> Which suggests that this function is not compatible with the 
	> VAR command. Has anyone tried to modify the code to get HAC 
	> corrected standard errors with VAR? Any suggestions are welcome. 
	>  
	> Thank you. 
	>  
	> Marta
	> 
	> [[alternative HTML version deleted]]
	> 
	> ______________________________________________
	> R-help at r-project.org mailing list
	> https://stat.ethz.ch/mailman/listinfo/r-help
	> PLEASE do read the posting guide 
	> http://www.R-project.org/posting-guide.html
	> and provide commented, minimal, self-contained, reproducible code.
	> 
	*****************************************************************
	Confidentiality Note: The information contained in this message,
	and any attachments, may contain confidential and/or privileged
	material. It is intended solely for the person(s) or entity to
	which it is addressed. Any review, retransmission, dissemination,
	or taking of any action in reliance upon this information by
	persons or entities other than the intended recipient(s) is
	prohibited. If you received this in error, please contact the
	sender and delete the material from any computer.
	*****************************************************************
	
	



More information about the R-help mailing list