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 0 0 0 17
- 0 0 0 0 257
- 1 0 1 0 15
- 0 0 1 0 107
- 10017
- 0 0 0 1 52
- 10115
- 0 0 1 1 27
- 11001
- 0 1 0 0 7
- 1 1 1 0 9
- 0 1 1 0 30
- 1 1 0 1 3
- 0 1 0 1 14
- 1 1 1 1 14
- 0 1 1 1 44
- 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