Announcement

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

  • Ologit Model Marginsplot Dropping Group from Factor Variable

    Using Stata V13 I am trying to 1) estimate an ologit model, 2) estimate marginal effects, and 3) plot the marginal effects. I include a factor variable for cohort or generation and a covariate measuring the year of the survey. When I use the margins command specifying both the factor variable and covariate, the margins look fine. But, when I plot the margins, one of the groups in the factor variable is not shown on the graph.

    Here is the code from the ologit estimation:

    Code:
    . ologit conpressrev i.cohort1 c.year i.race
    
    Iteration 0:   log likelihood = -27524.804
    Iteration 1:   log likelihood = -26544.676
    Iteration 2:   log likelihood = -26536.271
    Iteration 3:   log likelihood = -26536.264
    Iteration 4:   log likelihood = -26536.264
    
    Ordered logistic regression                       Number of obs   =      27845
                                                      LR chi2(5)      =    1977.08
                                                      Prob > chi2     =     0.0000
    Log likelihood = -26536.264                       Pseudo R2       =     0.0359
    
    ------------------------------------------------------------------------------
     conpressrev |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         cohort1 |
        Boomers  |   .0969397   .0267096     3.63   0.000     .0445898    .1492896
          Gen X  |   .0987783   .0389694     2.53   0.011     .0223997    .1751569
    Millennials  |   .3674232   .0737857     4.98   0.000     .2228059    .5120404
                 |
            year |   -.047217    .001171   -40.32   0.000    -.0495121   -.0449219
                 |
            race |
          black  |   .1088965   .0324684     3.35   0.001     .0452596    .1725333
    -------------+----------------------------------------------------------------
           /cut1 |  -94.73947   2.328825                     -99.30388   -90.17506
           /cut2 |  -92.12877   2.324229                     -96.68418   -87.57337
    ------------------------------------------------------------------------------
    And, here is an edited (shortened) listing of the margins:
    Code:
    . margins cohort1, at(year=(1973(1)2010)) predict(outcome(1))
    
    ---------------------------------------------------------------------------------
                    |            Delta-method
                    |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ----------------+----------------------------------------------------------------
        _at#cohort1 |
          1#Silent  |   .1684745   .0039917    42.21   0.000     .1606509    .1762982
         1#Boomers  |   .1553295   .0037288    41.66   0.000     .1480211    .1626379
           1#Gen X  |   .1550885   .0058258    26.62   0.000     .1436702    .1665068
     1#Millennials  |   .1230527   .0085103    14.46   0.000     .1063727    .1397326
          2#Silent  |   .1751917   .0040106    43.68   0.000     .1673311    .1830523
         2#Boomers  |   .1616245   .0037285    43.35   0.000     .1543167    .1689323
           2#Gen X  |   .1613756   .0058994    27.35   0.000      .149813    .1729382
     2#Millennials  |   .1282384   .0087473    14.66   0.000      .111094    .1453828
          3#Silent  |    .182118   .0040287    45.21   0.000     .1742219    .1900141
         3#Boomers  |   .1681239   .0037248    45.14   0.000     .1608233    .1754244
           3#Gen X  |   .1678669   .0059701    28.12   0.000     .1561657    .1795682
             .
             .
             .
         38#Silent  |   .5374293    .008247    65.17   0.000     .5212655    .5535931
        38#Boomers  |   .5132707   .0068983    74.41   0.000     .4997503     .526791
          38#Gen X  |   .5128115   .0078102    65.66   0.000     .4975038    .5281193
    38#Millennials  |   .4458914   .0164728    27.07   0.000     .4136053    .4781775
    ---------------------------------------------------------------------------------
    Note how there are margins estimate for all of the generation groups (Silent, Boomers, Gen X, and Millennials). So, I expect marginsplot to reflect all of these groups.

    Here is the Stata code for the plot:
    Code:
    #d ;
    marginsplot, recast(line) noci plotopts(lw(thick)) 
      title("Hardly any confidence") 
      xtitle("") ytitle("")
      ylabel(, format(%3.1f) angle(0))
      legend(row(1) region(color(none)))
      graphregion(color(white))
      name(conpressrev1, replace);
    #d cr
    I have attached a png graphic file showing how the Boomer generation is missing.

    Any ideas on why this group would not be graphed?

    Click image for larger version

Name:	conpressrev1.png
Views:	2
Size:	12.0 KB
ID:	1292604


    Best,
    Alan

  • #2
    Actually when using factor variables (i.varname) Stata pick one "base level" of the variable, and compares the effects of the other values to this base variable.
    So I guess this is why your margins are only computes for "Silent", "Boomers" "Gen X" and "Millenials". The missing value must have been picked as base value.

    see http://www.ats.ucla.edu/stat/stata/s...fv_seminar.htm for preciser details.

    Best,
    Charlie

    Comment


    • #3
      Charlie,

      Thank you for your comment. Unfortunately, I don't think that is happening. First, the default omitted category is the one with the lowest numerical value which in my case is the silent generation, not the boomers:
      Code:
      cohort1 -- year of birth
      -------------------------------------------------------------------
                            |      Freq.    Percent      Valid       Cum.
      ----------------------+--------------------------------------------
      Valid   1 Silent      |      12631      23.27      29.68      29.68
              2 Boomers     |      20364      37.52      47.85      77.52
              3 Gen X       |       7994      14.73      18.78      96.31
              4 Millennials |       1572       2.90       3.69     100.00
              Total         |      42561      78.42     100.00           
      Missing .             |      11715      21.58                      
      Total                 |      54276     100.00                      
      -------------------------------------------------------------------
      Second, in my experience, if -margins- produces a results for factors (which it does in this case), -marginsplot- graphs them. Third, I have another analogous dependent variable that produces the expected results.

      The dependent variable measures confidence in American institutions. For example, one measures the confidence in banks and the other the confidence in the press:
      Code:
      confinanrev -- confid in banks & financial institutions
      --------------------------------------------------------------------
                             |      Freq.    Percent      Valid       Cum.
      -----------------------+--------------------------------------------
      Valid   1 hardly any   |       6078      11.20      18.16      18.16
              2 only some    |      18767      34.58      56.06      74.22
              3 a great deal |       8630      15.90      25.78     100.00
              Total          |      33475      61.68     100.00           
      Missing .              |      20801      38.32                      
      Total                  |      54276     100.00                      
      --------------------------------------------------------------------
      
      conpressrev -- confidence in press
      --------------------------------------------------------------------
                             |      Freq.    Percent      Valid       Cum.
      -----------------------+--------------------------------------------
      Valid   1 hardly any   |      11000      20.27      30.26      30.26
              2 only some    |      19497      35.92      53.64      83.90
              3 a great deal |       5851      10.78      16.10     100.00
              Total          |      36348      66.97     100.00           
      Missing .              |      17928      33.03                      
      Total                  |      54276     100.00                      
      --------------------------------------------------------------------
      While the model for the confidence in the press fails as I detailed in an earlier post, here is what I get when I use the confidence in banks dependent measure. Not that the boomers are show in this graphic:
      Click image for larger version

Name:	CONFINANREV1.png
Views:	1
Size:	10.2 KB
ID:	1292663

      Best,
      Alan

      Comment


      • #4
        Dear Allan,
        I think there is nothing wrong with marginsplot. My sharp eyes have noticed that there is almost perfect overlap on the graph between Boomers and Gen X groups (use the graph editor to see that). This might be related to the way you construct the four groups.

        Comment


        • #5
          What an eye, I think you are right, the values of margins reported in the table 2 of first post also indicates very close values between Boomers and Gen X.

          Comment


          • #6
            Oded and Charlie both have a good eye (I need a trip to the ophthalmologist). I went back in to one of the graphs and changed the line widths and colors of the overlapping lines to show how similar they are (see the graph below). So, -margins- and -marginsplot- seems to be working as expected. Pesky results go tin the way.

            Click image for larger version

Name:	conpressrev3.png
Views:	1
Size:	10.6 KB
ID:	1292696


            To close this thread (from my perspective) I show a graph of a a dependent variable measuring confidence in financial institutions and banks over time, by named generations. Here, the Boomers stand out, as do all of the other generations:

            Click image for larger version

Name:	confinanlogit.png
Views:	1
Size:	37.5 KB
ID:	1292697

            You can see clearly where the gains and losses in confidence in banks are by generation. Again, I thank everybody for their comments and suggestions.

            Best,
            Alan

            Comment

            Working...
            X