Stata Textbook Examples
Applied Logistic Regression, Second Edition, by Hosmer and Lemeshow
Chapter 2: Multiple Logistic Regression

The data files used for the examples in this text can be downloaded in a .zip file from the Wiley Publications website.  You can then use a program such as zip to unzip the data files.  If you need assistance getting data into Stata, please see our Stata Class Notes, especially the unit on Entering Data.  (NOTE:  The *.dat files are the data files, and the *.txt files contain the codebook information.)
Table 2.1, page 32.
use lowbwt.dta, clear
(Hosmer and Lemeshow - from appendix 1)

tabulate race, gen(race_)

       race |      Freq.     Percent        Cum.
------------+-----------------------------------
      white |         96       50.79       50.79
      black |         26       13.76       64.55
      other |         67       35.45      100.00
------------+-----------------------------------
      Total |        189      100.00

list race race_2 race_3 in 1/3

          race    race_2    race_3 
  1.     black         1         0  
  2.     other         0         1  
  3.     white         0         0  
Table 2.2, page 36.
logit low age lwt race_2 race_3 ftv

Iteration 0:   log likelihood =   -117.336
Iteration 1:   log likelihood = -111.41656
Iteration 2:   log likelihood = -111.28677
Iteration 3:   log likelihood = -111.28645

Logit estimates                                   Number of obs   =        189
                                                  LR chi2(5)      =      12.10
                                                  Prob > chi2     =     0.0335
Log likelihood = -111.28645                       Pseudo R2       =     0.0516

------------------------------------------------------------------------------
         low |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |   -.023823   .0337295    -0.71   0.480    -.0899317    .0422857
         lwt |  -.0142446   .0065407    -2.18   0.029    -.0270641   -.0014251
      race_2 |   1.003898   .4978579     2.02   0.044     .0281143    1.979681
      race_3 |   .4331084   .3622397     1.20   0.232    -.2768684    1.143085
         ftv |  -.0493083   .1672386    -0.29   0.768    -.3770899    .2784733
       _cons |   1.295366   1.071439     1.21   0.227    -.8046157    3.395347
------------------------------------------------------------------------------
Table 2.3, page 38.
logit low lwt race_2 race_3

Iteration 0:   log likelihood =   -117.336
Iteration 1:   log likelihood =  -111.7491
Iteration 2:   log likelihood = -111.62983
Iteration 3:   log likelihood = -111.62955

Logit estimates                                   Number of obs   =        189
                                                  LR chi2(3)      =      11.41
                                                  Prob > chi2     =     0.0097
Log likelihood = -111.62955                       Pseudo R2       =     0.0486

------------------------------------------------------------------------------
         low |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         lwt |  -.0152231   .0064393    -2.36   0.018    -.0278439   -.0026023
      race_2 |   1.081066   .4880512     2.22   0.027     .1245034    2.037629
      race_3 |   .4806033   .3566733     1.35   0.178    -.2184636     1.17967
       _cons |   .8057535   .8451625     0.95   0.340    -.8507345    2.462241
------------------------------------------------------------------------------
Table 2.4, page 42.
* Stata 8 code.
vce

* Stata 9 code and output.
estat vce

Covariance matrix of coefficients of logit model

        e(V) |        lwt      race_2      race_3       _cons 
-------------+------------------------------------------------
         lwt |  .00004146                                     
      race_2 | -.00064703   .23819397                         
      race_3 |  .00035585   .05320001   .12721584             
       _cons | -.00521365   .02260223   -.1034968   .71429959

How to cite this page

Report an error on this page or leave a comment

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.