------------------------------------------------------------------------------------------------- log: C:\MyDocs\MPH\Text\SecondEdition\WebDoFiles\4.11.Sepsis.log log type: text opened on: 30 Dec 2007, 20:16:09 . * 4.11.Sepsis.log . * . * Simple logistic regression of mortal status at 30 days (fate) against . * baseline APACHE II score (apache) in a random sample of septic patients . * . use C:\WDDtext\4.11.Sepsis.dta, clear . summarize fate apache Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- fate | 38 .4473684 .5038966 0 1 apache | 38 19.55263 11.30343 0 41 . glm fate apache, family(binomial) link(logit) Iteration 0: log likelihood = -15.398485 Iteration 1: log likelihood = -14.9578 Iteration 2: log likelihood = -14.956086 Iteration 3: log likelihood = -14.956085 Generalized linear models No. of obs = 38 Optimization : ML Residual df = 36 Scale parameter = 1 Deviance = 29.91217061 (1/df) Deviance = .8308936 Pearson = 66.34190718 (1/df) Pearson = 1.842831 Variance function: V(u) = u*(1-u) [Bernoulli] Link function : g(u) = ln(u/(1-u)) [Logit] AIC = .8924255 Log likelihood = -14.95608531 BIC = -101.0409 ------------------------------------------------------------------------------ | OIM fate | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- apache | .2012365 .0609004 3.30 0.001 .081874 .320599 _cons | -4.347806 1.371623 -3.17 0.002 -7.036138 -1.659474 ------------------------------------------------------------------------------ . predict logodds, xb . generate prob = exp(logodds)/(1 + exp(logodds)) . list apache fate logodds prob in 1/3 +---------------------------------------+ | apache fate logodds prob | |---------------------------------------| 1. | 16 Alive -1.128022 .2445263 | 2. | 25 Dead .6831065 .6644317 | 3. | 19 Alive -.5243126 .3718444 | +---------------------------------------+ . sort apache . label variable prob "Probability of Death" . scatter fate apache || line prob apache, yaxis(2) color(red) /// > , ylabel(0 1, valuelabel angle(0)) /// > ylabel(, axis(2) angle(0) labcolor(red) tlcolor(red)) /// > ytitle(,axis(2) color(red)) /// > yscale(titlegap(-8)) xlabel(0(10)40) legend(off) . log close log: C:\MyDocs\MPH\Text\SecondEdition\WebDoFiles\4.11.Sepsis.log log type: text closed on: 30 Dec 2007, 20:16:11 -----------------------------------------------------------------------------------------------