*****************************************************; * Examples of logistic regression (and stepwise logistic regression): * * Suppose that we have Bernoulli trials (that is, observations that * yield Yes/No results, or values Y=1 or Y=0). The Bernoulli trials * can depend on a covariate or set of covariates, such as age, * health, income, etc. * * For definiteness, suppose that Y=1 means Yes (or success) and Y=0 * means No (or failure). These are the other possible values of Y. * Using data about the outcomes of Bernoulli trials with values of * their covariates X, we want we want to estimate the probability * of success as a function of X: * * p = P(Y=1|X) = p(X) = a function of a+bX * * Assuming a linear relationship * * p(X) = P(Y=1|X) = a + b X * * would not work very well, since 0 < a + bX < 1 would imply * awkward conditions on a, b, and X. The function * * p(X) = P(Y=1|X) = exp(a + bX) * * is always positive, but can be greater than one. A better choice * is * * Prob(Y=1|X) = p(X) = exp(a+bX)/(1 + exp(a+bX)) (*) * * which maps the line `a+bX' into values between 0 and 1. * * The relation (*) is equivalent to p(X)/(1-p(X)) = exp(a+bX), or * * log (p(X)/(1-p(X))) = a + bX (**) * * Since * * log (p(X)/(1-p(X))) = log (P(Y=1|X)/P(Y=0|X)) * * the function log(p/(1-p)) is also called the ``log odds ratio''. * * Note that (*) and (**) imply that X affects P(Y=1|X) monotonically. * That is, if X increases, then P(Y=1|X) increases if b>0 and * P(Y=1|X) decreases if b<0. * * While (*) or (**) resembles a classical linear regression * * Y = a + bX + Error, Error is N(0,sigma^2) (***) * * it is somewhat different: For Bernoulli (Yes/No) data , the * left-hand side of (***) always has Y=0 or Y=1, and there is no * reasonable way to model the error distribution. The relation (**) * is more analogous to writing a normal regression as * * E(Y|X) = a + bX (****) * * A second difference is that, in (**), we need a LINK FUNCTION * that maps the range of the parameter p (0