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

(vip2019) #1

for a particular pattern of covariates. This can also be accomplished in Stata using
thebinregcommand.


The summarized dataset, EVANS2, described in the SAS section contains eight
observations and is small enough to be typed directly into the computer using the
inputcommand followed by a list of variables. Theclearcommand clears the
individual level Evans County dataset from the computer’s memory and should
be run before creating the new dataset since there are common variable names to
the new and cleared dataset (CAT and ECG). After entering theinputcommand,
Stata will prompt you to enter each new observation until you typeend.


The code to create the dataset is presented below. The newly defined five variables are
described in the SAS section of this appendix.


clear

input cases total cat agegrp ecg

cases total cat agegrp ecg


  1. 17 274 0 0 0

  2. 15 122 0 1 0
    3.759001
    4.532011

  3. 1 8 1 0 0
    6.939110
    7.317101

  4. 14 58 1 1 1

  5. end


Thelistcommand can be used to display the dataset in the Results Window and to
check the accuracy of data entry.


The data is in binomial events/trials format in which the variable CASES represents
the number of coronary heart disease cases and the variable TOTAL represents the
number of subjects at risk in a particular stratum defined by the other three variables.
The model is stated as follows:


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

The code to run the logistic regression follows:


binreg cases cat age ecg, n(total)

Then( )option, with the variable TOTAL in parentheses, instructs Stata that TOTAL
contains the number of trials for each stratum. The output is omitted.


Individual level data can also be summarized using frequency counts if the variables
of interest are categorical variables. The dataset EVANS3, discussed in the SAS
section, uses frequency weights to summarize the data. The variable COUNT con-
tains the frequency of occurrences of each observation in the individual level data.


STATA 653

Free download pdf