Announcement

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

  • Comparing coefficients from dfferent models with lincom - lincom does not find equations

    Hello all!
    I would like to compare coefficients from differect models with lincom. But lincom does not work.
    My research question is whether pre-academic vocational education and training (VET) pays off for higher education graduates - and here specifically, whether it pays off for subgroups (e.g. men) more/less than for e.g. women. The problem is that lincom tells me that it cannot find my estimation results which I stored.

    Here my syntax (a simplified version):

    reg income i.vet he_inst study_field control1 control... if women==0, coeflegend
    est store M1

    2nd model:
    reg income i.vet he_inst study_field control1 control... if women==1, coeflegend
    est store M2

    lincom [M1]i.vet - [M2]i.vet
    Stata response: "equation [M1] not found"

    Of course, I could test for different effects via modeling an interaction effect (i.vet##i.women). But I have good reason to do it in separate models - and then compare the VET effects of the two separate models.

    In the lincom code, I have tried several versions to get the stores results (with brackets, without brackets, etc). But it does not work.

    Has anyone an idea how to do it properly ? ChatGPT's help was none. Now I hope for good old natural intelligence ;-)

    Thank you very much in advance
    Gunther
    Last edited by Gunther Dahm; 30 Jun 2023, 05:34.

  • #2
    Gunther:
    welcome to this forum.
    You may want to consider something along the following lines:
    Code:
    . use "C:\Program Files\Stata17\ado\base\a\auto.dta"
    (1978 automobile data)
    
    . regress price mpg if foreign==0 & mpg<=20
    
          Source |       SS           df       MS      Number of obs   =        33
    -------------+----------------------------------   F(1, 31)        =     51.95
           Model |   198763029         1   198763029   Prob > F        =    0.0000
        Residual |   118598565        31  3825760.17   R-squared       =    0.6263
    -------------+----------------------------------   Adj R-squared   =    0.6142
           Total |   317361594        32  9917549.81   Root MSE        =      1956
    
    ------------------------------------------------------------------------------
           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             mpg |   -1071.97   148.7215    -7.21   0.000     -1375.29   -768.6508
           _cons |   24776.62   2546.624     9.73   0.000     19582.74    29970.49
    ------------------------------------------------------------------------------
    
    . estimates store A
    
    . regress price mpg if foreign==1 & mpg<=20
    
          Source |       SS           df       MS      Number of obs   =         5
    -------------+----------------------------------   F(1, 3)         =      6.02
           Model |  30312141.1         1  30312141.1   Prob > F        =    0.0914
        Residual |  15100876.1         3  5033625.38   R-squared       =    0.6675
    -------------+----------------------------------   Adj R-squared   =    0.5566
           Total |  45413017.2         4  11353254.3   Root MSE        =    2243.6
    
    ------------------------------------------------------------------------------
           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             mpg |  -1675.315   682.6979    -2.45   0.091    -3847.964    497.3346
           _cons |   37403.89   11513.13     3.25   0.048     763.9747     74043.8
    ------------------------------------------------------------------------------
    
    . estimates store B
    
    . suest A B
    
    Simultaneous results for A, B                               Number of obs = 38
    
    ------------------------------------------------------------------------------
                 |               Robust
                 | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    A_mean       |
             mpg |   -1071.97   166.1949    -6.45   0.000    -1397.706   -746.2343
           _cons |   24776.62   3078.322     8.05   0.000     18743.22    30810.02
    -------------+----------------------------------------------------------------
    A_lnvar      |
           _cons |   15.15727   .2550977    59.42   0.000     14.65729    15.65725
    -------------+----------------------------------------------------------------
    B_mean       |
             mpg |  -1675.315   346.1403    -4.84   0.000    -2353.737   -996.8922
           _cons |   37403.89   5622.598     6.65   0.000      26383.8    48423.98
    -------------+----------------------------------------------------------------
    B_lnvar      |
           _cons |   15.43165   .3455294    44.66   0.000     14.75443    16.10888
    ------------------------------------------------------------------------------
    
    . help suest
    
    . test [A_mean=B_mean], cons
    
     ( 1)  [A_mean]mpg - [B_mean]mpg = 0
     ( 2)  [A_mean]_cons - [B_mean]_cons = 0
    
               chi2(  2) =   11.96
             Prob > chi2 =    0.0025
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hello Carlo,
      thank you very much.

      Does your answer mean that it doesn't work with lincom?
      I had already read about "suest", but I vaguely remembered that "lincom" was supposed to be better somehow.


      I myself have two problems with suest:

      1) Apparently you can't use pweights with it.
      2) Is it possible to limit the test with suest to a single variable of a larger model? My models of course have more independent variables than just the central independent variable "vet". And I am only interested in whether there are differences between the groups for the VET variable. Deviations between other variables should not distort the test. However, the suest test or the chi2 test statistic seems to refer to deviations between all variables, i.e. to deviations between the models as a whole. Or am I seeing this wrong?

      Best regards,
      Gunther

      Comment


      • #4
        Gunther:
        1) -suest- does not support -weights-;
        2) when compared to -test-, -lincom- does different operations (that do not include equality of two coefficients). Elaborating on the previous example:
        Code:
        . suest A B
        
        Simultaneous results for A, B                               Number of obs = 38
        
        ------------------------------------------------------------------------------
                     |               Robust
                     | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
        A_mean       |
                 mpg |   -1071.97   166.1949    -6.45   0.000    -1397.706   -746.2343
               _cons |   24776.62   3078.322     8.05   0.000     18743.22    30810.02
        -------------+----------------------------------------------------------------
        A_lnvar      |
               _cons |   15.15727   .2550977    59.42   0.000     14.65729    15.65725
        -------------+----------------------------------------------------------------
        B_mean       |
                 mpg |  -1675.315   346.1403    -4.84   0.000    -2353.737   -996.8922
               _cons |   37403.89   5622.598     6.65   0.000      26383.8    48423.98
        -------------+----------------------------------------------------------------
        B_lnvar      |
               _cons |   15.43165   .3455294    44.66   0.000     14.75443    16.10888
        ------------------------------------------------------------------------------
        
        . ereturn list
        
        scalars:
                          e(N) =  38
                       e(rank) =  6
        
        macros:
                        e(cmd) : "suest"
                   e(eqnames1) : "mean lnvar"
                   e(eqnames2) : "mean lnvar"
                      e(names) : "A B"
                    e(vcetype) : "Robust"
                        e(vce) : "robust"
                 e(properties) : "b V"
        
        matrices:
                          e(b) :  1 x 6
                          e(V) :  6 x 6
        
        functions:
                     e(sample)   
        
        . mat list e(b)
        
        e(b)[1,6]
                A_mean:     A_mean:    A_lnvar:     B_mean:     B_mean:    B_lnvar:
                   mpg       _cons       _cons         mpg       _cons       _cons
        y1  -1071.9704   24776.619   15.157268  -1675.3148   37403.889   15.431651
        
        . lincom [A_mean]mpg + [B_mean]mpg
        
         ( 1)  [A_mean]mpg + [B_mean]mpg = 0
        
        ------------------------------------------------------------------------------
                     | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
                 (1) |  -2747.285   383.9712    -7.15   0.000    -3499.855   -1994.715
        ------------------------------------------------------------------------------
        
        
        .
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Wonderful - and many thanks, Carlo!

          After the suest command, I can now compare effect coefficients from different models via lincom after all. I had previously thought that lincom could access saved model results without the suest command.

          However. Looks like I'm now getting the results I wanted to calculate, or at least a good approximation of them - apparently you can use iweights instead of pweights.

          Many thanks again and best regards
          Gunther

          Comment

          Working...
          X