Announcement

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

  • Syntax for lincom won't work in Stata 16 but works fine in Stata 15

    Hello all. I'm a professor at Baldwin Wallace. On Thursday, I tried to run a lab with my class from Pollock's Stata Companion (Chapter 6) to compare means. This lab runs fine in Stata v. 15, but it will not run in Stata v. 16.

    This is the command
    lincom [egal_scale]Male - [egal_scale]Female

    It runs perfectly fine in Stata 15, which I have on my home computer (see below).

    When I run it in Stata 16, I get an error message that says the variable was not recognized as an equation. All my students ran into this problem, too.

    Needless to say, it was a little embarrassing, and 'googling' the error isn't doing the trick.

    Any suggestions?

    Thank you!
    -Lauren



    . mean egal_scale [pw=nesw], over(female)

    Mean estimation Number of obs = 5,456

    Male: female = Male
    Female: female = Female

    --------------------------------------------------------------
    Over | Mean Std. Err. [95% Conf. Interval]
    -------------+------------------------------------------------
    egal_scale |
    Male | 13.69738 .1288302 13.44482 13.94993
    Female | 14.44775 .1250026 14.2027 14.69281
    --------------------------------------------------------------

    .
    . lincom [egal_scale]Male - [egal_scale]Female

    ( 1) [egal_scale]Male - [egal_scale]Female = 0

    ------------------------------------------------------------------------------
    Mean | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    (1) | -.7503768 .1795073 -4.18 0.000 -1.102283 -.3984709
    ------------------------------------------------------------------------------

  • #2
    Lauren:
    welcome to this forum.
    I can replicate your problem with one of the traditional Stata database:
    Code:
    . use "C:\Program Files (x86)\Stata15\ado\base\a\auto.dta"
    (1978 Automobile Data)
    
    . mean price, over(foreign)
    
    Mean estimation                   Number of obs   =         74
    
         Domestic: foreign = Domestic
          Foreign: foreign = Foreign
    
    --------------------------------------------------------------
            Over |       Mean   Std. Err.     [95% Conf. Interval]
    -------------+------------------------------------------------
    price        |
        Domestic |   6072.423   429.4911      5216.449    6928.398
         Foreign |   6384.682   558.9942      5270.608    7498.756
    --------------------------------------------------------------
    
    . mat list e(b)
    
    e(b)[1,3]
               0b.         1.          
          foreign    foreign      _cons
    y1          0  312.25874  6072.4231
    
    . lincom [ price ]Domestic - [ price ]Foreign
    
     ( 1)  [price]Domestic - [price]Foreign = 0
    
    ------------------------------------------------------------------------------
            Mean |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             (1) |  -312.2587   704.9376    -0.44   0.659    -1717.197     1092.68
    ------------------------------------------------------------------------------
    
    .
    
    
    
    
    . use "C:\Program Files\Stata16\ado\base\a\auto.dta"
    (1978 Automobile Data)
    
    .  mean price, over(foreign)
    
    Mean estimation                      Number of obs   =         74
    
    -----------------------------------------------------------------
                    |       Mean   Std. Err.     [95% Conf. Interval]
    ----------------+------------------------------------------------
    c.price@foreign |
          Domestic  |   6072.423   429.4911      5216.449    6928.398
           Foreign  |   6384.682   558.9942      5270.608    7498.756
    -----------------------------------------------------------------
    
    . mat list e(b)
    
    e(b)[1,2]
          c.price@   c.price@
        0.foreign  1.foreign
    y1  6072.4231  6384.6818
    
    . lincom [ price ][email protected] [ price ][email protected]
    equation [price] not found
    r(303);
    
    .
    However, immediately after my reply, I've noticed that I should have been more careful in reading -mean- entry examples in Stata .pdf manual, as everything boils down to a variation in coding between 15 and 16 releases:
    Code:
    . lincom [email protected] [email protected]
    
     ( 1)  [email protected] - [email protected] = 0
    
    ------------------------------------------------------------------------------
            Mean |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             (1) |  -312.2587   704.9376    -0.44   0.659    -1717.197     1092.68
    ------------------------------------------------------------------------------
    
    .
    The gist of the story is that William Lisowski is >100% right when he encourages a careful (and repeated) reading of the Stata material.
    Last edited by Carlo Lazzaro; 01 Mar 2020, 10:06.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you! I also reached out to Stata Technical Support, and this was their response:

      From: Stata Technical Support <[email protected]>
      Sent: Wednesday, March 4, 2020 11:06 AM
      To: Lauren Copeland
      Subject: EXT: Re: Lincom in Stata 16

      ________________________________

      Dear Lauren,

      Thank you for contacting us.

      This is an improvement we made in Stata 16 for -mean- and a couple of
      other commands. In -help whatsnew15to16-, you will find the following
      information

      4. Estimation commands mean, proportion, ratio, and total now
      allow factor-variable notation. Old behavior is preserved under
      version control. We mention that despite factor variables being
      a superset of varlists because variables in over() are now
      interacted, which they always were, but the use of factor
      variables changes (improves) the names under which results are
      stored. Old result names are preserved under version control.

      Now factor variables allow more complex combinations in -mean- and more
      post-estimations such as -marginsplot- are available after -mean-.

      We can see the labels for the mean estimates are changed. That's why
      -lincom- cannot find the stored results using the old labels. But you
      can use version control to get the old behavior of -mean- (please check
      -help version- for more information regarding the version control).

      version 15: mean egal_scale [pw=nesw], over(female)

      lincom [egal_scale]Male - [egal_scale]Female

      Or you may update your code according to Stata 16's behavior
      (recommended) and use the new labels in -lincom-. First you can specify
      the option -coeflegend- with -mean- to view the labels.

      mean egal_scale [pw=nesw], over(female) coeflegend

      then you call the estimates using the new labels in -lincom-.

      I hope that will help. Please let us know if you have any further
      questions.


      Best regards,

      Mia Lv, Ph.D.
      Staff Statistician
      StataCorp LLC

      Comment


      • #4
        Lauren:
        thanks for sharing.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Hi All,

          Carlo's feedback is correct. I am a student and replicated his lincom solution (specific for ASDS Chapter 5.3 exercises): lincom [email protected]- [email protected].

          Thanks! I am going to share this with the class! How do we help rlincom.pdf update their code from the use of brackets?

          Samantha
          Last edited by Samantha Chiu; 05 Mar 2020, 12:18.

          Comment


          • #6
            Thank you, Lauren. The coeflegend fixed the lincom issue after the "mean" command, but not after the "proportion" command. You mentioned that mean, proportion, ratio, and total now allow factor-variable notation. Is there a different post-command from coeflegend that works with proportion?

            The specific example is below:
            proportion domestic_spying [pw=wtss]
            lincom [domestic_spying]Oppose - .5

            Thanks,
            Lee

            Comment


            • #7
              Originally posted by Lee Payne View Post
              Thank you, Lauren. The coeflegend fixed the lincom issue after the "mean" command, but not after the "proportion" command. You mentioned that mean, proportion, ratio, and total now allow factor-variable notation. Is there a different post-command from coeflegend that works with proportion?

              The specific example is below:
              proportion domestic_spying [pw=wtss]
              lincom [domestic_spying]Oppose - .5

              Thanks,
              Lee
              coeflegend does work after proportion and does so in the same way. You need to include that so that you can give lincom the proper information for what you want:

              Code:
              . version 15
              
              . proportion domestic_spying [pw=wtss],coeflegend
              
              Proportion estimation             Number of obs   =      1,362
              
              ------------------------------------------------------------------------------
                           | Proportion  Legend
              -------------+----------------------------------------------------------------
              domestic_s~g |
                    Oppose |   .5076181  _b[domestic_spying:Oppose]
                   Support |   .4923819  _b[domestic_spying:Support]
              ------------------------------------------------------------------------------
              
              . lincom [domestic_spying]Oppose - .5
              
               ( 1)  [domestic_spying]Oppose = .5
              
              ------------------------------------------------------------------------------
                Proportion |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                       (1) |   .0076181   .0151678     0.50   0.616    -.0221367     .037373
              ------------------------------------------------------------------------------
              
              . 
              . version 16
              
              . proportion domestic_spying [pw=wtss],coeflegend
              
              Proportion estimation             Number of obs   =      1,362
              
              ---------------------------------------------------------------------------------
                              | Proportion  Legend
              ----------------+----------------------------------------------------------------
              domestic_spying |
                      Oppose  |   .5076181  _b[0bn.domestic_spying]
                     Support  |   .4923819  _b[1.domestic_spying]
              ---------------------------------------------------------------------------------
              
              . lincom _b[0bn.domestic_spying] - .5
              
               ( 1)  0bn.domestic_spying = .5
              
              ------------------------------------------------------------------------------
                Proportion |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                       (1) |   .0076181   .0151678     0.50   0.616    -.0221367     .037373
              ------------------------------------------------------------------------------
              
              .

              Comment


              • #8
                Thank you, John. That works perfectly!

                Comment

                Working...
                X