I have been trying to replicate the results of the Stata option robust
in R. I have used the rlm
command form the MASS package and also the command lmrob
from the package "robustbase". In both cases the results are quite different from the "robust" option in Stata. Can anybody please suggest something in this context?
Here are the results I obtained when I ran the robust option in 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
And this is what I obtained in R with the lmrob option:
> 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
is not the same asreg y x, robust
. Google "heteroskedasticity-consistent standard errors R". You'll get pages showing you how to use thelmtest
andsandwich
libraries. $\endgroup$