This page is hosted on AFS file server space, which is being shut down on November 13, 2018. If you are seeing this message, your service provider needs to take steps now. Visit afs.unc.edu for more information.

Robust Regression Using STATA 6

* OLS regression
. reg grad inc pbla phis edexp urb

  Source |       SS       df       MS                  Number of obs =      51
---------+------------------------------               F(  5,    45) =   14.94
   Model |  1973.30839     5  394.661678               Prob > F      =  0.0000
Residual |  1188.64143    45   26.414254               R-squared     =  0.6241
---------+------------------------------               Adj R-squared =  0.5823
   Total |  3161.94982    50  63.2389964               Root MSE      =  5.1395

------------------------------------------------------------------------------
    grad |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
     inc |    .001785   .0008021      2.225   0.031       .0001695    .0034005
    pbla |  -.4141165    .062532     -6.622   0.000      -.5400623   -.2881706
    phis |  -.4073045   .1169389     -3.483   0.001      -.6428316   -.1717774
   edexp |  -.0013187   .0013975     -0.944   0.350      -.0041334    .0014961
     urb |  -.1083125   .0460315     -2.353   0.023      -.2010247   -.0156004
   _cons |   69.04199   5.372707     12.851   0.000        58.2208    79.86317
 

* qreg performs least absolute residuals or minimum L1-norm regression
. qreg grad inc pbla phis edexp urb
Iteration  1:  WLS sum of weighted deviations =  208.54367
Iteration  1: sum of abs. weighted deviations =  236.21414
Iteration  2: sum of abs. weighted deviations =  207.28992
Iteration  3: sum of abs. weighted deviations =  201.05331
Iteration  4: sum of abs. weighted deviations =  200.34445
Iteration  5: sum of abs. weighted deviations =  199.84208

Median regression                                    Number of obs =        51
  Raw sum of deviations    312.5 (about 74.699997)
  Min sum of deviations 199.8421                     Pseudo R2     =    0.3605

------------------------------------------------------------------------------
    grad |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
     inc |   .0029724   .0015524      1.915   0.062      -.0001544    .0060992
    pbla |  -.3728657     .10048     -3.711   0.001      -.5752429   -.1704885
    phis |  -.4282676   .2360359     -1.814   0.076      -.9036684    .0471332
   edexp |  -.0028488    .002912     -0.978   0.333      -.0087138    .0030162
     urb |   -.189569   .0949354     -1.997   0.052      -.3807787    .0016407
   _cons |   65.07659   9.923346      6.558   0.000       45.08995    85.06324
 

* rreg performs robust regression using iteratively reweighted least squares with Huber and biweight functions tuned for 95% percent efficiency.
. rreg grad inc pbla phis edexp urb

   Huber iteration 1:  maximum difference in weights = .12234393
   Huber iteration 2:  maximum difference in weights = .05382205
   Huber iteration 3:  maximum difference in weights = .02203892
Biweight iteration 4:  maximum difference in weights = .1559363
Biweight iteration 5:  maximum difference in weights = .01087629
Biweight iteration 6:  maximum difference in weights = .00265105

Robust regression estimates                            Number of obs =      50
                                                       F(  5,    44) =   15.88
                                                       Prob > F      =  0.0000

------------------------------------------------------------------------------
    grad |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
     inc |   .0023026   .0008351      2.757   0.008       .0006196    .0039857
    pbla |  -.4363851   .0646035     -6.755   0.000      -.5665848   -.3061854
    phis |  -.7694453   .1837624     -4.187   0.000      -1.139794   -.3990965
   edexp |  -.0020356   .0014493     -1.405   0.167      -.0049566    .0008853
     urb |  -.0876499   .0483629     -1.812   0.077      -.1851189    .0098191
   _cons |   65.19619   5.641651     11.556   0.000       53.82619    76.56619
 

* The option tune(6), using a tuning constant of 6, down-weights outliers more steeply than the default 7.
. rreg grad inc pbla phis edexp urb, tune(6)

   Huber iteration 1:  maximum difference in weights = .12234393
   Huber iteration 2:  maximum difference in weights = .05382205
   Huber iteration 3:  maximum difference in weights = .02203892
Biweight iteration 4:  maximum difference in weights = .21024998
Biweight iteration 5:  maximum difference in weights = .02216084
Biweight iteration 6:  maximum difference in weights = .00613242

Robust regression estimates                            Number of obs =      50
                                                       F(  5,    44) =   14.70
                                                       Prob > F      =  0.0000

------------------------------------------------------------------------------
    grad |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
     inc |   .0023658   .0008732      2.709   0.010       .0006061    .0041255
    pbla |  -.4360197   .0675471     -6.455   0.000      -.5721519   -.2998875
    phis |  -.7707839   .1921354     -4.012   0.000      -1.158007   -.3835604
   edexp |  -.0020797   .0015154     -1.372   0.177      -.0051338    .0009743
     urb |  -.0919598   .0505665     -1.819   0.076      -.1938699    .0099503
   _cons |   64.86228   5.898709     10.996   0.000       52.97421    76.75035
------------------------------------------------------------------------------
 

* In Stata 6, I [Cheol-Sung Lee] could not find the relevant commands for robust regressions using Bisquare, Hampel, Trim, T method and Hadi method; I will check higher versions.