Announcement

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

  • Number of observations per coefficient

    Hello Statalist,

    A reviewer recently asked for a column that lists the number of observations in each regression coefficient. I am not sure how Stata could do this. Sample regression below.

    Code:
     use http://www.stata-press.com/data/mlmus3/toenail,clear
    
    . logit outcome i.treatment i.visit, or
    
    Iteration 0:   log likelihood = -990.24352  
    Iteration 1:   log likelihood = -905.82897  
    Iteration 2:   log likelihood = -900.35401  
    Iteration 3:   log likelihood = -900.33517  
    Iteration 4:   log likelihood = -900.33517  
    
    Logistic regression                             Number of obs     =      1,908
                                                    LR chi2(7)        =     179.82
                                                    Prob > chi2       =     0.0000
    Log likelihood = -900.33517                     Pseudo R2         =     0.0908
    
    ------------------------------------------------------------------------------
         outcome | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
     1.treatment |    .829333   .0970424    -1.60   0.110     .6593677     1.04311
                 |
           visit |
              2  |   .8628304   .1499067    -0.85   0.396     .6138172    1.212863
              3  |   .7171664   .1274266    -1.87   0.061     .5062649    1.015926
              4  |   .4603416   .0880158    -4.06   0.000     .3164706    .6696179
              5  |   .1546134   .0391922    -7.36   0.000     .0940762    .2541056
              6  |   .1352603   .0369504    -7.32   0.000     .0791843    .2310476
              7  |   .1385739   .0363363    -7.54   0.000     .0828863    .2316756
                 |
           _cons |    .646659   .0865521    -3.26   0.001     .4974463    .8406292
    ------------------------------------------------------------------------------

    I tried using table

    Code:
    . table outcome treatment visit if e(sample)
    
    ----------------------------------------------------------------------------------------------------------
              |                                      visit and treatment                                      
              | ---- 1 ---    ---- 2 ---    ---- 3 ---    ---- 4 ---    ---- 5 ---    ---- 6 ---    ---- 7 ---
      outcome |    0     1       0     1       0     1       0     1       0     1       0     1       0     1
    ----------+-----------------------------------------------------------------------------------------------
            0 |   92    93      92    99      94   105     103   111     116   125     107   119     119   125
            1 |   54    55      49    48      44    40      29    29      14     8      10     8      14     6
    ----------------------------------------------------------------------------------------------------------
    But this only works for three measures at a time and won't work if I use any additional variables. Anyone?

  • #2
    I don't think I understand; in the regression you show there are 1,908 observations and that is true for the entire regression and for each coefficient.

    Comment


    • #3
      You're totally right. I'm phrasing this all wrong, sorry. I think he wants a count or a frequency of a given value next to the estimate. So in the case of treatment, if the treatment is split 50/50 across 1908, he wants to see a frequency of 954 for treatment=1.

      Comment


      • #4
        Ivan:
        by default Stata omits all the observations with missing values in any variables, adopting a complete case analysis, or CCA approach. Hence, as Rich pointed out, the number of observations for each coefficient=number of observed values of the variable with the highest number of missing data.
        Conversely, reviewer's request seems to imply an available case analysis approach, or ACA (ie, reporting the number of observed values for each variable included in the regression model;obviously, they can be really different).
        That said (and considering that each reviewer deserves a polite reply), you can provide the table required in the revised version of the manuscript, but you should also point out that regression model ran under a CCA (and not an ACA) approach.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Just an additional comment: if you wish to provide the number of cases for each level of predictor according to the regression model, you can do it.

          Use the "if e(sample)" clause for the tabulations. Make sure to use - tabulate - after the - regress - command.

          Hopefully that will solve the issue and satisfy the reviewer's demands.
          Best regards,

          Marcos

          Comment


          • #6
            Thanks all, Lots of useful comments here.

            Comment

            Working...
            X