Announcement

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

  • New post-estimation command -suregr- available on SSC: calculates robust, or cluster robust variance post -sureg- estimation.

    Thanks to Kit Baum, I have made available on SSC a new post estimation command -suregr- (mnemonic for -suregr[obust]-) that works after -[R] sureg -- Zellner's seemingly unrelated regression- and produces robust, or cluster-robust variance for the Seemingly Unrelated Regressions model.

    You can install -suregr- from within Stata by typing

    Code:
     ssc describe suregr
    
     ssc install suregr
    The motivation for writing this command is that Stata's native -sureg- is not able to calculate (cluster-)robust variance and standard errors for the parameter estimates, and this remains true as of Stata 17 which came out today.

    The command -suregr- implements automatically the methods and formulas in my recent paper Kolev (2021) "Robust and/or cluster-robust variance estimation in Seemingly Unrelated Regressions, and in Multivariate Regressions," and if you are interested in the methods and formulas I can send you the paper.

    What my -robustr- does is replace the standard variance with the (cluster-) robust variance and display -sureg- table with the robust standard errors. Everything that works with -sureg- still works as before, say you can impose linear constraints in the -sureg- estimation stage, and you can use -test-, -nlcom- and -lincom- after -suregr- as usual.

    Examples of use follow below:

    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . 
    . * Typical use of -suregr-, we firstly fit -sureg- quitetly, and then we follow up with -sureg- 
    . * to get the robust variance.
    . * If we do not specify the minus option, the default is minus(0) meaning no degrees of freedom adjustmen
    > t.
    . * Of course if we want to see the non-robust standard errors as well we can also run -sureg- noisily.  
    . 
    . quietly sureg (price headroom) (mpg weight length)
    
    . 
    . suregr
    
    Seemingly unrelated regression
    --------------------------------------------------------------------------
    Equation             Obs   Parms        RMSE    "R-sq"       chi2        P
    --------------------------------------------------------------------------
    price                 74       1    2910.242    0.0131       0.94   0.3314
    mpg                   74       2     3.34875    0.6604     136.53   0.0000
    --------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
                 |               Robust
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    price        |
        headroom |   389.6366   295.9122     1.32   0.188    -190.3406    969.6139
           _cons |   4998.979   843.8949     5.92   0.000     3344.976    6652.983
    -------------+----------------------------------------------------------------
    mpg          |
          weight |  -.0033167   .0019688    -1.68   0.092    -.0071756    .0005422
          length |  -.0916353   .0682694    -1.34   0.180    -.2254408    .0421703
           _cons |   48.53323   7.544959     6.43   0.000     33.74538    63.32108
    ------------------------------------------------------------------------------
    
    . 
    . * Typical use for getting the cluster-robust variance. We use the minus(1) degree of freedom adjustment,
    >  
    . * because this is the common adjustment cluster-robust variance estimators in native Stata commands use.
    . * We also use the option noheader to omit the header from our regression table. 
    . 
    . quietly sureg (price headroom) (mpg weight length)
    
    . 
    . suregr, cluster(rep) minus(1) noheader
    
                                      (Std. Err. adjusted for 5 clusters in rep78)
    ------------------------------------------------------------------------------
                 |               Robust
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    price        |
        headroom |    382.429   119.2846     3.21   0.001     148.6355    616.2224
           _cons |   4998.757   383.9062    13.02   0.000     4246.314    5751.199
    -------------+----------------------------------------------------------------
    mpg          |
          weight |  -.0027392   .0012197    -2.25   0.025    -.0051298   -.0003487
          length |  -.1121001   .0352499    -3.18   0.001    -.1811887   -.0430115
           _cons |   50.70261   6.473076     7.83   0.000     38.01561     63.3896
    ------------------------------------------------------------------------------
    
    . 
    . 
    . * Post estimation after -suregr- works as usual.
    . * -suregr- has substituted the (cluster-)robust variance, and the postestimation commands like -test-
    . * -lincom- and -nlcom- use  the (cluster-)robust variance in the calculations they are carrying out:
    . 
    . quietly sureg (price headroom) (mpg weight length)
    
    . 
    . suregr, cluster(rep) minus(1) noheader
    
                                      (Std. Err. adjusted for 5 clusters in rep78)
    ------------------------------------------------------------------------------
                 |               Robust
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    price        |
        headroom |    382.429   119.2846     3.21   0.001     148.6355    616.2224
           _cons |   4998.757   383.9062    13.02   0.000     4246.314    5751.199
    -------------+----------------------------------------------------------------
    mpg          |
          weight |  -.0027392   .0012197    -2.25   0.025    -.0051298   -.0003487
          length |  -.1121001   .0352499    -3.18   0.001    -.1811887   -.0430115
           _cons |   50.70261   6.473076     7.83   0.000     38.01561     63.3896
    ------------------------------------------------------------------------------
    
    . 
    . test [price]headroom = [mpg]weight
    
     ( 1)  [price]headroom - [mpg]weight = 0
    
               chi2(  1) =   10.28
             Prob > chi2 =    0.0013
    
    . 
    . nlcom [price]headroom/[mpg]weight
    
           _nl_1:  [price]headroom/[mpg]weight
    
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _nl_1 |  -139611.7   70247.72    -1.99   0.047    -277294.7   -1928.649
    ------------------------------------------------------------------------------
    
    . 
    . * Imposing linear constraints works as usual too
    . 
    . constraint define 1 [price]headroom = [mpg]weight
    
    . 
    . quietly sureg (price headroom) (mpg weight length), constraint(1)
    
    . 
    . suregr,  noheader
    
     ( 1)  [price]headroom - [mpg]weight = 0
    ------------------------------------------------------------------------------
                 |               Robust
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    price        |
        headroom |  -.0025949   .0020145    -1.29   0.198    -.0065432    .0013534
           _cons |   6165.265   340.5458    18.10   0.000     5497.807    6832.722
    -------------+----------------------------------------------------------------
    mpg          |
          weight |  -.0025949   .0020145    -1.29   0.198    -.0065432    .0013534
          length |  -.1057886   .0695312    -1.52   0.128    -.2420672      .03049
           _cons |   49.01368   7.647086     6.41   0.000     34.02566    64.00169
    ------------------------------------------------------------------------------
    
    . 
    . 
    .
    Reference

    Kolev, Gueorgui I. (2021). Robust and/or cluster-robust variance estimation in Seemingly Unrelated Regressions, and in Multivariate Regressions.
    (under review at the Stata Journal, available upon request from the author).

  • #2
    Dear Joro,

    Thanks for this! Does suregr support multiway clustering too?

    Best,

    Maria

    Comment


    • #3
      Hi Maria,

      No, -suregr- does not support multiway clustering automatically.

      But you can easily calculate manually the two-way clustered variance using -suregr- the way how I show for OLS in my post number 15 on this thread here:
      https://www.statalist.org/forums/for...ols-regression

      The formula for the two way clustered variance is:

      Vtwoway = Vfirstdim + Vseconddim - Vrobust

      Where:

      Vtwoway is the two way clustered variance that you are looking for
      Vfirstdim is the clustered variance along the first dimension of clustering only
      Vseconddim is the clustered variance along the second dimension only
      Vrobust is the robust only variance.








      Originally posted by Maria Ventura View Post
      Dear Joro,

      Thanks for this! Does suregr support multiway clustering too?

      Best,

      Maria

      Comment


      • #4
        Hi Joro,

        Thanks a lot, this is great! Would you have a theoretical reference for this by any chance?

        Best,

        Maria

        Comment


        • #5
          Hi Maria,

          I worked on the two way clustering issue circa year 2008-2009 when the two seminal papers of Cameron et al, and Thompson were still working papers.

          I might have actually figured out myself that Vtwoway = Vfirstdim + Vseconddim - Vrobust.

          For a published reference, check this paper:

          Thompson, Samuel B. "Simple formulas for standard errors that cluster by both firm and time." Journal of financial Economics 99, no. 1 (2011): 1-10.

          I either saw this fact that Vtwoway = Vfirstdim + Vseconddim - Vrobust in the Thompson's working paper version, or I figured it out myself as a result of some bells that rang reading the working paper of Thompson.

          Originally posted by Maria Ventura View Post
          Hi Joro,

          Thanks a lot, this is great! Would you have a theoretical reference for this by any chance?

          Best,

          Maria

          Comment


          • #6
            That's great, thanks again!

            Comment


            • #7
              Dear Joro Kolev,

              Many thanks for your written suregr command. It is really helpful and I am using it, hence, citing it in my current research. Could you please send me your paper?

              Kind regards,
              Binh

              Comment

              Working...
              X