Docsity

Logistic Regression - Lecture Slides | STAT 579, Exams of Descriptive statistics

Toggle sidebar
bg1
1
Logistic Regression
Logistic Regression
• Consider the Multiple Linear Regression Model:
i01i12i2 kiki
y = x x x
β
ββ β ε
++ ++ +
where the response variable y is dichotomous,
taking on only one of two values:
y = 1 if a success
= 0 if a failure
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f

Partial preview of the text

Download Logistic Regression - Lecture Slides | STAT 579 and more Exams Descriptive statistics in PDF only on Docsity!

Logistic Regression

Logistic Regression

  • Consider the Multiple Linear Regression Model:

y =i β 0 + β 1 xi1 + β 2 xi2 + "+ βk xik +εi

where the response variable y is dichotomous,

taking on only one of two values:

y = 1 if a success

= 0 if a failure

Logistic Regression

  • The response variable, y, is really just a

Bernoulli trial, with

E(y) = π

where

π = probability of a success on any given

trial

  • π can only take on values between 0 and 1

Logistic Regression

  • Thus, the Multiple Regression Model

π = μ y|x = β 0 + β 1 xi1 + β 2 x i2 + "+βk xik

is not appropriate for a dichotomous response

variable, since this model assumes π can take

on any value, but in fact it can only take on

values between 0 and 1.

Logistic Regression

• Consider the model with one predictor

(k=1):

log x

x
x

e e e

π

Logit

Odds

Logistic Regression

x

e e

π

Odds

• Every one-unit increase in x increases the

odds by a factor of e

Logistic Regression

e ( e )

π

x = 1

e e e e e

π

x = 2

x = 3

e e e e e e

Logistic Regression

• Thus, e

is the odds ratio, comparing the

odds at x+1 with the odds at x

• An odds ratio equal to 1 (i.e., e

occurs when β = 0, which describes the

situation where the predictor x has no

association with the response y.

Logistic Regression

  • The estimate of π is

a+bx

a+bx

e

p

1+e

Example: Coronary Heart Disease

60 8 8 10 0.80 4.00000 1.

55 7 13 17 0.76 3.25000 1.

50 6 5 8 0.63 1.66667 0.

45 5 6 13 0.46 0.85714 -0.

40 4 5 15 0.33 0.50000 -0.

35 3 3 12 0.25 0.33333 -1.

30 2 2 15 0.13 0.15385 -1.

25 1 1 10 0.10 0.11111 -2.

Log(Odds) log(p/(1-p)

Odds N p p/(1-p)

CHD Present

Age Age Group

Example: Coronary Heart Disease

Multiplicative Additive

a = -2.

b = 0.

Exp(b) = Odds Ratio = 1.

60 8 8 10 0.80 4.89175 1.58755 0.

55 7 13 17 0.76 2.79947 1.02943 0.

50 6 5 8 0.63 1.60209 0.47131 0.

45 5 6 13 0.46 0.91685 -0.08681 0.

40 4 5 15 0.33 0.52470 -0.64493 0.

35 3 3 12 0.25 0.30028 -1.20305 0.

30 2 2 15 0.13 0.17184 -1.76117 0.

25 1 1 10 0.10 0.09834 -2.31929 0.

Predicted p-hat 1/(1+exp(-a-b*x))

Predicted Log(Odds) a+b*x

Predicted Odds N p exp(a+b*x)

CHD Present

Age Group Age x

Example: Coronary Heart Disease

P robability of Coronary Heart Disease

1 2 3 4 5 6 7 8 A g e Gr o up

predicted observed

log(p/(1-p)) = -2.8774 +0.5581* X

Hypothesis Testing

H 0 : β = 0

H 1 : β ≠ 0

The test statistics for testing this hypothesis

are χ

statistics. There are 3 that are

commonly used:

Hypothesis Testing

( )

QLR = −2 L α − Lα β, ∼χ 1

( )

W 1

ˆ Q a.s.e. ˆ

⎛ ⎞ = ⎜ ⎟ ⎜ ⎟ ⎝ ⎠

∼

QS ∼ χ 1

Wald Test

Likelihood Ratio Test

Score Test

Goodness of Fit

  • Let m = # of levels of x (m=8 for CHD example)
  • Let ni = number of observations in the i th^ level of x
  • Let k = number of parameters (k=2 for CHD

example)

( )

m
2 i i 2
Pearson i m-k
i=1 i

p (^) ˆ X n ˆ

− = ∑ ∼

m
2 i 2
Deviance i i m-k
i=1 i

p

X 2 n p log

χ π

Hosmer-Lemeshow

Goodness of Fit Test

  • Used when multiple observations do not occur

for each value of some predictor variable(s).

  • Fit the model, and estimate πi with
  • Divide the observations into (approximately) 10

groups, of approximately equal size, based on

the percentiles of

πˆi

πˆi

Logistic Regression Example Coronary Heart Disease vs. Age (first 25 observations, out of 100)

Age Obs Age Group CHD 1 25 1 1 2 25 1 0 3 25 1 0 4 25 1 0 5 25 1 0 6 25 1 0 7 25 1 0 8 25 1 0 9 25 1 0 10 25 1 0 11 30 2 1 12 30 2 1 13 30 2 0 14 30 2 0 15 30 2 0 16 30 2 0 17 30 2 0 18 30 2 0 19 30 2 0 20 30 2 0 21 30 2 0 22 30 2 0 23 30 2 0 24 30 2 0 25 30 2 0

SAS Code:

Proc Logistic

Proc Logistic Data=CHD100 Descending; Model CHD=AgeGroup / Scale=none Aggregate; Run;

Pearson and Deviance Goodness of Fit statistics are calculated
and printed when
SCALE=option
is specified.
SCALE=NONE
requests statistics with no adjustment of overdispersion.
The AGGREGATE option specifies the subpopulations on which
these statistics are calculated. Observations with common
values in the list of variables define each subpopulation.

Proc Logistic Output: CHD Example

The LOGISTIC Procedure

Testing Global Null Hypothesis: BETA=

Test Chi-Square DF Pr > ChiSq

Likelihood Ratio 28.4851 1 <. Score 26.0782 1 <. Wald 21.4281 1 <.

Analysis of Maximum Likelihood Estimates

Standard Wald Parameter DF Estimate Error Chi-Square Pr > ChiSq

Intercept 1 -2.8770 0.6233 21.3024 <. AgeGroup 1 0.5580 0.1206 21.4281 <.

Odds Ratio Estimates

Point 95% Wald Effect Estimate Confidence Limits

AgeGroup 1.747 1.380 2.

Proc Logistic Output: CHD Example

Deviance and Pearson Goodness-of-Fit Statistics

Criterion DF Value Value/DF Pr > ChiSq

Deviance 6 0.2164 0.0361 0. Pearson 6 0.2178 0.0363 0.

Number of unique profiles: 8

SAS Code for Logistic Regression

Proc Logistic Data=Miner.CHD100 Descending; Model CHD=Age / Lackfit; Units Age=5; Output Out=C1 p=pi_hat; Run;

The LACKFIT option requests that the Hosmer-Lemeshow
Goodness of Fit test is calculated and printed.

Proc Logistic Output: CHD Example

The LOGISTIC Procedure

Testing Global Null Hypothesis: BETA=

Test Chi-Square DF Pr > ChiSq

Likelihood Ratio 28.6373 1 <. Score 26.1600 1 <. Wald 21.4538 1 <.

Analysis of Maximum Likelihood Estimates

Standard Wald Parameter DF Estimate Error Chi-Square Pr > ChiSq

Intercept 1 -4.8815 1.0374 22.1433 <. Age 1 0.1114 0.0240 21.4538 <.

Odds Ratio Estimates

Point 95% Wald Effect Estimate Confidence Limits

Age 1.118 1.066 1.

Proc Logistic Output: CHD Example

Adjusted Odds Ratios

Effect Unit Estimate

Age 5.0000 1.

Hosmer and Lemeshow Goodness-of-Fit Test

Chi-Square DF Pr > ChiSq

1.6102 7 0.

Logistic Regression Model predicting CHD from Age

-0.

0

1

20 25 30 35 40 45 50 55 60 65 Age

Probability

Observed Predicted

Predicting Thermal Distress

from Temperature

Testing Global Null Hypothesis: BETA=

Test Chi-Square DF Pr > ChiSq Likelihood Ratio 7.9520 1 0. Score 7.2312 1 0. Wald 4.6008 1 0.

Analysis of Maximum Likelihood Estimates

Standard Wald Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 15.0429 7.3786 4.1563 0. Temp 1 -0.2322 0.1082 4.6008 0.

Odds Ratio Estimates

Point 95% Wald Effect Estimate Confidence Limits Temp 0.793 0.641 0.

Predicting Thermal Distress

from Temperature

  • The temperature at the time of the final

Challenger flight was 31°.

  • From the logistic regression model, the

predicted probability of thermal distress in

one or more of the O-rings was 0.99961.

Predicting O-ring Thermal Distress from Temperature

-0.

0

1

30 40 50 60 70 80 Temperature

Probability

Observed Predicted

Multiple Logistic Regression

⎛ ⎞ = (^) ⎜ ⎟= + + + + ⎝ − ⎠

logit( ) log (^) 1 1x 2 x 2 " k xk 1

π π α β β β π