Announcement

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

  • Average responses from multi-level mixed-effect logistic regression null model

    Hi STATA forum,

    I have panel data, whereby each month, of a cohort of 1000 participants, 200 participants were randomly selected to participate in surveys. Over the 5 months, some respondents were sampled multiple times, therefore I have uneven repeated measures within individuals.

    I need to obtain the average probability that y=1 across all the data therefore am using null models with the code 'merqrlogit outcome || cluster || id: || month to account for the survey design.

    I can obtain the average probability by the 'predict' command, but how can I also obtain confidence intervals for this?

    Many thanks in advance,
    Emily

  • #2
    You do not show your commands, but margins can generate the predictions and CIs. Note that meqrlogit has been superseded by the -intmethod(pcag)- option of melogit.

    Code:
    webuse bangladesh, clear
    keep in 1/150
    meqrlogit c_use urban age child* || district: urban, covariance(unstructured)
    predict pred, mu fixedonly
    list pred in 1/10, sep(0)
    gen obs_no=_n
    margins, over(obs_no) predict(mu fixedonly)
    Res.:

    Code:
    . 
    . list pred in 1/10, sep(0)
    
         +----------+
         |     pred |
         |----------|
      1. | .7821657 |
      2. | .5287604 |
      3. | .8638175 |
      4. | .8304574 |
      5. | .5899113 |
      6. | .5748069 |
      7. | .7821657 |
      8. | .8766975 |
      9. | .9041128 |
     10. | .8589082 |
         +----------+
    
    . 
    . gen obs_no=_n
    
    . 
    . margins, over(obs_no) predict(mu fixedonly)
    
    Predictive margins                              Number of obs     =        150
    
    Expression   : Predicted mean, fixed portion only, predict(mu fixedonly)
    over         : obs_no
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          obs_no |
              1  |   .7821657   .2388479     3.27   0.001     .3140324    1.250299
              2  |   .5287604   .3341776     1.58   0.114    -.1262157    1.183736
              3  |   .8638175    .159304     5.42   0.000     .5515874    1.176048
              4  |   .8304575   .1867743     4.45   0.000     .4643866    1.196528
              5  |   .5899113   .3264746     1.81   0.071    -.0499671     1.22979
              6  |   .5748069   .3280537     1.75   0.080    -.0681667     1.21778
              7  |   .7821657   .2388479     3.27   0.001     .3140324    1.250299
              8  |   .8766976   .1458328     6.01   0.000     .5908706    1.162525
              9  |   .9041128    .119251     7.58   0.000     .6703852     1.13784
             10  |   .8589082   .1605047     5.35   0.000     .5443247    1.173492
             11  |   .5748069   .3280537     1.75   0.080    -.0681667     1.21778
             12  |   .5055014   .3380197     1.50   0.135     -.157005    1.168008
             13  |   .9013867   .1223321     7.37   0.000     .6616201    1.141153
             14  |   .8431738   .1745962     4.83   0.000     .5009715    1.185376
             15  |   .8662684   .1542791     5.61   0.000     .5638868     1.16865
             16  |   .8472366    .170854     4.96   0.000     .5123688    1.182104
             17  |   .5287604   .3341776     1.58   0.114    -.1262157    1.183736
             18  |   .8662684   .1542791     5.61   0.000     .5638868     1.16865
             19  |   .9067714   .1162994     7.80   0.000     .6788288    1.134714
             20  |   .8810736   .1413507     6.23   0.000     .6040313    1.158116
             21  |   .5210163   .3354043     1.55   0.120    -.1363642    1.178397
             22  |   .5595621   .3298571     1.70   0.090     -.086946     1.20607
             23  |   .8551028   .1638139     5.22   0.000     .5340335    1.176172
             24  |    .860123   .1633604     5.27   0.000     .5399424    1.180304
             25  |   .9013867   .1223321     7.37   0.000     .6616201    1.141153
             26  |    .802588    .215798     3.72   0.000     .3796316    1.225544
             27  |   .5364907   .3330083     1.61   0.107    -.1161935    1.189175
             28  |   .8985917   .1255482     7.16   0.000     .6525217    1.144662
             29  |   .9041128    .119251     7.58   0.000     .6703852     1.13784
             30  |   .8927903   .1324064     6.74   0.000     .6332785    1.152302
             31  |   .8904941   .1322458     6.73   0.000     .6312972    1.149691
             32  |   .8777809   .1446486     6.07   0.000     .5942749    1.161287
             33  |   .8934858   .1294547     6.90   0.000     .6397593    1.147212
             34  |   .4132266   .3561306     1.16   0.246    -.2847765     1.11123
             35  |   .8304575   .1867743     4.45   0.000     .4643866    1.196528
             36  |    .802588    .215798     3.72   0.000     .3796316    1.225544
             37  |   .8304575   .1867743     4.45   0.000     .4643866    1.196528
             38  |   .8390236   .1784937     4.70   0.000     .4891824    1.188865
             39  |   .8810736   .1413507     6.23   0.000     .6040313    1.158116
             40  |   .8832558    .140727     6.28   0.000     .6074361    1.159076
             41  |    .802588    .215798     3.72   0.000     .3796316    1.225544
             42  |   .8551028   .1638139     5.22   0.000     .5340335    1.176172
             43  |   .9167548    .105681     8.67   0.000     .7096239    1.123886
             44  |   .8431738   .1745962     4.83   0.000     .5009715    1.185376
             45  |   .9093637   .1134719     8.01   0.000     .6869629    1.131765
             46  |   .8842892    .138188     6.40   0.000     .6134456    1.155133
             47  |   .8698252   .1513507     5.75   0.000     .5731832    1.166467
             48  |   .9190942   .1032967     8.90   0.000     .7166365    1.121552
             49  |   .8589082   .1605047     5.35   0.000     .5443247    1.173492
             50  |   .8230027   .2078722     3.96   0.000     .4155806    1.230425
             51  |   .5823784   .3272374     1.78   0.075     -.058995    1.223752
             52  |   .8777809   .1446486     6.07   0.000     .5942749    1.161287
             53  |    .513262   .3366861     1.52   0.127    -.1466305    1.173155
             54  |   .5210163   .3354043     1.55   0.120    -.1363642    1.178397
             55  |   .8934858   .1294547     6.90   0.000     .6397593    1.147212
             56  |    .859244   .1765071     4.87   0.000     .5132965    1.205191
             57  |    .887429    .135155     6.57   0.000     .6225301    1.152328
             58  |   .8347851   .1825514     4.57   0.000     .4769908    1.192579
             59  |   .9067714   .1162994     7.80   0.000     .6788288    1.134714
             60  |   .5748069   .3280537     1.75   0.080    -.0681667     1.21778
             61  |   .7976215   .2212774     3.60   0.000     .3639257    1.231317
             62  |   .8842892    .138188     6.40   0.000     .6134456    1.155133
             63  |   .8810736   .1413507     6.23   0.000     .6040313    1.158116
             64  |   .2434171    .119059     2.04   0.041     .0100658    .4767684
             65  |   .3458865   .1553856     2.23   0.026     .0413362    .6504367
             66  |   .2491817   .1188963     2.10   0.036     .0161491    .4822142
             67  |   .2856395   .1238231     2.31   0.021     .0429507    .5283284
             68  |   .3388945   .1504427     2.25   0.024     .0440322    .6337569
             69  |    .091355   .0688107     1.33   0.184    -.0435115    .2262215
             70  |   .3768609    .152581     2.47   0.014     .0778076    .6759141
             71  |   .0939657   .0711678     1.32   0.187    -.0455207     .233452
             72  |   .2920181   .1258316     2.32   0.020     .0453927    .5386434
             73  |   .2072874   .1575846     1.32   0.188    -.1015727    .5161475
             74  |   .3768609    .152581     2.47   0.014     .0778076    .6759141
             75  |   .3138071   .1361461     2.30   0.021     .0469655    .5806486
             76  |   .0727205   .0555199     1.31   0.190    -.0360965    .1815375
             77  |   .0792582   .0594629     1.33   0.183     -.037287    .1958033
             78  |   .3251217   .1415684     2.30   0.022     .0476527    .6025908
             79  |   .2984795   .1282174     2.33   0.020     .0471781    .5497809
             80  |   .2609815   .1193137     2.19   0.029     .0271309    .4948321
             81  |   .2609815   .1193137     2.19   0.029     .0271309    .4948321
             82  |   .0839107   .0627445     1.34   0.181    -.0390663    .2068876
             83  |   .2609815   .1193137     2.19   0.029     .0271309    .4948321
             84  |   .2670152   .1199473     2.23   0.026     .0319229    .5021075
             85  |   .2793454   .1221826     2.29   0.022     .0398718    .5188189
             86  |   .2984795   .1282174     2.33   0.020     .0471781    .5497809
             87  |   .0727205   .0555199     1.31   0.190    -.0360965    .1815375
             88  |   .3116449   .1341363     2.32   0.020     .0487426    .5745471
             89  |   .2434171    .119059     2.04   0.041     .0100658    .4767684
             90  |   .3388945   .1504427     2.25   0.024     .0440322    .6337569
             91  |   .0543631   .0481007     1.13   0.258    -.0399125    .1486387
             92  |   .3251217   .1415684     2.30   0.022     .0476527    .6025908
             93  |   .3768609    .152581     2.47   0.014     .0778076    .6759141
             94  |   .2793454   .1221826     2.29   0.022     .0398718    .5188189
             95  |   .3189474   .1818043     1.75   0.079    -.0373826    .6752773
             96  |   .3116449   .1341363     2.32   0.020     .0487426    .5745471
             97  |   .2491817   .1188963     2.10   0.036     .0161491    .4822142
             98  |   .2670152   .1199473     2.23   0.026     .0319229    .5021075
             99  |   .4502545    .187544     2.40   0.016     .0826749     .817834
            100  |   .2569528   .1435908     1.79   0.074    -.0244801    .5383856
            101  |   .2984795   .1282174     2.33   0.020     .0471781    .5497809
            102  |   .3481661   .1415383     2.46   0.014     .0707561     .625576
            103  |   .3116449   .1341363     2.32   0.020     .0487426    .5745471
            104  |   .2159703   .1224732     1.76   0.078    -.0240728    .4560134
            105  |   .3325875   .1788597     1.86   0.063    -.0179711    .6831461
            106  |   .2377437   .1194319     1.99   0.047     .0036615    .4718259
            107  |   .2609815   .1193137     2.19   0.029     .0271309    .4948321
            108  |   .2056392   .1245668     1.65   0.099    -.0385071    .4497856
            109  |   .0939657   .0711678     1.32   0.187    -.0455207     .233452
            110  |   .4502545    .187544     2.40   0.016     .0826749     .817834
            111  |   .0686419   .0534427     1.28   0.199    -.0361039    .1733878
            112  |   .0748425   .0567152     1.32   0.187    -.0363172    .1860022
            113  |   .3005903   .1363037     2.21   0.027     .0334399    .5677406
            114  |   .0666831   .0525434     1.27   0.204    -.0363002    .1696663
            115  |   .2920181   .1258316     2.32   0.020     .0453927    .5386434
            116  |   .3251217   .1415684     2.30   0.022     .0476527    .6025908
            117  |   .2510686   .1451214     1.73   0.084    -.0333642    .5355013
            118  |   .3251217   .1415684     2.30   0.022     .0476527    .6025908
            119  |   .3623909   .1463029     2.48   0.013     .0756424    .6491394
            120  |   .0939657   .0711678     1.32   0.187    -.0455207     .233452
            121  |   .3623909   .1463029     2.48   0.013     .0756424    .6491394
            122  |   .2006128   .1256786     1.60   0.110    -.0457127    .4469384
            123  |   .3050223   .1309854     2.33   0.020     .0482957     .561749
            124  |   .3824584   .1740666     2.20   0.028     .0412941    .7236226
            125  |   .2813751   .1384247     2.03   0.042     .0100676    .5526826
            126  |   .3623909   .1463029     2.48   0.013     .0756424    .6491394
            127  |   .2670152   .1199473     2.23   0.026     .0319229    .5021075
            128  |   .3050223   .1309854     2.33   0.020     .0482957     .561749
            129  |   .3205324   .1365235     2.35   0.019     .0529513    .5881134
            130  |   .0888097   .0666258     1.33   0.183    -.0417745    .2193939
            131  |   .2491817   .1188963     2.10   0.036     .0161491    .4822142
            132  |   .0792582   .0594629     1.33   0.183     -.037287    .1958033
            133  |   .3411521   .1397301     2.44   0.015     .0672862     .615018
            134  |   .0939657   .0711678     1.32   0.187    -.0455207     .233452
            135  |   .3411521   .1397301     2.44   0.015     .0672862     .615018
            136  |   .3138071   .1361461     2.30   0.021     .0469655    .5806486
            137  |   .4502545    .187544     2.40   0.016     .0826749     .817834
            138  |   .8766976   .1458328     6.01   0.000     .5908706    1.162525
            139  |   .5518952   .3308475     1.67   0.095    -.0965539    1.200344
            140  |   .9067714   .1162994     7.80   0.000     .6788288    1.134714
            141  |   .8551028   .1638139     5.22   0.000     .5340335    1.176172
            142  |   .8744101   .1480874     5.90   0.000     .5841641    1.164656
            143  |    .513262   .3366861     1.52   0.127    -.1466305    1.173155
            144  |   .8472366    .170854     4.96   0.000     .5123688    1.182104
            145  |   .8403777   .1862357     4.51   0.000     .4753625    1.205393
            146  |   .8347851   .1825514     4.57   0.000     .4769908    1.192579
            147  |   .8662684   .1542791     5.61   0.000     .5638868     1.16865
            148  |   .9167548    .105681     8.67   0.000     .7096239    1.123886
            149  |   .8985917   .1255482     7.16   0.000     .6525217    1.144662
            150  |   .8551028   .1638139     5.22   0.000     .5340335    1.176172
    ------------------------------------------------------------------------------
    
    .

    Comment

    Working...
    X