审稿人:请给出回归系数的鲁棒标准误,谢谢!
install.packages("sandwich")
install.packages("lmtest")
library(sandwich)
library(lmtest)
summary(mtcars)

mymodel <- lm(mpg ~ hp + wt, data = mtcars)
summary(mymodel)

coeftest(mymodel, vcov = vcovHC(mymodel, type = "HC1"))

vcov_robust <- vcovHC(mymodel, type = "HC1")
ro_std_errors <- sqrt(diag(vcov_robust))
ro_std_errors


https://cran.r-project.org/web/packages/sandwich/index.html
https://cran.r-project.org/web/packages/lmtest/index.html
2024-06-24 12:12