UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

Stata Textbook Examples
Applied Logistic Regression by Hosmer and Lemeshow
Chapter 1: Introduction to the Logistic Regression Model

This chapter makes use of the chdaga.dta file.
use chdage
Figure 1.1 -- page 4
graph twoway scatter chd age, ylabel(0 1)
Table 1.2 -- page 4
/* create the age categories */
recode age 20/29=1 30/34=2 35/39=3 40/44=4 45/49=5 50/54=6 55/59=7 60/69=8, gen(agecat)
tabulate agecat chd

           |          chd
    agecat |         0          1 |     Total
-----------+----------------------+----------
        29 |         9          1 |        10 
        34 |        13          2 |        15 
        39 |         9          3 |        12 
        44 |        10          5 |        15 
        49 |         7          6 |        13 
        54 |         3          5 |         8 
        59 |         4         13 |        17 
        69 |         2          8 |        10 
-----------+----------------------+----------
     Total |        57         43 |       100

table agecat, c(mean chd)

----------+-----------
   agecat |  mean(chd)
----------+-----------
       29 |         .1
       34 |   .1333333
       39 |        .25
       44 |   .3333333
       49 |   .4615385
       54 |       .625
       59 |   .7647059
       69 |         .8
----------+-----------
Figure 1.2 -- page 5
collapse (count) tot=chd (sum) present=chd, by(agecat)
gen prop = present / tot
graph twoway scatter prop agecat, ylabel(0(.2)1)
Table 1.3 -- page 11
use chdage, clear

logit chd age

Iteration 0:   log likelihood = -68.331491
Iteration 1:   log likelihood = -54.170558
Iteration 2:   log likelihood = -53.681645
Iteration 3:   log likelihood = -53.676547
Iteration 4:   log likelihood = -53.676546

Logit estimates                                   Number of obs   =        100
                                                  LR chi2(1)      =      29.31
                                                  Prob > chi2     =     0.0000
Log likelihood = -53.676546                       Pseudo R2       =     0.2145

------------------------------------------------------------------------------
     chd |      Coef.   Std. Err.       z     P>|z|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
     age |   .1109211   .0240598      4.610   0.000       .0637647    .1580776
   _cons |  -5.309453   1.133655     -4.683   0.000      -7.531376   -3.087531
------------------------------------------------------------------------------

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


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.