\documentstyle[11pt]{techreport} 
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}
\setlength{\textwidth}{6.3in}
\setlength{\topmargin}{0in}
\setlength{\headsep}{0in}
\setlength{\textheight}{8.5in}
\renewcommand{\baselinestretch}{1} % changes spacing.
\renewcommand{\arraystretch}{1}
\renewcommand{\tabcolsep}{.15in}
\flushbottom
\begin{document}

\begin{center}
\small{\sc Statistical Methods in Epidemiology}
\end{center}

\noindent
Handout 10\\
36-461\hfill{}{\bf Using BMDP LR for Logistic Regresssion}\hfill{}Fall, 1995

\begin{flushleft}
{\bf Background}
\end{flushleft}

The data are from a prospective study whose purpose was to
characterize the spontaneous recovery of language functioning in
patients during the first 3 to 4 months following a stroke.  Details
of the design and results of this study may be found in Holland et
al. (1985) and Holland, Greenhouse, Fromm, and Swindell (1989).
Briefly, patients admitted to a hospital with the diagnosis of stroke
and who met the study inclusion criteria were seen daily (6 days/week)
for 15 minutes beginning 48 to 72 hours poststroke and continuing
until hospital discharge.  The daily visits consisted of
semistructured conversational interactions and systemic scoring of the
patient's communication behavior.  At hospital discharge, patients
were formally tested using the Western Aphasia Battery (WAB).  If the
WAB indicated aphasic dysfunction (AQ $<$ 93.8), the patient was seen
and assessed at 1 month postdischarge. If this second WAB demonstrated
continued difficulty the patient was assessed again at 2 months
postdischarge.  The data set to be discussed here consists of 61
patients who had unilateral (right- or left-hemisphere) stroke,
ischemic or hemorrhagic etiology, and impaired language functioning at
time of hospital discharge.  We will use these data to investigate the
correlates of language recovery during the two month period
post-hospital discharge.  Definitions and the codes for the variables
of interest are presented in Table 1.

The multiple logistic regression model will allow us to investigate
simultaneously the effect of a number of different variables on the
likelihood of spontaneous language recovery.  A feature of the
logistic regression model is that it allows us to use explanatory
variables that are either quantitative or discrete.  Using the
variables defined and coded in Table 1 for the stroke recovery study,
the specification of the deterministic component of the multiple
linear logistic regression model on the logit scale is
\begin{center}
\hfill{}\small{
$ln(\frac{\pi}{1-\pi})  =  \beta_{0} + \beta_{1}\cdot (SIDE) + \beta_{2}\cdot
(GENDER) + \beta_{3}\cdot (AGE) + \beta_{4}\cdot (LOSD) 
 + \beta_{5}\cdot (WAB1)$}. \hfill{}(1)
\end{center}
Note that if we were to dichotomize length of stay, age and WAB1 then
a multiple cross-classification table of these data would consist of
$2^{6}=64$ cells or subgroups and that with 61 patients such a table
would have numerous sparse or empty cells which would be a problem for
a chi-square analysis.  An advantage of a statistical model such as
the one given in equation (1), however, is that the model provides a
structure that smooths the fit of the probability of a response to all
the cells in such a table.

\begin{center}
{\bf Table 0. Example of what the data file 'stroke.dat' looks like}
\end{center}

\begin{verbatim}
Side  Gender  Age  LOSD  WAB1  Status

  0     1      74   17   92.5    1
  1     1      75   30   87.8    0
  0     1      72   17   65.9    0
  0     1      60   21   86.4    1
  0     0      69   11   90.0    1
  0     0      62   13   6.2     0
\end{verbatim}


\newpage
\begin{center}
Table 1.  Variables and Codes from the Stroke Recovery Study 
\begin{tabular}{lll} \hline \hline \\
{\em Variable} & {\em Description} & {\em Values/Codes}\\ 
\hline\\
STATUS & Status at last & 0 = Not Recovered \\
& observation & 1 = Recovered\\
\\
SIDE & Side of lesion & 0 = Left\\
& & 1 = Right\\
\\
GENDER & & 0 = Female\\
& & 1 = Male\\
\\
AGE & Age at stroke & In years\\
& onset &\\
\\
LOSD & Length of hospital & In days\\
& stay &\\
\\
WAB1 & WAB at  & Range: 0 - 100\\
& hospital discharge\\
\hline \hline
\end{tabular}
\end{center}

\vspace{.2in}
\begin{flushleft}
{\bf Interpretation of Regression Coefficients}
\end{flushleft}

Figure 2 on the next page presents part of the BMDP output listing the
estimates of the regressions coefficients and their standard errors.
We see from the column of Figure 2 labelled {\sf coeff/S.E.} that the
coefficients for gender, length-of-stay, and the WAB score at
discharge are all significantly related to the probability of
spontaneous language recovery at the 0.05 level.  The coefficient for
length-of-stay is negative indicating that the longer patients are in
the hospital the smaller the chance of spontaneous language recovery
relative to patients who have shorter lengths-of-stay even after
controlling for the effect of the WAB1 score.  The coefficient for
WAB1 is positive as we would expect.  Males, after controlling for the
other variables in the model, are $exp(2.88)=17.8$ times as likely to
recover spontaneous language function as females.  A 95\% confidence
interval for $\beta_{2}$, the adjusted log odds ratio of recovery for
males relative to females, however, is large and ranges from 0.47 to
5.29.  We also note that side of stroke and subject's age do not have
a statistically significant association with spontaneous language
recovery after controlling for the effects of the other variables.  As
part of the BMDPLR output, the results from several goodness-of-fit
tests are given.  Details about these tests can be found in Hosmer and
Lemeshow (1989, Chapter 5).

\newpage
\begin{center}
{\bf Figure 1. BMDP LR Command file}
\end{center}

\small{
\begin{verbatim}
/ CONTROL   COLUMN=72.    /END  
/ PROBLEM  TITLE IS 'LANGUAGE RECOVERY FOLLOWING STROKE'.       
/ INPUT    VARIABLES = 6.       
           FORMAT IS FREE.      
           FILE = 'stroke.dat'. 
/ VARIABLE NAMES ARE SIDE, GENDER, AGE, LOSD, WAB1, STATUS.    
            USE = 1,2,3,4,5,6.   
/ REGRESS  DEPEND IS STATUS.    
            INTERVAL IS  SIDE, GENDER, AGE, LOSD, WAB1.
            MODEL = SIDE, GENDER, AGE, LOSD, WAB1.       
            START = IN, IN, IN, IN, IN. CONSTANT = IN.   
            MOVE  = 0, 0, 0, 0, 0.       
/ PRINT    CELLS = NONE.  NO HIST.      
            NO PLOT. CASE=0. NEWS.       
/ PLOT     XVAR =PREDPROB.   
            YVAR =STDRESID.
/ END   
\end{verbatim}
}

\normalsize{
\begin{center}
{\bf Figure 2.  Partial Output from the BMDP LR Analysis of the Stroke Data}
\end{center}
}

\footnotesize{
\begin{verbatim}
 STEP NUMBER   0
 ---------------
                          LOG LIKELIHOOD =   -14.494
 GOODNESS OF FIT CHI-SQ   (2*O*LN(O/E))  =    28.988  D.F.=  55  P-VALUE= 0.999
 GOODNESS OF FIT CHI-SQ (HOSMER-LEMESHOW)=    34.610  D.F.=   8  P-VALUE= 0.000
 GOODNESS OF FIT CHI-SQ   ( C.C.BROWN )  =     8.452  D.F.=   2  P-VALUE= 0.015

                                         STANDARD
      TERM                COEFFICIENT       ERROR   COEFF/S.E.  EXP(COEFFICIENT)

 SIDE                       -1.3694       1.111      -1.233      0.2543    
 GENDER                      2.8773       1.267       2.271       17.77    
 AGE                       -0.69369E-02  0.3070E-01 -0.2259      0.9931    
 LOSD                      -0.19617      0.9664E-01  -2.030      0.8219    
 WAB1                       0.16453      0.7300E-01   2.254       1.179    
 CONSTANT                   -11.078       6.380      -1.736      0.1545E-04


 CORRELATION MATRIX OF COEFFICIENTS
 ----------------------------------

               SIDE      GENDER    AGE       LOSD      WAB1      CONSTANT
         
 SIDE             1.000  
 GENDER          -0.284     1.000
 AGE             -0.127     0.201     1.000      
 LOSD             0.210    -0.535    -0.192     1.000    
 WAB1            -0.311     0.536     0.062    -0.305     1.000  
 CONSTANT         0.260    -0.509    -0.334     0.130    -0.931     1.000
\end{verbatim}
}


\newpage

\normalsize{
\begin{flushleft}
{\bf Analysis of the Fit of the Model}
\end{flushleft}

Figure 3 presents a residual analysis for this logistic regression.

One relatively easy method for the analysis of the fit of the logistic
regression model is based on calculating the predicted probability of
spontaneous language recovery based on the model in (1) compared to
the observed probability of language recovery 
Specifically, substitute the estimated regression coefficients given
in Figure 2 into the multiple logistic regression equation in (1).
For each patient in the study calculate his or her individual
predicted probabilty of language recovery by calculating the linear
combination of each patient's individual set of explanatory variables
with the estimated regression coefficients and use the inverse of the
logit transformation to solve for the probability of language
recovery, $\hat{\pi}$.
For example, consider a patient whose stroke was on the left side
(SIDE=0), was a 61 year old male (GENDER=1, AGE=61), stayed in the
hospital 19 days (LOSD=19), and whose WAB at discharge was 81.6
(WAB1=81.6).  The estimated probability of spontaneous language
recovery based on the model for such a patient is
\begin{displaymath}
  \hat{\pi}  =  \frac{1}{1 +
e^{-(-11.1-1.37\cdot(0)+2.88\cdot(1)-0.0069\cdot(61)-0.196\cdot(19)+0.165\cdot(81.6))}} = 0.77 .
\end{displaymath}
This value can be interpreted to mean that 77 patients out of 100 with
the above characteristics can be expected to recover normal language
functioning spontaneously within the first 2 months post-hospital
discharge.  To study the goodness of fit of the model, we obtain the
frequency distribution of the values of $\hat{\pi}$, and determine, say,
the quintiles of the distribution.  The observed number of patients
who had normal language functioning are tallied within each quintile,
and the expected number of patients who had normal language
functioning (predicted by the model) is determined by summing the
$\hat{\pi}$'s for all the patients in the quintile.  Table 2 presents
the expected and observed number of patients who had normal language
functioning for each quintile of risk of language recovery.
Comparisons of the expected number predicted by the model to the
observed number suggests that this model fits the data reasonably
well.

A test for whether there is a significant difference between the
observed and expected numbers in Table 2 can be constructed based on a
Pearson chi-square test.  This chi-square test would have
degrees-of-freedom equal to the number of groups (e.g., 5 for the
number of quintiles) minus 2 (Hosmer and Lemeshow, 1989, chapter 5).
In our example, this chi-square statistics is equal to 3.60 with 3
degrees-of-freedom and has a non-significant $p$-value=0.69, indicating
that the model adequately fits the data. A small p-value would
indicate a significant lack of fit of the model.
}

\begin{center}
{\bf Table 2. Analysis of the fit of the logit model in Equation (1)}
\begin{tabular}{rccc}
 &                 & Expected  & Observed  \\
 & Quintile of risk & Number    & Number \\ \hline
Highest & 5    & 10.7   & 11 \\
        & 4    &  3.1   &  2  \\     
        & 3    &  0.2   &  1  \\
        & 2    &  0.0   &  0  \\ 
Lowest  & 1    &  0.0   &  0  \\ \hline
Total   &      & 14.0   & 14  \\ \hline
\end{tabular}
\end{center}

\newpage
\footnotesize{
\begin{center}
{\bf Figure 3. Plot of Standardized Residual vs Predicted Probability}
\end{center}

\begin{verbatim}
         .+.....+.....+.....+.....+.....+.....+.....+.....+.....+.....+.
          -                                                             -
      8   + 1                                                           +
          -                                                             -
          -                                                             -
          -                                                             -
          -                                                             -
          -                                                             -
          -                                                             -
          -                                                             -
      6   +                                                             +
          -                                                             -
          -                                                             -
          -                                                             -
          -                                                             -
 S        -                                                             -
 T        -                                                             -
 D        -                                                             -
 R    4   +                                                             +
 E        -                                                             -
 S        -                                                             -
 I        -                                                             -
 D        -                                                             -
          -                                                             -
          -                                                             -
 1        -                                                             -
 2    2   +               1                                             +
          -                                                             -
          -                     1                                       -
          -                                1                            -
          -                                                             -
          -                                            12               -
          -                                                 2 11        -
          -                                                         111 -
      0   +T1                                                           +
          -  1111                                                       -
          -        11 1                                                 -
          -              1  3111                                        -
          -                                                             -
          -                                1                            -
          -                                1  1                         -
          -                                                             -
          .+.....+.....+.....+.....+.....+.....+.....+.....+.....+.....+.
                .10         .30         .50         .70         .90  
          0.0         .20         .40         .60         .80         1.0
     
                                   PREDPROB  10  
 EXTREME CASES --
 CASE NO.  STDRESID    CASE NO.  PREDPROB
     59      7.9404        57      0.9785
\end{verbatim}
}


\end{document}

