gpt4 book ai didi

r - 如何用R计算面板引导标准误差?

转载 作者:行者123 更新时间:2023-12-04 15:42:57 24 4
gpt4 key购买 nike

我最近从 STATA 更​​改为 R 并且以某种方式努力寻找一些相应的命令。我想使用 plm 从固定效应模型中获取面板引导标准错误此处描述的库 here对于 STATA 用户:

  • 我的问题涉及一般的方法(引导是合适的库还是库(meboot)
    )
  • 如何使用引导解决该特定错误:

  • 首先获取一些面板数据:
    library(plm)
    data(EmplUK) # from plm library

    test<-function(data, i) coef(plm(wage~emp+sector,data = data[i,],
    index=c("firm","year"),model="within"))

    第二:
    library(boot)
    boot<-boot(EmplUK, test, R = 100)

    > boot<-boot(EmplUK, test, R = 100)
    duplicate couples (time-id)
    Error in pdim.default(index[[1]], index[[2]]) :
    Called from: top level
    Browse[1]>

    最佳答案

    出于某种原因,boot将一个索引(这里是原始的)传递给 plm带有重复值。您应该删除所有重复值并断言索引为 唯一在将其传递给 plm 之前.

    test <- function(data,original) {
    coef(plm(wage~emp+sector,data = data[unique(original),],
    index=c("firm","year"),model="within"))
    }


    boot(EmplUK, test, R = 100)

    ## ORDINARY NONPARAMETRIC BOOTSTRAP
    ## Call:
    ## boot(data = EmplUK, statistic = test, R = 100)
    ## Bootstrap Statistics :
    ## original bias std. error
    ## t1* -0.1198127 -0.01255009 0.05269375

    关于r - 如何用R计算面板引导标准误差?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30781194/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com