Announcement

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

  • Problem with the output for the margins post command

    Hi Statalisters,
    For the below example code, I defined label values for the group variable. However, Stata does not report the label values for the group variable in the output for the margins command. Instead, Stata reports the numeric values for the group variable. I wonder how to force Stata to report the label values instead of the numeric values.
    Thanks,
    NM


    use https://www.stata-press.com/data/r17/estimability, clear
    label define group 1 "1.Northeast" 2 "2.Midwest" 3 "3.West" 4 "4.Foreign" 5"5.South"
    label values group group

    quietly: regress y i.sex i.group
    margins, at ( sex=0 group=(1 (1) 5))
    Delta-method
    Margin Std. Err. t P>t [95% Conf. Interval]
    _at
    1 24.4537 2.107566 11.60 0.000 20.24207 28.66534
    2 19.88837 1.494867 13.30 0.000 16.90112 22.87563
    3 19.07767 .9583984 19.91 0.000 17.16247 20.99288
    4 19.125 1.825206 10.48 0.000 15.47762 22.77238
    5 21 3.650411 5.75 0.000 13.70524 28.29476

  • #2
    If you want the labeling, don't put group in the -at()- option: put it in the -margins- varlist:
    Code:
    . margins group, at(sex = 0)
    
    Adjusted predictions                                        Number of obs = 69
    Model VCE: OLS
    
    Expression: Linear prediction, predict()
    At: sex = 0
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
           group |
    1.Northeast  |    24.4537   2.107566    11.60   0.000     20.24207    28.66534
      2.Midwest  |   19.88837   1.494867    13.30   0.000     16.90112    22.87563
         3.West  |   19.07767   .9583984    19.91   0.000     17.16247    20.99288
      4.Foreign  |     19.125   1.825206    10.48   0.000     15.47762    22.77238
        5.South  |         21   3.650411     5.75   0.000     13.70524    28.29476
    ------------------------------------------------------------------------------

    Comment

    Working...
    X