Announcement

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

  • Testing Equality of Coefficients from Two Separate Regressions

    Hi all,

    I am using Stata18.

    I have two separate regressors, X1 and X2. Hence, I want to run two separate equations, but both equations have the same dependent variable and controls.

    In the below two equations, I want to test whether the coefficient on X1 in the first equation (call it B1) is statistically significantly different from the coefficient on X2 in the second equation (call it B2).

    How can I achieve this? I presume it would involve seemingly unrelated regression, however I am quite unfamiliar with this estimation method.

    Code:
    reg Y X1 controls
    reg Y X2 controls
    Code:
    input float(Y X1) double X2
     1  3.306991  4.719900320258221
     1 1.4509706  5.033017157002235
     1  1.420742  4.955461239756943
     1 1.2662406 4.5469089910628275
     1 1.2695993  4.476237999457594
     1 1.3636436  4.483950194197082
     1  1.309904                  .
     1   1.16212  4.281886680407543
     1 1.0815105 3.6729566039140558
    20  1.799189  5.822563431721446
    37 1.4509706  5.033017157002235
    42  1.323339  4.724373896730076
    76 1.2662406 4.5469089910628275
    64 1.3636436  4.483950194197082
    34 1.0277709                  .
     0  .9874661                  .
     0 3.6635265  4.179483443697536
     5  3.791261  4.468130536388181

  • #2
    Code:
    help suest
    for examples.

    Comment


    • #3
      Thanks Andrew!

      Code:
       
       reg Y X1 controls est store m1 reg Y X2 controls est store m2  * Use suest to combine the estimates  suest model1 model2  * Test the difference between coefficients  test [model1]X1 = [model2]X2
      Unfortunately I get the error "suest requires that predict allow the score option"

      Comment


      • #4
        Maxence:
        as per Andrew's excellent advice, you may find the following toy-example useful:
        Code:
        . reg Y X1
        
              Source |       SS           df       MS      Number of obs   =        18
        -------------+----------------------------------   F(1, 16)        =      0.93
               Model |  550.057228         1  550.057228   Prob > F        =    0.3494
            Residual |  9468.88722        16  591.805451   R-squared       =    0.0549
        -------------+----------------------------------   Adj R-squared   =   -0.0042
               Total |  10018.9444        17  589.349673   Root MSE        =    24.327
        
        ------------------------------------------------------------------------------
                   Y | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
        -------------+----------------------------------------------------------------
                  X1 |  -6.329131   6.564923    -0.96   0.349    -20.24615    7.587884
               _cons |   26.60029   12.45163     2.14   0.048     .2040155    52.99656
        ------------------------------------------------------------------------------
        
        . estimates store A
        
        . reg Y X2
        
              Source |       SS           df       MS      Number of obs   =        15
        -------------+----------------------------------   F(1, 13)        =      0.30
               Model |  206.035337         1  206.035337   Prob > F        =    0.5946
            Residual |  8998.36466        13  692.181897   R-squared       =    0.0224
        -------------+----------------------------------   Adj R-squared   =   -0.0528
               Total |      9204.4        14  657.457143   Root MSE        =    26.309
        
        ------------------------------------------------------------------------------
                   Y | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
        -------------+----------------------------------------------------------------
                  X2 |   8.003695   14.66999     0.55   0.595    -23.68889    39.69628
               _cons |  -20.24577   68.24021    -0.30   0.771    -167.6698    127.1783
        ------------------------------------------------------------------------------
        
        . estimates store B
        
        . suest A B
        
        Simultaneous results for A, B                               Number of obs = 18
        
        ------------------------------------------------------------------------------
                     |               Robust
                     | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
        A_mean       |
                  X1 |  -6.329131   3.114945    -2.03   0.042    -12.43431   -.2239507
               _cons |   26.60029   10.55403     2.52   0.012     5.914776     47.2858
        -------------+----------------------------------------------------------------
        A_lnvar      |
               _cons |   6.383178   .3328784    19.18   0.000     5.730748    7.035608
        -------------+----------------------------------------------------------------
        B_mean       |
                  X2 |   8.003695   6.484276     1.23   0.217    -4.705252    20.71264
               _cons |  -20.24577   32.09214    -0.63   0.528    -83.14521    42.65367
        -------------+----------------------------------------------------------------
        B_lnvar      |
               _cons |   6.539849   .3710018    17.63   0.000     5.812699    7.266999
        ------------------------------------------------------------------------------
        
        
        . test [A_mean]X1 =[B_mean]X2
        
         ( 1)  [A_mean]X1 - [B_mean]X2 = 0
        
                   chi2(  1) =    5.21
                 Prob > chi2 =    0.0225
        
        .
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          Originally posted by Maxence Morlet View Post

          Unfortunately I get the error "suest requires that predict allow the score option"
          Are you sure that you are using the regress command? As Carlo illustrates in #3, suest works with regress.

          Comment


          • #6
            Carlo Lazzaro : I am not familiar with -suest- but nevertheless I am asking: The first regression model has 18 observations, the second only 15. I wonder how it is possible to compare the effects of both models (of X1 and X2) if the sample sizes differ, and all the more how is it possible that the number of observations of -suest- is reported as 18?

            Comment


            • #7
              Dirk Enzmann:
              this is an interesting questiin that puzzled me for a while until I found an answer in the -suest- helpfile:
              Different estimators are allowed, for example, a regress model and a probit model; the only requirement is that predict produce equation-level scores with the score option after an estimation command. The models may be estimated on different samples, due either to explicit if or in selection or to missing values.
              Just out of curiosity, I applied -suest- to two other linear regressions whose sample sizes differ:
              Code:
              use https://www.stata-press.com/data/r18/auto
              . regress price rep78
              
                    Source |       SS           df       MS      Number of obs   =        69
              -------------+----------------------------------   F(1, 67)        =      0.00
                     Model |  24770.7652         1  24770.7652   Prob > F        =    0.9574
                  Residual |   576772188        67  8608540.12   R-squared       =    0.0000
              -------------+----------------------------------   Adj R-squared   =   -0.0149
                     Total |   576796959        68  8482308.22   Root MSE        =      2934
              
              ------------------------------------------------------------------------------
                     price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
              -------------+----------------------------------------------------------------
                     rep78 |   19.28012   359.4221     0.05   0.957    -698.1295    736.6897
                     _cons |   6080.379    1274.06     4.77   0.000     3537.345    8623.413
              ------------------------------------------------------------------------------
              
              . estimates store A
              
              . regress price foreign
              
                    Source |       SS           df       MS      Number of obs   =        74
              -------------+----------------------------------   F(1, 72)        =      0.17
                     Model |  1507382.66         1  1507382.66   Prob > F        =    0.6802
                  Residual |   633558013        72  8799416.85   R-squared       =    0.0024
              -------------+----------------------------------   Adj R-squared   =   -0.0115
                     Total |   635065396        73  8699525.97   Root MSE        =    2966.4
              
              ------------------------------------------------------------------------------
                     price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
              -------------+----------------------------------------------------------------
                   foreign |   312.2587   754.4488     0.41   0.680    -1191.708    1816.225
                     _cons |   6072.423    411.363    14.76   0.000     5252.386     6892.46
              ------------------------------------------------------------------------------
              
              . estimates store B
              
              . suest A B
              
              Simultaneous results for A, B                               Number of obs = 74
              
              ------------------------------------------------------------------------------
                           |               Robust
                           | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
              -------------+----------------------------------------------------------------
              A_mean       |
                     rep78 |   19.28012   323.9278     0.06   0.953    -615.6067     654.167
                     _cons |   6080.379   1248.488     4.87   0.000     3633.389     8527.37
              -------------+----------------------------------------------------------------
              A_lnvar      |
                     _cons |   15.96827   .2369417    67.39   0.000     15.50387    16.43266
              -------------+----------------------------------------------------------------
              B_mean       |
                   foreign |   312.2587   696.9581     0.45   0.654    -1053.754    1678.271
                     _cons |   6072.423   428.2447    14.18   0.000     5233.079    6911.767
              -------------+----------------------------------------------------------------
              B_lnvar      |
                     _cons |    15.9902   .2260545    70.74   0.000     15.54714    16.43325
              ------------------------------------------------------------------------------
              Kind regards,
              Carlo
              (StataNow 18.5)

              Comment


              • #8
                What suest does is the equivalent of a stacked regression. Different sample sizes isn't a problem, same way as you don't have a problem with different sample sizes when running a two-sample t-test using groups. On the sample sizes, unlike a stacked regression, suest takes into account duplicated observations.

                Code:
                clear
                input float(Y X1) double X2
                 1  3.306991  4.719900320258221
                 1 1.4509706  5.033017157002235
                 1  1.420742  4.955461239756943
                 1 1.2662406 4.5469089910628275
                 1 1.2695993  4.476237999457594
                 1 1.3636436  4.483950194197082
                 1  1.309904                  .
                 1   1.16212  4.281886680407543
                 1 1.0815105 3.6729566039140558
                20  1.799189  5.822563431721446
                37 1.4509706  5.033017157002235
                42  1.323339  4.724373896730076
                76 1.2662406 4.5469089910628275
                64 1.3636436  4.483950194197082
                34 1.0277709                  .
                 0  .9874661                  .
                 0 3.6635265  4.179483443697536
                 5  3.791261  4.468130536388181
                end
                
                gen obs_no=_n
                reshape long X, i(obs_no) j(which)
                gen cons=1
                glm Y i.which#(c.X c.cons), nocons robust
                Res.:

                Code:
                . glm Y i.which#(c.X c.cons), nocons robust
                
                Iteration 0:  Log pseudolikelihood = -151.22454  
                
                Generalized linear models                         Number of obs   =         33
                Optimization     : ML                             Residual df     =         29
                                                                  Scale parameter =   636.8018
                Deviance         =  18467.25188                   (1/df) Deviance =   636.8018
                Pearson          =  18467.25188                   (1/df) Pearson  =   636.8018
                
                Variance function: V(u) = 1                       [Gaussian]
                Link function    : g(u) = u                       [Identity]
                
                                                                  AIC             =   9.407548
                Log pseudolikelihood = -151.2245423               BIC             =   18365.85
                
                ------------------------------------------------------------------------------
                             |               Robust
                           Y | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                   which#c.X |
                          1  |  -6.329131   3.074119    -2.06   0.040    -12.35429   -.3039696
                          2  |   8.003695   6.399288     1.25   0.211    -4.538679    20.54607
                             |
                which#c.cons |
                          1  |   26.60029    10.4157     2.55   0.011     6.185895    47.01468
                          2  |  -20.24577   31.67152    -0.64   0.523     -82.3208    41.82927
                ------------------------------------------------------------------------------

                Comment

                Working...
                X