문제

Update -- I closed this question and posted on crossvalidated.com.

I have found some good information on using the sandwich package and the NeweyWest() function to find heteroskedastic autocorrelation consistent (HAC) standard errors.

But NeweyWest() only takes lm objects.

> library(sandwich)
> NeweyWest(rnorm(100))
Error in UseMethod("estfun") : 
  no applicable method for 'estfun' applied to an object of class "c('double', 'numeric')"
> 

I frequently get vectors of returns unassociated with a linear regression for which I would like to find HAC standard errors. Any ideas? Should I write my own? Thanks!

도움이 되었습니까?

해결책

There's been a slight misunderstanding. I was thinking in terms of residuals, but what you asked is the standard error of the mean. That's easily obtained by modelling your vector against the intercept, or :

NeweyWest(lm(rnorm(100)~1))

For the standard deviation :

x <- rnorm(100)
NeweyWest(lm(x~1))*length(x)

Sorry for the misunderstanding, my bad.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top