我一直在尝试robust
在R中复制Stata选项的结果。我使用了rlm
来自MASS包的命令lmrob
以及来自“ robustbase”包的命令。在这两种情况下,结果都与Stata中的“ robust”选项完全不同。在这种情况下,有人可以提出建议吗?
这是我在Stata中运行稳健选项时获得的结果:
. reg yb7 buildsqb7 no_bed no_bath rain_harv swim_pl pr_terrace, robust
Linear regression Number of obs = 4451
F( 6, 4444) = 101.12
Prob > F = 0.0000
R-squared = 0.3682
Root MSE = .5721
------------------------------------------------------------------------------
| Robust
yb7 | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
buildsqb7 | .0046285 .0026486 1.75 0.081 -.0005639 .009821
no_bed | .3633841 .0684804 5.31 0.000 .2291284 .4976398
no_bath | .0832654 .0706737 1.18 0.239 -.0552904 .2218211
rain_harv | .3337906 .0395113 8.45 0.000 .2563289 .4112524
swim_pl | .1627587 .0601765 2.70 0.007 .0447829 .2807346
pr_terrace | .0032754 .0178881 0.18 0.855 -.0317941 .0383449
_cons | 13.68136 .0827174 165.40 0.000 13.51919 13.84353
这是我在R中使用lmrob选项获得的结果:
> modelb7<-lmrob(yb7~Buildsqb7+No_Bed+Rain_Harv+Swim_Pl+Gym+Pr_Terrace, data<-bang7)
> summary(modelb7)
Call:
lmrob(formula = yb7 ~ Buildsqb7 + No_Bed + Rain_Harv + Swim_Pl + Gym + Pr_Terrace,
data = data <- bang7)
\--> method = "MM"
Residuals:
Min 1Q Median 3Q Max
-51.03802 -0.12240 0.02088 0.18199 8.96699
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 12.648261 0.055078 229.641 <2e-16 ***
Buildsqb7 0.060857 0.002050 29.693 <2e-16 ***
No_Bed 0.005629 0.019797 0.284 0.7762
Rain_Harv 0.230816 0.018290 12.620 <2e-16 ***
Swim_Pl 0.065199 0.028121 2.319 0.0205 *
Gym 0.023024 0.014655 1.571 0.1162
Pr_Terrace 0.015045 0.013951 1.078 0.2809
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Robust residual standard error: 0.1678
Multiple R-squared: 0.8062, Adjusted R-squared: 0.8059
lmrob
一样reg y x, robust
。Google“异方差一致性标准错误R”。您将获得显示如何使用lmtest
和sandwich
库的页面。