. do "C:\Users\hstryhn\AppData\Local\Temp\STD14bc_000000.tmp"

. * do-file for lecture 4a of VHM 802/812, Winter 2018
. version 15 /* works also with versions 13-14 */

. set more off

. cd "r:\data_stata"
r:\data_stata

.
. use nocardia.dta, clear

. tabulate casecont dclox, chi2 row exact lrchi2

+----------------+
| Key            |
+----------------+
|   frequency    |
| row percentage |
+----------------+

           |  Cloxacillin used on
    Case - |         farm
   Control |        no        yes |     Total
-----------+----------------------+----------
        no |        35         19 |        54
           |     64.81      35.19 |    100.00
-----------+----------------------+----------
       yes |        46          8 |        54
           |     85.19      14.81 |    100.00
-----------+----------------------+----------
     Total |        81         27 |       108
           |     75.00      25.00 |    100.00

          Pearson chi2(1) =   5.9753   Pr = 0.015
 likelihood-ratio chi2(1) =   6.1130   Pr = 0.013
           Fisher's exact =                 0.025
   1-sided Fisher's exact =                 0.013

. cc casecont dclox
                                                         Proportion
                 |   Exposed   Unexposed  |      Total     Exposed
-----------------+------------------------+------------------------
           Cases |         8          46  |         54       0.1481
        Controls |        19          35  |         54       0.3519
-----------------+------------------------+------------------------
           Total |        27          81  |        108       0.2500
                 |                        |
                 |      Point estimate    |    [95% Conf. Interval]
                 +------------------------+------------------------
      Odds ratio |         .3203661       |    .1091298    .8852277 (exact)
 Prev. frac. ex. |         .6796339       |    .1147723    .8908702 (exact)
 Prev. frac. pop |         .2391304       |
                 +------------------------+------------------------
                               chi2(1) =     5.98  Pr>chi2 = 0.0145

. * logistic regression for case-control design
. logit casecont dclox

Iteration 0:   log likelihood = -74.859896
Iteration 1:   log likelihood = -71.810582
Iteration 2:   log likelihood = -71.803418
Iteration 3:   log likelihood = -71.803418

Logistic regression                             Number of obs     =        108
                                                LR chi2(1)        =       6.11
                                                Prob > chi2       =     0.0134
Log likelihood = -71.803418                     Pseudo R2         =     0.0408

-------------+----------------------------------------------------------------
     casecont |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
       dclox |   -1.138291    .4774329     -2.38    0.017     -2.074042    -.2025395
       _cons |    .2732933    .2243002      1.22    0.223     -.1663269     .7129136
-------------+----------------------------------------------------------------

. logit casecont dclox, or /* displays ORs */

Iteration 0:   log likelihood = -74.859896
Iteration 1:   log likelihood = -71.810582
Iteration 2:   log likelihood = -71.803418
Iteration 3:   log likelihood = -71.803418

Logistic regression                             Number of obs     =        108
                                                LR chi2(1)        =       6.11
                                                Prob > chi2       =     0.0134
Log likelihood = -71.803418                     Pseudo R2         =     0.0408

-------------+----------------------------------------------------------------
     casecont | Odds Ratio    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
       dclox |    .3203661    .1529533     -2.38    0.017      .1256768     .8166542
       _cons |    1.314286    .2947945      1.22    0.223      .8467694     2.039926
-------------+----------------------------------------------------------------


Note: _cons estimates baseline odds.


. logistic casecont dclox  /* same using logistic command */

Logistic regression                             Number of obs     =        108
                                                LR chi2(1)        =       6.11
                                                Prob > chi2       =     0.0134
Log likelihood = -71.803418                     Pseudo R2         =     0.0408

-------------+----------------------------------------------------------------
     casecont | Odds Ratio    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
       dclox |    .3203661    .1529533     -2.38    0.017      .1256768     .8166542
       _cons |    1.314286    .2947945      1.22    0.223      .8467694     2.039926
-------------+----------------------------------------------------------------


Note: _cons estimates baseline odds.


. logit dclox casecont /* to demonstrate same log(OR) */

Iteration 0:   log likelihood = -60.732196
Iteration 1:   log likelihood = -57.735076
Iteration 2:   log likelihood = -57.675769
Iteration 3:   log likelihood = -57.675718
Iteration 4:   log likelihood = -57.675718

Logistic regression                             Number of obs     =        108
                                                LR chi2(1)        =       6.11
                                                Prob > chi2       =     0.0134
Log likelihood = -57.675718                     Pseudo R2         =     0.0503

-------------+----------------------------------------------------------------
        dclox |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
    casecont |   -1.138291    .4774329     -2.38    0.017     -2.074042    -.2025396
       _cons |   -.6109091    .2849614     -2.14    0.032     -1.169423     -.052395
-------------+----------------------------------------------------------------

.
. * logistic regression for categorical predictor
. tabulate casecont dbarn, chi2 row exact lrchi2

+----------------+
| Key            |
+----------------+
|   frequency    |
| row percentage |
+----------------+

Enumerating sample-space combinations:
stage 3:  enumerations = 1
stage 2:  enumerations = 3
stage 1:  enumerations = 0

    Case - |         dry cow housing
   Control |  freestal   tiestall      other |     Total
-----------+---------------------------------+----------
        no |        13         38          3 |        54
           |     24.07      70.37       5.56 |    100.00
-----------+---------------------------------+----------
       yes |        22         29          3 |        54
           |     40.74      53.70       5.56 |    100.00
-----------+---------------------------------+----------
     Total |        35         67          6 |       108
           |     32.41      62.04       5.56 |    100.00

          Pearson chi2(2) =   3.5232   Pr = 0.172
 likelihood-ratio chi2(2) =   3.5531   Pr = 0.169
           Fisher's exact =                 0.157

. logit casecont i.dbarn

Iteration 0:   log likelihood = -74.859896
Iteration 1:   log likelihood = -73.083934
Iteration 2:   log likelihood = -73.083342
Iteration 3:   log likelihood = -73.083342

Logistic regression                             Number of obs     =        108
                                                LR chi2(2)        =       3.55
                                                Prob > chi2       =     0.1692
Log likelihood = -73.083342                     Pseudo R2         =     0.0237

-------------+----------------------------------------------------------------
     casecont |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
       dbarn |
   tiestall  |   -.7963834    .4279909     -1.86    0.063      -1.63523     .0424632
      other  |   -.5260931    .8882816     -0.59    0.554     -2.267093     1.214907
             |
       _cons |    .5260931    .3498251      1.50    0.133     -.1595516     1.211738
-------------+----------------------------------------------------------------

. logistic casecont i.dbarn

Logistic regression                             Number of obs     =        108
                                                LR chi2(2)        =       3.55
                                                Prob > chi2       =     0.1692
Log likelihood = -73.083342                     Pseudo R2         =     0.0237

-------------+----------------------------------------------------------------
     casecont | Odds Ratio    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
       dbarn |
   tiestall  |    .4509569    .1930054     -1.86    0.063      .1949075     1.043378
      other  |    .5909091    .5248937     -0.59    0.554      .1036129      3.36998
             |
       _cons |    1.692308    .5920118      1.50    0.133       .852526     3.359317
-------------+----------------------------------------------------------------


Note: _cons estimates baseline odds.


. testparm i.dbarn /* multiple Wald test for dbarn */


 ( 1)  [casecont]2.dbarn = 0


 ( 2)  [casecont]3.dbarn = 0


           chi2(  2) =    3.46
         Prob > chi2 =    0.1771

.
. * multiple logistic regression
. logit casecont dneo dclox dcpct

Iteration 0:   log likelihood = -74.859896
Iteration 1:   log likelihood = -54.156164
Iteration 2:   log likelihood = -53.993934
Iteration 3:   log likelihood = -53.993656
Iteration 4:   log likelihood = -53.993656

Logistic regression                             Number of obs     =        108
                                                LR chi2(3)        =      41.73
                                                Prob > chi2       =     0.0000
Log likelihood = -53.993656                     Pseudo R2         =     0.2787

-------------+----------------------------------------------------------------
     casecont |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
        dneo |    2.212564    .5780423      3.83    0.000      1.079622     3.345506
       dclox |   -1.412516    .5572076     -2.53    0.011     -2.504623    -.3204093
       dcpct |    .0226682    .0071871      3.15    0.002      .0085817     .0367547
       _cons |   -2.984272    .7722467     -3.86    0.000     -4.497848    -1.470697
-------------+----------------------------------------------------------------

. logistic casecont dneo dclox dcpct /* shows ORs */

Logistic regression                             Number of obs     =        108
                                                LR chi2(3)        =      41.73
                                                Prob > chi2       =     0.0000
Log likelihood = -53.993656                     Pseudo R2         =     0.2787

-------------+----------------------------------------------------------------
     casecont | Odds Ratio    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
        dneo |    9.139118    5.282797      3.83    0.000      2.943566     28.37493
       dclox |    .2435298    .1356966     -2.53    0.011      .0817064     .7258519
       dcpct |    1.022927    .0073519      3.15    0.002      1.008619     1.037439
       _cons |    .0505763    .0390574     -3.86    0.000      .0111329     .2297654
-------------+----------------------------------------------------------------


Note: _cons estimates baseline odds.


. testparm dneo /* Wald test as chi^2-test, same P as z-test */


 ( 1)  [casecont]dneo = 0


           chi2(  1) =   14.65
         Prob > chi2 =    0.0001

. * profile likelihood CI for dneo, using logprof add-on command
. logprof dneo

Maximum Profile Log-Likelihood = -53.993656


-------------------------------------------------------------------------------
casecont       |   Coef.               [95% Conf. Interval]
---------------+---------------------------------------------------------------
dneo           |   2.2125639           1.1441697   3.4453488
-------------------------------------------------------------------------------

.
. * display of iterations of ML estimation
. logit casecont dneo dclox dcpct, trace

-------------
Iteration 0:
Parameter vector:
     casecont:  casecont:  casecont:  casecont:
         dneo      dclox      dcpct      _cons
r1          0          0          0          0

                                                   log likelihood = -74.859896
-------------
Iteration 1:
Parameter vector:
     casecont:  casecont:  casecont:  casecont:
         dneo      dclox      dcpct      _cons
r1   2.235522   -1.60015   .0228446  -2.857956

                                                   log likelihood = -54.156164
-------------
Iteration 2:
Parameter vector:
     casecont:  casecont:  casecont:  casecont:
         dneo      dclox      dcpct      _cons
r1   2.204562  -1.406852   .0225647  -2.974098

                                                   log likelihood = -53.993934
-------------
Iteration 3:
Parameter vector:
     casecont:  casecont:  casecont:  casecont:
         dneo      dclox      dcpct      _cons
r1   2.212543    -1.4125    .022668  -2.984243

                                                   log likelihood = -53.993656
-------------
Iteration 4:
Parameter vector:
     casecont:  casecont:  casecont:  casecont:
         dneo      dclox      dcpct      _cons
r1   2.212564  -1.412516   .0226682  -2.984272

                                                   log likelihood = -53.993656
-------------

Logistic regression                             Number of obs     =        108
                                                LR chi2(3)        =      41.73
                                                Prob > chi2       =     0.0000
Log likelihood = -53.993656                     Pseudo R2         =     0.2787

-------------+----------------------------------------------------------------
     casecont |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
        dneo |    2.212564    .5780423      3.83    0.000      1.079622     3.345506
       dclox |   -1.412516    .5572076     -2.53    0.011     -2.504623    -.3204093
       dcpct |    .0226682    .0071871      3.15    0.002      .0085817     .0367547
       _cons |   -2.984272    .7722467     -3.86    0.000     -4.497848    -1.470697
-------------+----------------------------------------------------------------

.
. * likelihood-ratio tests
. logit casecont dneo dclox dcpct /* need to rerun using logit */

Iteration 0:   log likelihood = -74.859896
Iteration 1:   log likelihood = -54.156164
Iteration 2:   log likelihood = -53.993934
Iteration 3:   log likelihood = -53.993656
Iteration 4:   log likelihood = -53.993656

Logistic regression                             Number of obs     =        108
                                                LR chi2(3)        =      41.73
                                                Prob > chi2       =     0.0000
Log likelihood = -53.993656                     Pseudo R2         =     0.2787

-------------+----------------------------------------------------------------
     casecont |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
        dneo |    2.212564    .5780423      3.83    0.000      1.079622     3.345506
       dclox |   -1.412516    .5572076     -2.53    0.011     -2.504623    -.3204093
       dcpct |    .0226682    .0071871      3.15    0.002      .0085817     .0367547
       _cons |   -2.984272    .7722467     -3.86    0.000     -4.497848    -1.470697
-------------+----------------------------------------------------------------

. test dneo dclox /* Wald test for dneo+dclox */


 ( 1)  [casecont]dneo = 0


 ( 2)  [casecont]dclox = 0


           chi2(  2) =   21.40
         Prob > chi2 =    0.0000

. estimates store full

. logit casecont dcpct

Iteration 0:   log likelihood = -74.859896
Iteration 1:   log likelihood = -69.088754
Iteration 2:   log likelihood = -69.074669
Iteration 3:   log likelihood = -69.074669

Logistic regression                             Number of obs     =        108
                                                LR chi2(1)        =      11.57
                                                Prob > chi2       =     0.0007
Log likelihood = -69.074669                     Pseudo R2         =     0.0773

-------------+----------------------------------------------------------------
     casecont |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
       dcpct |    .0189543    .0060179      3.15    0.002      .0071595     .0307492
       _cons |   -1.462424    .5230518     -2.80    0.005     -2.487586    -.4372608
-------------+----------------------------------------------------------------

. lrtest full /* likelihood-ratio test for dneo+dclox */

Likelihood-ratio test                                 LR chi2(2)  =     30.16
(Assumption: . nested in full)                        Prob > chi2 =    0.0000

. lrtest full, stats /* same with all fit statistics */

Likelihood-ratio test                                 LR chi2(2)  =     30.16
(Assumption: . nested in full)                        Prob > chi2 =    0.0000

Akaike's information criterion and Bayesian information criterion

-------------+---------------------------------------------------------------
       Model |        Obs  ll(null)  ll(model)      df         AIC        BIC
-------------+---------------------------------------------------------------
.            |        108  -74.8599  -69.07467       2    142.1493   147.5136
full         |        108  -74.8599  -53.99366       4    115.9873   126.7158
-------------+---------------------------------------------------------------


Note: N=Obs used in calculating BIC; see [R] BIC note.


. estimates store red

. logit casecont

Iteration 0:   log likelihood = -74.859896
Iteration 1:   log likelihood = -74.859896

Logistic regression                             Number of obs     =        108
                                                LR chi2(0)        =      -0.00
                                                Prob > chi2       =          .
Log likelihood = -74.859896                     Pseudo R2         =    -0.0000

-------------+----------------------------------------------------------------
     casecont |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
       _cons |           0    .1924501      0.00    1.000     -.3771952     .3771952
-------------+----------------------------------------------------------------

. estimates store null

. estimates stats *

Akaike's information criterion and Bayesian information criterion

-------------+---------------------------------------------------------------
       Model |        Obs  ll(null)  ll(model)      df         AIC        BIC
-------------+---------------------------------------------------------------
full         |        108  -74.8599  -53.99366       4    115.9873   126.7158
red          |        108  -74.8599  -69.07467       2    142.1493   147.5136
null         |        108  -74.8599   -74.8599       1    151.7198   154.4019
-------------+---------------------------------------------------------------


Note: N=Obs used in calculating BIC; see [R] BIC note.


. estimates table *

-------------+---------------------------------------
Variable   | full     red     null
-------------+---------------------------------------
        dneo | 2.2125639
       dclox | -1.412516
       dcpct | .02266825     .01895434
       _cons | -2.9842724     -1.4624236     0
-------------+---------------------------------------

.
. use mice.dta, clear

. logit dead dose

Iteration 0:   log likelihood = -75.669723
Iteration 1:   log likelihood = -64.201632
Iteration 2:   log likelihood = -63.944944
Iteration 3:   log likelihood = -63.944713
Iteration 4:   log likelihood = -63.944713

Logistic regression                             Number of obs     =        120
                                                LR chi2(1)        =      23.45
                                                Prob > chi2       =     0.0000
Log likelihood = -63.944713                     Pseudo R2         =     0.1549

-------------+----------------------------------------------------------------
         dead |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
        dose |     14.6369    3.332533      4.39    0.000       8.10526     21.16855
       _cons |   -3.569738    .7053432     -5.06    0.000     -4.952185    -2.187291
-------------+----------------------------------------------------------------

. estimates store red

. * does not work: logit dead i.dose
. * because dose has non-integer values
. egen Dose=group(dose), label /* create dose groups (in new variable Dose)  */

. logit dead i.Dose /* dose as categorical predictor */

note: 4.Dose != 0 predicts failure perfectly
      4.Dose dropped and 10 obs not used

Iteration 0:   log likelihood = -71.523665
Iteration 1:   log likelihood = -59.113208
Iteration 2:   log likelihood =  -58.82041
Iteration 3:   log likelihood = -58.817856
Iteration 4:   log likelihood = -58.817856

Logistic regression                             Number of obs     =        110
                                                LR chi2(10)       =      25.41
                                                Prob > chi2       =     0.0046
Log likelihood = -58.817856                     Pseudo R2         =     0.1776

-------------+----------------------------------------------------------------
         dead |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
        Dose |
         .1  |      .81093    1.317616      0.62    0.538     -1.771549     3.393409
      .1259  |   -9.56e-17    1.490712     -0.00    1.000     -2.921742     2.921742
      .1413  |           0   (empty)
        .15  |   -9.56e-17    1.490712     -0.00    1.000     -2.921742     2.921742
      .1588  |      .81093    1.317616      0.62    0.538     -1.771549     3.393409
      .1778  |    1.791759    1.236033      1.45    0.147     -.6308209     4.214339
      .1995  |     2.60269    1.236033      2.11    0.035      .1801093      5.02527
      .2239  |    1.791759    1.236033      1.45    0.147     -.6308209     4.214339
      .2512  |    2.197224    1.229273      1.79    0.074     -.2121055     4.606554
      .2818  |    2.197224    1.229273      1.79    0.074     -.2121055     4.606554
      .3162  |    3.583519    1.317616      2.72    0.007       1.00104     6.165998
             |
       _cons |   -2.197224    1.054092     -2.08    0.037     -4.263208    -.1312411
-------------+----------------------------------------------------------------

. logit dead i.Dose, asis /* avoids exclusion of dose=0.1413 */

Iteration 0:   log likelihood = -75.669723
Iteration 1:   log likelihood = -60.073875
Iteration 2:   log likelihood = -59.076968
Iteration 3:   log likelihood = -58.874743
Iteration 4:   log likelihood = -58.831027
Iteration 5:   log likelihood = -58.820395
Iteration 6:   log likelihood =  -58.81828
Iteration 7:   log likelihood = -58.817905
Iteration 8:   log likelihood = -58.817866
Iteration 9:   log likelihood = -58.817858
Iteration 10:  log likelihood = -58.817856

Logistic regression                             Number of obs     =        120
                                                LR chi2(11)       =      33.70
                                                Prob > chi2       =     0.0004
Log likelihood = -58.817856                     Pseudo R2         =     0.2227

-------------+----------------------------------------------------------------
         dead |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
        Dose |
         .1  |    .8110233     1.31765      0.62    0.538     -1.771523      3.39357
      .1259  |   -7.83e-16    1.490771     -0.00    1.000     -2.921858     2.921858
      .1413  |   -14.73911    1505.568     -0.01    0.992     -2965.599      2936.12
        .15  |    2.90e-16    1.490771      0.00    1.000     -2.921858     2.921858
      .1588  |    .8110233     1.31765      0.62    0.538     -1.771523      3.39357
      .1778  |    1.791833     1.23607      1.45    0.147     -.6308193     4.214485
      .1995  |    2.602659    1.236064      2.11    0.035      .1800167       5.0253
      .2239  |    1.791833     1.23607      1.45    0.147     -.6308193     4.214485
      .2512  |    2.197249    1.229309      1.79    0.074     -.2121518     4.606649
      .2818  |    2.197249    1.229309      1.79    0.074     -.2121518     4.606649
      .3162  |    3.583471    1.317628      2.72    0.007      1.000967     6.165976
             |
       _cons |   -2.197324    1.054134     -2.08    0.037      -4.26339    -.1312584
-------------+----------------------------------------------------------------

. logit dead i.Dose, asis trace /* showing convergence process */

-------------
Iteration 0:
Parameter vector:
         dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:
           1b.         2.         3.         4.         5.         6.         7.         8.         9.        10.        11.
         Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose
r1          0          0          0          0          0          0          0          0          0          0          0

         dead:      dead:
           12.
         Dose      _cons
r1          0  -.7308875

                                                   log likelihood = -75.669723
-------------
Iteration 1:
Parameter vector:
         dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:
           1b.         2.         3.         4.         5.         6.         7.         8.         9.        10.        11.
         Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose
r1          0   .5128205   1.14e-14  -.5128205   1.14e-14   .5128205   1.538462   2.564103   1.538462   2.051282   2.051282

         dead:      dead:
           12.
         Dose      _cons
r1   3.589744  -1.884734

                                                   log likelihood = -60.073875
-------------
Iteration 2:
Parameter vector:
         dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:
           1b.         2.         3.         4.         5.         6.         7.         8.         9.        10.        11.
         Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose
r1          0   .8756869  -2.01e-15  -1.630307  -2.01e-15   .8756869   1.840062   2.554934   1.840062   2.203774   2.203774

         dead:      dead:
           12.
         Dose      _cons
r1   3.484351   -2.26729

                                                   log likelihood = -59.076968
-------------
Iteration 3:
Parameter vector:
         dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:
           1b.         2.         3.         4.         5.         6.         7.         8.         9.        10.        11.
         Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose
r1          0   .7838782   2.26e-15  -3.132326   2.26e-15   .7838782   1.770934   2.616282   1.770934   2.192047   2.192047

         dead:      dead:
           12.
         Dose      _cons
r1   3.607197   -2.16817

                                                   log likelihood = -58.874743
-------------
Iteration 4:
Parameter vector:
         dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:
           1b.         2.         3.         4.         5.         6.         7.         8.         9.        10.        11.
         Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose
r1          0   .8339775  -4.60e-15  -4.962829  -4.60e-15   .8339775   1.809369   2.589805   1.809369   2.201125   2.201125

         dead:      dead:
           12.
         Dose      _cons
r1   3.560565  -2.222022

                                                   log likelihood = -58.831027
-------------
Iteration 5:
Parameter vector:
         dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:
           1b.         2.         3.         4.         5.         6.         7.         8.         9.        10.        11.
         Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose
r1          0   .8077708  -4.61e-17  -6.116858  -1.71e-16   .8077708   1.789285   2.603871   1.789285   2.196459   2.196459

         dead:      dead:
           12.
         Dose      _cons
r1   3.585359  -2.193845

                                                   log likelihood = -58.820395
-------------
Iteration 6:
Parameter vector:
         dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:
           1b.         2.         3.         4.         5.         6.         7.         8.         9.        10.        11.
         Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose
r1          0   .8168411  -1.36e-15  -8.982863  -1.49e-15   .8168411   1.796387   2.600456   1.796387   2.198647   2.198647

         dead:      dead:
           12.
         Dose      _cons
r1   3.580031  -2.203547

                                                   log likelihood =  -58.81828
-------------
Iteration 7:
Parameter vector:
         dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:
           1b.         2.         3.         4.         5.         6.         7.         8.         9.        10.        11.
         Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose
r1          0   .8101734  -3.32e-16  -10.11501  -4.42e-16   .8101734   1.791163   2.602943   1.791163   2.197029   2.197029

         dead:      dead:
           12.
         Dose      _cons
r1   3.583905  -2.196416

                                                   log likelihood = -58.817905
-------------
Iteration 8:
Parameter vector:
         dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:
           1b.         2.         3.         4.         5.         6.         7.         8.         9.        10.        11.
         Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose
r1          0    .811592  -1.16e-15   -11.9885  -1.27e-15    .811592   1.792281   2.602468   1.792281   2.197395   2.197395

         dead:      dead:
           12.
         Dose      _cons
r1    3.58318  -2.197931

                                                   log likelihood = -58.817866
-------------
Iteration 9:
Parameter vector:
         dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:
           1b.         2.         3.         4.         5.         6.         7.         8.         9.        10.        11.
         Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose
r1          0   .8106818   7.71e-16  -13.36448   6.59e-16   .8106818   1.791564   2.602773   1.791564    2.19716    2.19716

         dead:      dead:
           12.
         Dose      _cons
r1   3.583645  -2.196959

                                                   log likelihood = -58.817858
-------------
Iteration 10:
Parameter vector:
         dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:      dead:
           1b.         2.         3.         4.         5.         6.         7.         8.         9.        10.        11.
         Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose       Dose
r1          0   .8110233  -7.83e-16  -14.73911   2.90e-16   .8110233   1.791833   2.602659   1.791833   2.197249   2.197249

         dead:      dead:
           12.
         Dose      _cons
r1   3.583471  -2.197324

                                                   log likelihood = -58.817856
-------------

Logistic regression                             Number of obs     =        120
                                                LR chi2(11)       =      33.70
                                                Prob > chi2       =     0.0004
Log likelihood = -58.817856                     Pseudo R2         =     0.2227

-------------+----------------------------------------------------------------
         dead |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
        Dose |
         .1  |    .8110233     1.31765      0.62    0.538     -1.771523      3.39357
      .1259  |   -7.83e-16    1.490771     -0.00    1.000     -2.921858     2.921858
      .1413  |   -14.73911    1505.568     -0.01    0.992     -2965.599      2936.12
        .15  |    2.90e-16    1.490771      0.00    1.000     -2.921858     2.921858
      .1588  |    .8110233     1.31765      0.62    0.538     -1.771523      3.39357
      .1778  |    1.791833     1.23607      1.45    0.147     -.6308193     4.214485
      .1995  |    2.602659    1.236064      2.11    0.035      .1800167       5.0253
      .2239  |    1.791833     1.23607      1.45    0.147     -.6308193     4.214485
      .2512  |    2.197249    1.229309      1.79    0.074     -.2121518     4.606649
      .2818  |    2.197249    1.229309      1.79    0.074     -.2121518     4.606649
      .3162  |    3.583471    1.317628      2.72    0.007      1.000967     6.165976
             |
       _cons |   -2.197324    1.054134     -2.08    0.037      -4.26339    -.1312584
-------------+----------------------------------------------------------------

. testparm i.Dose /* note: Wald test for dose fails here */


 ( 1)  [dead]2.Dose = 0


 ( 2)  [dead]3.Dose = 0


 ( 3)  [dead]4.Dose = 0


 ( 4)  [dead]5.Dose = 0


 ( 5)  [dead]6.Dose = 0


 ( 6)  [dead]7.Dose = 0


 ( 7)  [dead]8.Dose = 0


 ( 8)  [dead]9.Dose = 0


 ( 9)  [dead]10.Dose = 0


 (10)  [dead]11.Dose = 0


 (11)  [dead]12.Dose = 0


           chi2( 11) =   19.22
         Prob > chi2 =    0.0573

. lrtest red, stats /* likelihood-ratio test ok */

Likelihood-ratio test                                 LR chi2(10) =     10.25
(Assumption: red nested in .)                         Prob > chi2 =    0.4185

Akaike's information criterion and Bayesian information criterion

-------------+---------------------------------------------------------------
       Model |        Obs  ll(null)  ll(model)      df         AIC        BIC
-------------+---------------------------------------------------------------
red          |        120 -75.66972  -63.94471       2    131.8894   137.4644
.            |        120 -75.66972  -58.81786      12    141.6357   175.0856
-------------+---------------------------------------------------------------


Note: N=Obs used in calculating BIC; see [R] BIC note.


.
end of do-file

. exit, clear