Announcement

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

  • Displaying Predictive Margins per 1,000

    Dear all,

    I am running margins after an nbreg model using the code below:
    Code:
     margins pre_year_cat
    Here are the results:
    Code:
    Expression: Predicted number of events, predict()
    
    Delta-method
    Margin    std. err.     z     P>z    [95% conf.    interval]
    
    pre_year_cat 
    2015      .1045401    .0014501    72.09    0.000    .1016979    .1073822
    2016      .1289053     .001505    85.65    0.000    .1259556    .131855
    2017      .1270988    .0014596    87.08    0.000    .124238    .1299597
    2018      .1417483    .0015568    91.05    0.000    .1386971    .1447995
    2019      .1388607    .0014831    93.63    0.000    .1359538    .1417676
    2020      .1742347    .0017418   100.03    0.000    .1708207    .1776486
    2021      .1909975    .0018776   101.73    0.000    .1873175    .1946775
    2022      .1855599    .0019013    97.60    0.000    .1818335    .1892863
    How can I show the margins per 1,000? Instead of .1045401, I want them to be 104, and I do not want to calculate them manually as I plan to use marginsplot afterwards.

  • #2
    Code:
    margins pre_year_cat, expression(1000*predict(pr))

    Comment


    • #3
      Thanks Clyde.

      I tried the code and it does produce the below result

      Code:
      nbreg total_CT_AT ib(first).pre_year_cat ib(first).age_grp
      
      Negative binomial regression                          Number of obs =  552,366
                                                            LR chi2(10)   = 18053.38
      Dispersion: mean                                      Prob > chi2   =   0.0000
      Log likelihood = -235929.96                           Pseudo R2     =   0.0369
      
      ------------------------------------------------------------------------------
       total_CT_AT | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
      -------------+----------------------------------------------------------------
      pre_year_cat |
             2016  |   .2095076    .018123    11.56   0.000     .1739872     .245028
             2017  |   .1953946   .0180015    10.85   0.000     .1601123    .2306769
             2018  |   .3044825   .0176856    17.22   0.000     .2698194    .3391456
             2019  |    .283901   .0175018    16.22   0.000      .249598    .3182039
             2020  |   .5108328   .0170897    29.89   0.000     .4773376     .544328
             2021  |   .6026901   .0169962    35.46   0.000     .5693781    .6360021
             2022  |   .5738074   .0172445    33.27   0.000     .5400088    .6076059
                   |
           age_grp |
            35-54  |   .6154216    .012735    48.33   0.000     .5904615    .6403817
            55-74  |   1.033554   .0123243    83.86   0.000     1.009398    1.057709
              75+  |   1.374228   .0122126   112.53   0.000     1.350292    1.398164
                   |
             _cons |  -3.060938   .0166162  -184.21   0.000    -3.093505    -3.02837
      -------------+----------------------------------------------------------------
          /lnalpha |   .2328044   .0164584                      .2005465    .2650623
      -------------+----------------------------------------------------------------
             alpha |   1.262135   .0207727                       1.22207    1.303512
      ------------------------------------------------------------------------------
      LR test of alpha=0: chibar2(01) = 7314.49              Prob >= chibar2 = 0.000
      
      . margins pre_year_cat, expression(1000*predict(pr))
      option pr not allowed
      r(198);
      It may help if I gave an example of the data

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input float(total_CT_AT pre_year_cat) int age_grp
      0 1 2
      0 1 0
      0 1 2
      0 1 2
      0 1 0
      0 1 2
      0 1 1
      0 1 2
      0 1 0
      0 1 0
      0 1 3
      0 1 2
      0 1 2
      0 1 1
      0 1 0
      0 1 2
      1 1 1
      0 1 2
      0 1 2
      0 1 1
      0 1 3
      0 1 0
      0 1 3
      0 1 2
      0 1 0
      1 1 3
      1 1 0
      0 1 1
      0 1 1
      0 1 3
      0 1 1
      0 1 1
      0 1 2
      0 1 1
      0 1 0
      0 1 3
      0 1 1
      0 1 2
      0 1 1
      1 1 2
      0 1 2
      0 1 0
      0 1 3
      0 1 1
      0 1 1
      0 1 2
      0 1 1
      0 1 3
      0 1 1
      0 1 3
      0 1 0
      0 1 1
      0 1 0
      0 1 2
      0 1 0
      0 1 0
      0 1 1
      0 1 2
      0 1 1
      0 1 1
      1 1 3
      1 1 3
      0 1 0
      0 1 0
      0 1 3
      0 1 3
      1 1 0
      0 1 0
      0 1 2
      0 1 1
      1 1 3
      0 1 3
      0 1 1
      1 1 0
      0 1 0
      0 1 0
      0 1 3
      0 1 2
      0 1 0
      0 1 3
      0 1 1
      0 1 3
      0 1 2
      0 1 3
      0 1 1
      0 1 1
      0 1 0
      0 1 1
      0 1 0
      0 1 2
      0 1 2
      0 1 3
      0 1 3
      0 1 1
      0 1 3
      0 1 1
      0 1 1
      0 1 1
      0 1 2
      1 1 3
      end
      label values pre_year_cat pre_year_cat
      label def pre_year_cat 1 "2015", modify
      label values age_grp age_grp
      label def age_grp 0 "18-34", modify
      label def age_grp 1 "35-54", modify
      label def age_grp 2 "55-74", modify
      label def age_grp 3 "75+", modify

      Comment


      • #4
        Sorry, my mistake:
        Code:
        margins pre_year_cat, expression(1000*predict())
        No -pr- inside -predict()-.

        Comment


        • #5
          Thank you, it worked.

          Comment

          Working...
          X