Announcement

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

  • Testing the equality of coefficients

    Hello,

    I'm currently conducting an analysis to assess the presence of a structural change in the data. To do this, I have conducted two separate regression analyses: one for the period before the structural break and another for the period after the break. My specific objective is to determine if the coefficient for the "income" variable is the same across these two time periods.

    I have included the code I've been using for your reference. If possible, could you please assist me in refining this code to accurately test the equality of the "income" coefficient between the two periods? Your guidance and support are highly appreciated.


    Code:
    regress savings income if break == 0
    scalar b1_p0 = _b[income]
    
    regress savings income if break == 1
    scalar b1_p1 = _b[income]
    
    test b1_p0 = b1_p1
    I got the following error message:

    Code:
    command test b1_p0 is unrecognized
    r(199);
    Then I tried the following:

    Code:
    regress savings income if break == 0
    estimates store reg0
    
    regress savings income if break == 1
    estimates store reg1
    
    test [reg0]income = [reg1]income

    I got the following error message:

    Code:
    equation [reg0] not found
    r(303);
    Thank you in advance.


  • #2
    You can't use this approach. When you use the -test- command, the coefficients you refer to must all be part of the currently posted estimation results. You are trying to get -test- to look at two coefficients that are in different estimation results, only one of which is currently posted.

    What you can do is combine the estimation results with -suest-. Here's an example of how it's done using the auto.dta:
    Code:
    sysuse auto, clear
    
    regress price mpg if foreign == 0
    estimates store f0
    
    regress price mpg if foreign == 1
    estimates store f1
    
    suest f0 f1
    suest, coeflegend
    
    test _b[f0_mean:mpg] = _b[f1_mean:mpg]
    A couple of caveats about -suest-. It supports many, but not all, Stata estimation commands, so its scope is somewhat limited. Also, if you want to use robust variance-covariance estimators, you don't apply them to the original -regress- commands. You use ordinary vce for those and then specify the robust vce in the -suest- command itself.


    Comment


    • #3
      Clyde Schechter : I never used suest and have only a vague understanding of what it does. But seeing your code I would like to take the opportunity to ask why you can't answer the apparent research question by simply testing the interaction of "mpg" and "foreign" using
      Code:
      regress price c.mpg##i.foreign
      I see that the test of significance (p-value) is not exactly identical, so what is different when using suest here?

      Comment


      • #4
        You can use an interaction. In fact, in my own work, I almost never use -suest- for this; I use interactions. But O.P. had already set down the two-separate-regressions road, suggesting he or she may not be familiar with using interactions. Since learning to use interactions proves difficult for many people, I thought it best to continue in the direction he or she began.

        As for the small difference in p-value, the interaction approach provides a t-test, whereas the -suest- approach uses a chi square test. So the -suest- approach is actually asymptotic, whereas -regress- with interaction calculates the actual degrees of freedom from the sample size. For small sample sizes, the difference could be appreciable, and the interaction approach would be the accurate one. But for most real-world data sets, the N is large enough that the difference is unimportant.

        Comment


        • #5
          Clyde Schechter and Dirk Enzmann, I appreciate your prompt response.

          The solution provided by Clyde Schechter did not work in my case. I am aware of the factor variable approach suggested by Dirk Enzmann. However, I have done it hardly, so it never crossed my mind.

          I ran the following syntax to test the equality of coefficients:

          Code:
          regress price c.mpg##i.foreign
          Code:
          . regress price c.mpg##i.foreign
          
                Source |       SS           df       MS      Number of obs   =        74
          -------------+----------------------------------   F(3, 70)        =      9.48
                 Model |   183435281         3  61145093.6   Prob > F        =    0.0000
              Residual |   451630115        70  6451858.79   R-squared       =    0.2888
          -------------+----------------------------------   Adj R-squared   =    0.2584
                 Total |   635065396        73  8699525.97   Root MSE        =    2540.1
          
          -------------------------------------------------------------------------------
                  price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
          --------------+----------------------------------------------------------------
                    mpg |  -329.2551   74.98545    -4.39   0.000    -478.8088   -179.7013
                        |
                foreign |
               Foreign  |  -13.58741   2634.664    -0.01   0.996    -5268.258    5241.084
                        |
          foreign#c.mpg |
               Foreign  |   78.88826   112.4812     0.70   0.485    -145.4485     303.225
                        |
                  _cons |   12600.54   1527.888     8.25   0.000     9553.261    15647.81
          -------------------------------------------------------------------------------
          Code:
          
          



          Running regression separately:

          Code:
          . regress price mpg if foreign == 0
          
                Source |       SS           df       MS      Number of obs   =        52
          -------------+----------------------------------   F(1, 50)        =     17.05
                 Model |   124392956         1   124392956   Prob > F        =    0.0001
              Residual |   364801844        50  7296036.89   R-squared       =    0.2543
          -------------+----------------------------------   Adj R-squared   =    0.2394
                 Total |   489194801        51  9592054.92   Root MSE        =    2701.1
          
          ------------------------------------------------------------------------------
                 price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
          -------------+----------------------------------------------------------------
                   mpg |  -329.2551   79.74034    -4.13   0.000    -489.4183   -169.0919
                 _cons |   12600.54   1624.773     7.76   0.000     9337.085    15863.99
          ------------------------------------------------------------------------------
          
          . regress price mpg if foreign == 1
          
                Source |       SS           df       MS      Number of obs   =        22
          -------------+----------------------------------   F(1, 20)        =     13.25
                 Model |  57534941.7         1  57534941.7   Prob > F        =    0.0016
              Residual |  86828271.1        20  4341413.55   R-squared       =    0.3985
          -------------+----------------------------------   Adj R-squared   =    0.3685
                 Total |   144363213        21   6874438.7   Root MSE        =    2083.6
          
          ------------------------------------------------------------------------------
                 price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
          -------------+----------------------------------------------------------------
                   mpg |  -250.3668   68.77435    -3.64   0.002    -393.8276    -106.906
                 _cons |   12586.95   1760.689     7.15   0.000     8914.217    16259.68
          ------------------------------------------------------------------------------
          Code:
          
          


          Since the interaction term gives us the estimate of the difference between slope coefficients of the two periods, I am unsure how to test the equality of coefficients. I know that if the differential slope coefficient is significant, it suggests that the slope coefficients in the two periods are significantly different from each other. However, there should be a way to test the equality of two coefficients: That of mpg of -329.2551 when foreign == 0 is equal to mpg of -250.3668 when foreign == 1.

          I ran the following to test the equality:

          Code:
          test 1.foreign#c.mpg = mpg
          test 1.foreign = _con
          Looking forward to your guidance.
          Thank you.

          Comment


          • #6
            The significance test of the interaction term is already the test of the equality of coefficients. As I understand it (I may be wrong): The difference of this approach as compared to suest is that suest allows to test cross-model hypotheses.

            Using suest as in your last attempt:
            Code:
            . sysuse auto
            (1978 automobile data)
            
            . regress price mpg if foreign == 0
            
                  Source |       SS           df       MS      Number of obs   =        52
            -------------+----------------------------------   F(1, 50)        =     17.05
                   Model |   124392956         1   124392956   Prob > F        =    0.0001
                Residual |   364801844        50  7296036.89   R-squared       =    0.2543
            -------------+----------------------------------   Adj R-squared   =    0.2394
                   Total |   489194801        51  9592054.92   Root MSE        =    2701.1
            
            ------------------------------------------------------------------------------
                   price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     mpg |  -329.2551   79.74034    -4.13   0.000    -489.4183   -169.0919
                   _cons |   12600.54   1624.773     7.76   0.000     9337.085    15863.99
            ------------------------------------------------------------------------------
            
            . est sto m1
            
            . regress price mpg if foreign == 1
            
                  Source |       SS           df       MS      Number of obs   =        22
            -------------+----------------------------------   F(1, 20)        =     13.25
                   Model |  57534941.7         1  57534941.7   Prob > F        =    0.0016
                Residual |  86828271.1        20  4341413.55   R-squared       =    0.3985
            -------------+----------------------------------   Adj R-squared   =    0.3685
                   Total |   144363213        21   6874438.7   Root MSE        =    2083.6
            
            ------------------------------------------------------------------------------
                   price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     mpg |  -250.3668   68.77435    -3.64   0.002    -393.8276    -106.906
                   _cons |   12586.95   1760.689     7.15   0.000     8914.217    16259.68
            ------------------------------------------------------------------------------
            
            . est sto m2
            
            . suest m1 m2
            
            Simultaneous results for m1, m2                             Number of obs = 74
            
            ------------------------------------------------------------------------------
                         |               Robust
                         | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
            m1_mean      |
                     mpg |  -329.2551   80.16093    -4.11   0.000    -486.3676   -172.1425
                   _cons |   12600.54   1755.108     7.18   0.000     9160.589    16040.49
            -------------+----------------------------------------------------------------
            m1_lnvar     |
                   _cons |   15.80284   .2986031    52.92   0.000     15.21759    16.38809
            -------------+----------------------------------------------------------------
            m2_mean      |
                     mpg |  -250.3668   84.69387    -2.96   0.003    -416.3637   -84.36987
                   _cons |   12586.95   2258.417     5.57   0.000     8160.534    17013.37
            -------------+----------------------------------------------------------------
            m2_lnvar     |
                   _cons |   15.28371   .2310235    66.16   0.000     14.83091    15.73651
            ------------------------------------------------------------------------------
            
            . suest, coeflegend
            
            Simultaneous results for m1, m2                             Number of obs = 74
            
            ------------------------------------------------------------------------------
                         | Coefficient  Legend
            -------------+----------------------------------------------------------------
            m1_mean      |
                     mpg |  -329.2551  _b[m1_mean:mpg]
                   _cons |   12600.54  _b[m1_mean:_cons]
            -------------+----------------------------------------------------------------
            m1_lnvar     |
                   _cons |   15.80284  _b[m1_lnvar:_cons]
            -------------+----------------------------------------------------------------
            m2_mean      |
                     mpg |  -250.3668  _b[m2_mean:mpg]
                   _cons |   12586.95  _b[m2_mean:_cons]
            -------------+----------------------------------------------------------------
            m2_lnvar     |
                   _cons |   15.28371  _b[m2_lnvar:_cons]
            ------------------------------------------------------------------------------
            
            . test _b[m1_mean:mpg] = _b[m2_mean:mpg]
            
             ( 1)  [m1_mean]mpg - [m2_mean]mpg = 0
            
                       chi2(  1) =    0.46
                     Prob > chi2 =    0.4987
            Last edited by Dirk Enzmann; 21 Oct 2023, 06:55.

            Comment

            Working...
            X