Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • OLS with robust standard errors

    Hello,

    I want to perform a multiple linear regression in my model, OLS with robust standard errors. Due to this last part, I am a little confused with the statistical tests that I can do, since some of the most known ones are not possible to perform, such as the hettest.

    Thank you for your time

  • #2
    Please could describe your data further? Are they cross-sectional, longitudinal, time series?

    Intuitively, if you're using OLS, you will want to test all Gauss-Markov assumptions. There are tests specific to panel data and tests specific to time-series data, which is why I ask about the nature of your data.

    Comment


    • #3
      Mary Anne:
      as an aside to Maxence's helpful advice, please note that repeating -estat hettest- after invoking -robust- to take heteroskedasticity into account, is pointless, as outcome is expected to report (again) the evidence of heteroskedasticity (that's why Stata throws an error message in that instance).
      This happens because -estat hettest- focuses on residual distribution (that remains unchanged after invoking the -robust- option, which, in turn, affects standard errors, with no bearing on residual distribution).
      Conversely, you can run:
      - estat ovtest- (with the usual caution in interpreting its output, as it is not that white/black magic able to spot what predictors are missing in the right-hand side of your regression equation, as it is often supposed/hoped to be);
      -linktest- (that I prefer to -estat ovtest-);
      -estat imtest-.

      What above is (hopefully) made clearer in the following toy-example:
      Code:
      . use "C:\Program Files\Stata16\ado\base\a\auto.dta"
      (1978 Automobile Data)
      
      . regress price mpg trunk i.foreign
      
            Source |       SS           df       MS      Number of obs   =        74
      -------------+----------------------------------   F(3, 70)        =      9.68
             Model |   186257112         3  62085704.1   Prob > F        =    0.0000
          Residual |   448808284        70  6411546.91   R-squared       =    0.2933
      -------------+----------------------------------   Adj R-squared   =    0.2630
             Total |   635065396        73  8699525.97   Root MSE        =    2532.1
      
      ------------------------------------------------------------------------------
             price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
               mpg |  -261.9892   64.91261    -4.04   0.000    -391.4533   -132.5251
             trunk |   83.64631   86.50052     0.97   0.337    -88.87354    256.1662
                   |
           foreign |
          Foreign  |   1887.461   711.4158     2.65   0.010     468.5866    3306.335
             _cons |   10033.08   2256.685     4.45   0.000     5532.264     14533.9
      ------------------------------------------------------------------------------
      
      . estat hettest
      
      Breusch-Pagan / Cook-Weisberg test for heteroskedasticity
               Ho: Constant variance
               Variables: fitted values of price
      
               chi2(1)      =     4.73
               Prob > chi2  =   0.0297
      
      . regress price mpg trunk i.foreign, vce(robust)
      
      Linear regression                               Number of obs     =         74
                                                      F(3, 70)          =      10.77
                                                      Prob > F          =     0.0000
                                                      R-squared         =     0.2933
                                                      Root MSE          =     2532.1
      
      ------------------------------------------------------------------------------
                   |               Robust
             price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
               mpg |  -261.9892   67.65337    -3.87   0.000    -396.9196   -127.0588
             trunk |   83.64631   65.27092     1.28   0.204    -46.53244    213.8251
                   |
           foreign |
          Foreign  |   1887.461    629.807     3.00   0.004     631.3504    3143.571
             _cons |   10033.08   2168.228     4.63   0.000     5708.686    14357.47
      ------------------------------------------------------------------------------
      
      . estat hettest
      hettest not appropriate after robust cluster()
      r(498);
      
      . linktest
      
            Source |       SS           df       MS      Number of obs   =        74
      -------------+----------------------------------   F(2, 71)        =     23.41
             Model |   252361179         2   126180590   Prob > F        =    0.0000
          Residual |   382704217        71  5390200.24   R-squared       =    0.3974
      -------------+----------------------------------   Adj R-squared   =    0.3804
             Total |   635065396        73  8699525.97   Root MSE        =    2321.7
      
      ------------------------------------------------------------------------------
             price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
              _hat |  -2.423435   .9922671    -2.44   0.017     -4.40196   -.4449106
            _hatsq |   .0002969   .0000848     3.50   0.001     .0001278    .0004659
             _cons |   9075.642   2808.766     3.23   0.002     3475.122    14676.16
      ------------------------------------------------------------------------------
      
      . estat ovtest
      
      Ramsey RESET test using powers of the fitted values of price
             Ho:  model has no omitted variables
                        F(3, 67) =      4.29
                        Prob > F =      0.0079
      
      . estat imtest
      
      Cameron & Trivedi's decomposition of IM-test
      
      ---------------------------------------------------
                    Source |       chi2     df      p
      ---------------------+-----------------------------
        Heteroskedasticity |       8.64      8    0.3733
                  Skewness |       5.44      3    0.1426
                  Kurtosis |       1.34      1    0.2472
      ---------------------+-----------------------------
                     Total |      15.42     12    0.2194
      ---------------------------------------------------
      
      .
      Eventually, please note that -linktest- can also be run manually with very similar results (in this toy-example, OLS - or, more technically speaking, the functional form of the regressand- is misspecified, as both -_hatsq- and -sq_fitted- have explanatory power):
      Code:
      . use "C:\Program Files\Stata16\ado\base\a\auto.dta"
      (1978 Automobile Data)
      
      . regress price mpg trunk i.foreign, vce(robust)
      
      Linear regression                               Number of obs     =         74
                                                      F(3, 70)          =      10.77
                                                      Prob > F          =     0.0000
                                                      R-squared         =     0.2933
                                                      Root MSE          =     2532.1
      
      ------------------------------------------------------------------------------
                   |               Robust
             price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
               mpg |  -261.9892   67.65337    -3.87   0.000    -396.9196   -127.0588
             trunk |   83.64631   65.27092     1.28   0.204    -46.53244    213.8251
                   |
           foreign |
          Foreign  |   1887.461    629.807     3.00   0.004     631.3504    3143.571
             _cons |   10033.08   2168.228     4.63   0.000     5708.686    14357.47
      ------------------------------------------------------------------------------
      
      . predict fitted, xb
      
      . g sq_fitted=fitted^2
      
      . regress price fitted sq_fitted, robust
      
      Linear regression                               Number of obs     =         74
                                                      F(2, 71)          =      26.28
                                                      Prob > F          =     0.0000
                                                      R-squared         =     0.3974
                                                      Root MSE          =     2321.7
      
      ------------------------------------------------------------------------------
                   |               Robust
             price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            fitted |  -2.423435   .6867943    -3.53   0.001    -3.792864   -1.054006
         sq_fitted |   .0002969   .0000654     4.54   0.000     .0001664    .0004273
             _cons |   9075.642   1586.624     5.72   0.000     5912.003    12239.28
      ------------------------------------------------------------------------------
      Last edited by Carlo Lazzaro; 03 Oct 2021, 05:09.
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Hello,

        Maxence, I forgot to mention that my data is in cross sectional data. I am sorry

        Carlo, thank you so much for your help!

        Comment

        Working...
        X