Logistic Regression: A Self-learning Text, Third Edition (Statistics in the Health Sciences)

(vip2019) #1

EVANS3 contains the same information as EVANS2 except that it has sixteen obser-
vations rather than eight. The difference is that with EVANS3, for each pattern of
covariates there is an observation containing the frequency counts for CHD¼1 and
another observation containing the frequency counts for CHD¼0. The code to
create the data is:


clear

input chd cat agegrp ecg count

chd cat agegrp ecg count


  1. 1 0 0 0 17

  2. 0 0 0 0 257

  3. 1 0 1 0 15

  4. 0 0 1 0 107

  5. 10017

  6. 0 0 0 1 52

  7. 10115

  8. 0 0 1 1 27

  9. 11001

  10. 0 1 0 0 7

  11. 1 1 1 0 9

  12. 0 1 1 0 30

  13. 1 1 0 1 3

  14. 0 1 0 1 14

  15. 1 1 1 1 14

  16. 0 1 1 1 44

  17. end


The model is restated as follows:


logit PðCHD¼ 1 jXÞ¼b 0 þb 1 CATþb 2 AGEGRPþb 3 ECG

The code to run the logistic regression using thelogitcommand with frequency
weighted data is:


logit chd cat agegrp ecg [fweight¼count]

The[fweight¼]option, with the variable COUNT, instructs Stata that the variable
COUNT contains the frequency counts. The[fweight¼]option can also be used
with thebinregcommand:


binreg chd cat agegrp ecg [fweight¼count]

The output is omitted.


Obtaining ROC Curves


The knee fracture dataset will be used to illustrate how ROC curves are generated in
Stata. Open the datasetkneefr.dta. The outcome variable is FRACTURE indicating


654 Appendix: Computer Programs for Logistic Regression

Free download pdf