【问题标题】:R: standard errorsR:标准错误
【发布时间】:2013-06-12 18:40:45
【问题描述】:

在 NLS 回归中是否有任何函数可以计算 Newey-West 估计量和 R 中的 White 标准误差。三明治和汽车套餐可以,但他们需要 lm 对象来计算误差。

【问题讨论】:

    标签: r


    【解决方案1】:

    来自Achim Zeleis's April 2013 r-help posting 的示例(顺便说一下,这是第一次在谷歌上搜索“nls 三明治”):

     ## from ?nls:
     x <- -(1:100)/10
     y <- 100 + 10 * exp(x / 2) + rnorm(x)/10
     suppressWarnings(nlmod <- nls(y ~  Const + A * exp(B * x)))
    
     vcov(nlmod)
     sqrt(diag(vcov(nlmod)))
    

    来自阿奇姆的回答:

     ## the sandwich (aka HC0) covariance matrix and standard errors
     library("sandwich")
     sandwich(nlmod)
     sqrt(diag(sandwich(nlmod)))
    
     ## associated coefficient tests
     library("lmtest")
     coeftest(nlmod)
     coeftest(nlmod, vcov = sandwich)
    

    【讨论】:

    • 嗨,Ben 感谢您的回答。我还想知道如何为面板数据表单中的数据集执行此操作
    猜你喜欢
    • 2012-04-19
    • 2021-01-10
    • 1970-01-01
    • 1970-01-01
    • 2016-02-16
    • 2013-05-11
    • 1970-01-01
    • 1970-01-01
    • 2020-03-31
    相关资源
    最近更新 更多