在 R 中没有 lm 对象的情况下计算 Newey-West 标准误差
更新 - 我关闭了这个问题并 发布在 crossvalidated.com。
我发现了一些有关使用 sandwich
包和 NeweyWest()
函数的好信息找出异方差自相关一致 (HAC) 标准误差。
但 NeweyWest()
只接受 lm
对象。
> library(sandwich)
> NeweyWest(rnorm(100))
Error in UseMethod("estfun") :
no applicable method for 'estfun' applied to an object of class "c('double', 'numeric')"
>
我经常得到与线性回归无关的回报向量,我想找到 HAC 标准误差。有什么想法吗?我应该自己写吗?谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一点小小的误会。我在考虑残差,但你问的是平均值的标准误差。这可以通过对截距建模向量来轻松获得,或者:
对于标准差:
抱歉造成误解,我的错。
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 :
For the standard deviation :
Sorry for the misunderstanding, my bad.