Docsity

Logistic Regression - Lecture Slides | STAT 537, Exams of Statistics

Partial preview of the text

Download Logistic Regression - Lecture Slides | STAT 537 and more Exams Statistics in PDF only on Docsity!

Logistic Regression

Overview

Continuous

Categorical

Linear

Regression

Analysis

Response Analysis

What Does Logistic Regression

Do?

The logistic regression model uses the

predictor variables, which can be categorical

or continuous, to predict the probability of

specific outcomes.

In other words, logistic regression is

designed to describe probabilities

associated with the values of the response

variable.

Logistic Regression

  • Consider the Multiple Linear Regression Model:

y =i β 0 + β 1 xi1 + β 2 xi2 + L+ β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

  • When the response variable is dichotomous, a
more appropriate linear model is the
Logistic Regression Model :

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

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

π π α β β β π

Logistic Regression

  • The ratio
is called the odds, and is a function of the
probability π.

What Is an Odds Ratio?

An odds ratio indicates how much more

likely, with respect to odds, a certain event

occurs in one group relative to its

occurrence in another group.

Example: How much more likely are females

to purchase 100 dollars or more

in items compared to males?

Probability of Outcome

Outcome
Group A
Group B
Total
Total
YES NO
Probability of a
in group A
Yes outcome 20/
Probability of a
in group A
NO outcome 60/

Logistic Regression

  • Consider the model with one predictor

(k=1):

log x 1

⎛ ⎞ = + ⎜ ⎟ ⎝ − ⎠

( )

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 χ

2

statistics. There are 3 that are

commonly used:

Hypothesis Testing

( )

2

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

( )

2

2 W 1

ˆ Q a.s.e. ˆ

⎛ ⎞ = ⎜ ⎟ ⎜ ⎟ ⎝ ⎠

2 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)

( )

2 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