Announcement

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

  • Check if coefficients of regressions are statistically different

    Dear all,

    I would like to compare the coefficients of a couple of regressions in order to check if they are statistically different. However, I am not quite sure on the syntax in the program. As an illustration, besides the dataex, I am providing the regressions I want to compare.

    Code:
     * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(country1 year) float(tech_intensity r_valworker lval_worker ln_1980 perc_wanted2)
    398 1994 1         .         .         0            .
    400 2011 1 12046.368  9.396519  9.251294   .004684663
    705 1985 1         .         .         0            .
    524 2008 1  397.7566   5.98584         0            .
     60 1999 1         .         .         0            .
    705 2006 1 20136.074  9.910268         0            .
    266 1970 1         .         .         0            .
    231 2001 1  3446.155  8.145015         0            .
    388 1991 1         .         .         0            .
    410 2014 1  50931.88 10.838244         0            .
    438 2011 1         .         .         0            .
    178 1970 1 4219.0156  8.347357         0            .
    894 1988 1         .         .  9.881193            .
    422 2008 1         .         .         0            .
    462 2006 1         .         .         0            .
    360 1987 1  4684.382  8.451989  8.297654    .02204786
    340 1993 1   5411.45  8.596272         0            .
    250 2010 1  43072.58 10.670642  10.40521   .008847745
    764 2010 1  3111.553  8.042877         0            .
     50 1971 1 1519.3197  7.326018  7.223282            .
    616 1983 1 4241.7007  8.352719  8.179547      .057724
    214 1998 1         .         .  9.139141            .
     70 1994 1         .         .         0            .
    120 1993 1  8052.041  8.993681  9.822526   -.06375731
    508 2013 1         .         .         0            .
    800 1993 1  8450.436  9.041973         0            .
    686 2014 1  674.0557  6.513313   9.26582   -.08095608
    280 1981 1  23264.57 10.054687 10.104993   -.05030632
    530 1991 1         .         .         0            .
    268 1999 1         .         .         0            .
     12 1984 1         .         .  9.920269            .
    360 1993 1         .         .         0            .
    192 1975 1         .         .  8.889088            .
    356 2014 1 2833.6084  7.949306  6.411442     .0452313
    446 1999 1   9209.31   9.12797  7.995726     .0595918
    630 1974 1         .         .         0            .
    376 1986 1  29112.62 10.278927 10.303637 -.0041182837
    360 2004 1 3684.1794  8.211803  7.618095   .024737835
    894 1996 1         .         .  9.671973            .
    112 2002 1         .         .         0            .
    531 2014 1         .         .         0            .
     40 1974 1  22565.56  10.02418 10.241074            .
    590 2007 1         .         .  9.464402            .
    705 2015 1  10161.63  9.226374         0            .
    484 1993 1 17147.781  9.749624         0            .
    196 1976 1  9863.634 9.1966095  9.373387            .
    450 1981 1 3981.5635   8.28943   8.62533    -.3359003
    372 1963 1  7207.489  8.882875  9.754238            .
    288 1966 1 10838.454  9.290855  8.529375            .
    704 2004 1         .         .         0            .
    170 1975 1  6967.462  8.849007   9.24948            .
     32 1990 1 21454.033  9.973668         0            .
    702 2014 1  26597.59 10.188576  9.356116     .0244841
    266 1991 1         .         .  9.535266            .
    554 1999 1 37221.027  10.52463  9.834158   .036340613
    706 1971 1         .         .         0            .
    428 2005 1  3454.181  8.147341         0            .
    604 1996 1 14189.943  9.560288         0            .
    590 1973 1  13438.45  9.505876  9.464402            .
    840 1963 1 19254.178  9.865483     9.898            .
    686 2014 1   3489.04  8.157382  9.650778   -.04392341
    388 1976 1  18210.34  9.809745  9.204855            .
    380 1997 1  45456.82 10.724518 10.678854   .002686108
    710 1982 1 17311.281  9.759113 10.333258   -.28707218
      8 2019 1  2577.152   7.85444         0            .
    724 1984 1  40690.35 10.613747 11.005033   -.09782147
    688 1997 1         .         .         0            .
    752 1977 1  22656.51 10.028202 10.031988            .
    756 1993 1  52818.46 10.874616         0            .
    230 1970 1  30136.51 10.313493 10.653697            .
    894 1974 1         .         .         0            .
    152 1974 1  208201.7 12.246263 12.534375            .
    356 1990 1 2050.2195  7.625702  7.563256   .006244612
     32 1977 1         .         .         0            .
    862 1985 1 156336.66 11.959767 11.537888    .08437596
    716 2013 1         .         .         0            .
    230 1971 1 4064.5205  8.310051  8.299515            .
    480 2006 1  5784.978   8.66302  8.413436   .009599392
     68 1987 1         .         .         0            .
     44 1996 1  54812.94  10.91168         0            .
    340 1985 1  6305.229  8.749135         0            .
     40 2011 1   53558.5  10.88853 10.158862    .02353767
    340 1965 1 13715.672  9.526295         0            .
     68 2016 1         .         . 11.706547            .
    807 2010 1  2511.626  7.828686         0            .
    140 1991 1  20647.18  9.935334    9.1395   .072348595
     32 2012 1         .         .         0            .
    462 2016 1         .         .         0            .
    158 2011 1 16584.393  9.716217         0            .
    776 1993 1         .         .         0            .
    634 1999 1         .         .         0            .
    398 1994 1         .         .         0            .
    686 1990 1  6957.519  8.847578  9.030405    -.0182827
    203 2002 1  9160.186  9.122622         0            .
    278 1978 1         .         .         0            .
     32 2005 1         .         .         0            .
    840 1976 1 33681.516 10.424705 10.247317            .
     60 2009 1         .         .         0            .
     52 1978 1 13538.247  9.513274  9.346107            .
     60 2003 1         .         .         0            .
    end
    Code:
    reg perc_wanted2 ln_1980 i.country1 i.isic1 i.year if tech_intensity==3, robust
    Code:
     eg perc_wanted2 ln_1980 i.country1 i.isic1 i.year if tech_intensity==1, robust
    My goal is to see if the betas in both regressions are statistically different. Thank you very much!

  • #2
    Hugo:
    unfortunately, your excerpt does not help, as -tech_intensity- is always 1.
    However, the following toy-example may be helpful:
    Code:
    use "https://www.stata-press.com/data/r17/auto.dta"
    . reg mpg turn if rep78==4
    
          Source |       SS           df       MS      Number of obs   =        18
    -------------+----------------------------------   F(1, 16)        =    110.53
           Model |  361.649402         1  361.649402   Prob > F        =    0.0000
        Residual |  52.3505976        16  3.27191235   R-squared       =    0.8735
    -------------+----------------------------------   Adj R-squared   =    0.8656
           Total |         414        17  24.3529412   Root MSE        =    1.8088
    
    ------------------------------------------------------------------------------
             mpg | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
            turn |  -.9800797    .093222   -10.51   0.000    -1.177701   -.7824579
           _cons |   59.39973   3.614281    16.43   0.000      51.7378    67.06167
    ------------------------------------------------------------------------------
    
    . estimates store m1
    
    . reg mpg turn if rep78==5
    
          Source |       SS           df       MS      Number of obs   =        11
    -------------+----------------------------------   F(1, 9)         =      3.26
           Model |  202.775543         1  202.775543   Prob > F        =    0.1045
        Residual |  559.769912         9  62.1966568   R-squared       =    0.2659
    -------------+----------------------------------   Adj R-squared   =    0.1844
           Total |  762.545455        10  76.2545455   Root MSE        =    7.8865
    
    ------------------------------------------------------------------------------
             mpg | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
            turn |  -3.141593   1.739905    -1.81   0.104    -7.077532    .7943466
           _cons |   139.3186   62.04948     2.25   0.051    -1.047095    279.6843
    ------------------------------------------------------------------------------
    
    . estimates store m2
    
    . suest m1 m2, robust
    
    Simultaneous results for m1, m2                             Number of obs = 29
    
    ------------------------------------------------------------------------------
                 |               Robust
                 | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    m1_mean      |
            turn |  -.9800797   .0965911   -10.15   0.000    -1.169395   -.7907646
           _cons |   59.39973   3.716808    15.98   0.000     52.11492    66.68454
    -------------+----------------------------------------------------------------
    m1_lnvar     |
           _cons |   1.185375    .255296     4.64   0.000     .6850036    1.685746
    -------------+----------------------------------------------------------------
    m2_mean      |
            turn |  -3.141593   1.246517    -2.52   0.012    -5.584721   -.6984649
           _cons |   139.3186   43.73153     3.19   0.001     53.60637    225.0308
    -------------+----------------------------------------------------------------
    m2_lnvar     |
           _cons |   4.130301   .2280587    18.11   0.000     3.683314    4.577288
    ------------------------------------------------------------------------------
    
    . lincom [m1_mean]turn-[m2_mean]turn
    
     ( 1)  [m1_mean]turn - [m2_mean]turn = 0
    
    ------------------------------------------------------------------------------
                 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             (1) |   2.161513   1.250254     1.73   0.084    -.2889387    4.611965
    ------------------------------------------------------------------------------
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you very much! is it possible to do the test simultaneously for multiple regressions?

      Comment


      • #4
        Hugo:
        yes, via -suest- again.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Originally posted by Carlo Lazzaro View Post
          Hugo:
          yes, via -suest- again.
          I apologize for bothering. For the case of three regressions, can I test if the coefficient of one of them is strictly greater than the coefficient for the other two?

          Comment


          • #6
            Hugo:
            you may want to try something along the following lines:
            Code:
            use "https://www.stata-press.com/data/r17/auto.dta"
            . reg mpg turn if rep78==4
            . estimates store m1
            . reg mpg turn if rep78==5
            . estimates store m2
            . suest m1 m2, robust
            . reg mpg turn if rep78==3
            . estimates store m3
            . suest m1 m2 m3, robust
            .  test ([m2_mean]turn+[m3_mean]turn)=[m1_mean]turn
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Thank you, I tried something along those lines. In that syntax, then the null hyothesis is that the coefficient for m2 plus the coefficient for m3 are equal to the coefficient of m1.
              What would be the alternate hypothesis? I was thinking in one tailed tests but these are easier to think with two regressions....

              Comment


              • #8
                Hugo:
                an idea for a one-tailed test may be:
                Code:
                . lincom ([m2_mean]turn-[m1_mean]turn)
                
                 ( 1)  - [m1_mean]turn + [m2_mean]turn = 0
                
                ------------------------------------------------------------------------------
                             | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                         (1) |  -2.161513   1.239054    -1.74   0.081    -4.590014    .2669873
                ------------------------------------------------------------------------------
                
                . di r(p)/2
                .04053709
                
                . lincom ([m3_mean]turn-[m1_mean]turn)
                
                 ( 1)  - [m1_mean]turn + [m3_mean]turn = 0
                
                ------------------------------------------------------------------------------
                             | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                         (1) |   .2301433   .1676431     1.37   0.170    -.0984312    .5587178
                ------------------------------------------------------------------------------
                
                . di r(p)/2
                .08490464
                
                .
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment


                • #9
                  Originally posted by Carlo Lazzaro View Post
                  Hugo:
                  an idea for a one-tailed test may be:
                  Code:
                  . lincom ([m2_mean]turn-[m1_mean]turn)
                  
                  ( 1) - [m1_mean]turn + [m2_mean]turn = 0
                  
                  ------------------------------------------------------------------------------
                  | Coefficient Std. err. z P>|z| [95% conf. interval]
                  -------------+----------------------------------------------------------------
                  (1) | -2.161513 1.239054 -1.74 0.081 -4.590014 .2669873
                  ------------------------------------------------------------------------------
                  
                  . di r(p)/2
                  .04053709
                  
                  . lincom ([m3_mean]turn-[m1_mean]turn)
                  
                  ( 1) - [m1_mean]turn + [m3_mean]turn = 0
                  
                  ------------------------------------------------------------------------------
                  | Coefficient Std. err. z P>|z| [95% conf. interval]
                  -------------+----------------------------------------------------------------
                  (1) | .2301433 .1676431 1.37 0.170 -.0984312 .5587178
                  ------------------------------------------------------------------------------
                  
                  . di r(p)/2
                  .08490464
                  
                  .
                  Thank you very much! I am trying this one!

                  Comment


                  • #10
                    Originally posted by Carlo Lazzaro View Post
                    Hugo:
                    an idea for a one-tailed test may be:
                    Code:
                    . lincom ([m2_mean]turn-[m1_mean]turn)
                    
                    ( 1) - [m1_mean]turn + [m2_mean]turn = 0
                    
                    ------------------------------------------------------------------------------
                    | Coefficient Std. err. z P>|z| [95% conf. interval]
                    -------------+----------------------------------------------------------------
                    (1) | -2.161513 1.239054 -1.74 0.081 -4.590014 .2669873
                    ------------------------------------------------------------------------------
                    
                    . di r(p)/2
                    .04053709
                    
                    . lincom ([m3_mean]turn-[m1_mean]turn)
                    
                    ( 1) - [m1_mean]turn + [m3_mean]turn = 0
                    
                    ------------------------------------------------------------------------------
                    | Coefficient Std. err. z P>|z| [95% conf. interval]
                    -------------+----------------------------------------------------------------
                    (1) | .2301433 .1676431 1.37 0.170 -.0984312 .5587178
                    ------------------------------------------------------------------------------
                    
                    . di r(p)/2
                    .08490464
                    
                    .
                    For the sake of interpretation. The output of your first lincolm is telling us that the first coefficient is higher than the second at a 10% level?

                    Comment


                    • #11
                      Hugo:
                      yes. Two-tail test.
                      Kind regards,
                      Carlo
                      (Stata 19.0)

                      Comment


                      • #12
                        Thank you very much!

                        Comment

                        Working...
                        X