23
Logistic Regression Interpreting Logistic Regression Research Methods in Political Science I 9. Logistic Regression Yuki Yanai School of Law and Graduate School of Law December 2, 2015 1 / 23

Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Research Methods in Political Science I9. Logistic Regression

Yuki Yanai

School of Law and Graduate School of Law

December 2, 2015

1 / 23

Page 2: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Today’s Menu

1 Logistic RegressionIntroductionLogistic Regression with One Predictor

2 Interpreting Logistic RegressionEstimated CoefficientsStatistical Inference

2 / 23

Page 3: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Introduction

When We Use Logistic Regression

Response is binary

Response: yi = 0 or 1 for all i

E.g.whether a person supports the current cabinet ornotwhether a person turns out to vote or notwhether an armed conflict occurs or notetc.

3 / 23

Page 4: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Introduction

Visualize Binary Variable

0.00

0.25

0.50

0.75

1.00

0 5 10 15 20 25expenditure (million yen)

SM

D v

icto

ry

4 / 23

Page 5: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Introduction

Fitting the Logistic Curve

0.00

0.25

0.50

0.75

1.00

0 5 10 15 20 25expenditure (million yen)

prob

. of S

MD

vic

tory

5 / 23

Page 6: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Logistic Regression with One Predictor

An Example Model of Logistic Regression

Response: the result of SMD election (win or lose):yi =0 (lost) or 1 (won)

Predictor: electoral expenditure (million yen), expm

Logistic curve of the model

Pr(yi = 1) = logit−1(−2.00+0.14 · expm)

6 / 23

Page 7: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Logistic Regression with One Predictor

Logistic Regression Model

Value of the response is either 0 or 1: linear models“Xβ + error” don’t fit wellInstead, we model the probability of y being 1

Pr(yi = 1) = logit−1(Xiβ )

Assumption: Given the probability of success pi, eachyi is independently determined

yi ∼ Bernoulli(pi)

We call Xβ linear predictor(線形予測子)

7 / 23

Page 8: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Logistic Regression with One Predictor

Logistic [Inverse Logit] Function)

logit−1(x) =ex

1+ ex =1

1+ exp(−x)

Function that maps x ∈ (−∞,∞) on (0, 1)Appropriate to treat probabilitiesLogistic function is the inverse of the logit function,hence we write logit−1

8 / 23

Page 9: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Logistic Regression with One Predictor

Logistic Curves (1)

0.00

0.25

0.50

0.75

1.00

-6 -3 0 3 6x

logit−1 (x)

y=logit−1(x)

9 / 23

Page 10: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Logistic Regression with One Predictor

Logistic Curves (2)

0.00

0.25

0.50

0.75

1.00

-20 0 20 40x

logit−1 (-2.00 + 0.14x)

y=logit−1(-2.00 + 0.14x)

10 / 23

Page 11: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Logistic Regression with One Predictor

Logistic Function and Logit Function (1)

Logit functionthe inverse of logistic function

maps a continuous variable z ∈ (0,1) on (−∞,∞)

xi = logit(pi) = log(

pi

1− pi

)

11 / 23

Page 12: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Logistic Regression with One Predictor

Logistic Function and Logit Function

Two representations of the model

Pr(yi = 1) = pi

1 Logistic

pi = logit−1(Xiβ ) =1

1+ exp(−Xiβ )

2 Logit

logit(pi) = log(

pi

1− pi

)= Xiβ

Both are important and frequently used12 / 23

Page 13: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Logistic Regression with One Predictor

Logistic “Curves”

Logistic curves are not lines: effects are not constantthe amount of change in the response correspondingto 1-unit change of a predictor is not constant: theeffect size depends on the value of the predictor

logit(0.5) = 0, logit(0.6) = 0.4: 0.4 unit change onlogit scale is equivalent to 10 point change from50% to 60% on probability scalelogit(0.07) = −2.6, logit(0.1) = −2.2: 0.4 unitchange on logit scale is equivalent to 3 pointchange from 7% to 10% on probability scale

the change in the response corresponding to a certainamount of change in the predictor: small when thepredictor takes on values near minimum or maximum,and large when it takes on values around the mean

13 / 23

Page 14: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Estimated Coefficients

Evaluating the Data around the Mean (1)

Pr(win) = logit−1(−2.00+0.14 · expm)

Logistic curve is not linear: the effect size depends onwhere of the data we evaluate

Evaluate the probability of success at the meanmean(exam) = 6.12logit−1(−2.00+0.14 ·6.12) = 0.24

14 / 23

Page 15: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Estimated Coefficients

Evaluating the Data around the Mean (2)

Pr(win) = logit−1(−2.00+0.14 · expm)

Evaluate the effect of the predictor on the successprobability around the mean

mean(exam) = 6.12 : Compare when expm = 6and when expm = 7logit−1(−2.00+0.14 ·7)− logit−1(−2.00+0.14 ·6) =0.0261-unit increase of the expenditure around itsmean leads to 2.6 point increase of the winningprobability

15 / 23

Page 16: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Estimated Coefficients

Evaluating the Data around the Mean (3)

Pr(win) = logit−1(−2.00+0.14 · expm)

Evaluate analytically,

ddx

logit−1(−2+0.14x) = 0.14exp(−2+0.14x)

[1+ exp(−2+0.14x)]2

Plug x̄ = 6.12 into x

ddx

logit−1(−2+0.14 ·6.12) = 0.026

16 / 23

Page 17: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Estimated Coefficients

Divide-by-4 Rule

the slope of the tangent of the logistic curve: max whenXβ = α +βx = 0

logit−1(0) = 0.5

the slope is

ddx

logit−1(0) = βe0

(1+ e0)2 =β4

Maximal effect of the predictor is the value of thecoefficient divided by 4

Winning probability: the coefficient of the expenditure0.14:0.14/4 = 0.035 → 1 unit increase of the expenditureraises the winning probability by 3.5 percentage points atmost

17 / 23

Page 18: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Estimated Coefficients

Odds and Odds Ratios

Odds of success when the probability of success is p andthat of failure is 1− p:

p1− p

p = 0.5 → odds is 1p = 1/3 → odds is 0.5

Odds ratio: the ratio of two sets of odds

p1

1− p1/

p2

1− p2

Merit of using odds ratios: no upper limitOdds and odds ratios are different: do not confuse

18 / 23

Page 19: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Estimated Coefficients

Interpreting Logistic Regression with Odds

Odds of logistic regression:

Pr(y = 1|x)Pr(y = 0|x)

=

(exp(α +βx)

1+ exp(α +βx)

)/

(1− exp(α +βx)

1+ exp(α +βx)

)= exp(α +βx)

Take natural logarithms of both sides

log(

Pr(y = 1|x)Pr(y = 0|x)

)= α +βx = logit(α +βx)

In logarithmic scale, 1 unit increase of x increase the oddsby βIn the original scale, the amount of change is exp(β )E.g., exp(0.14) = 1.15 : 1 unit increase of x → the odds ofwinning is multiplied by 1.15: odds ratio is 1.15

19 / 23

Page 20: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Statistical Inference

Estimates and Standard Errors of Coefficients

Purpose of logistic regression: estimate β in thelinear predictorEstimation method: maximum likelihood methodthe point estimate of ββ̂ ±2se are consistent with dataElection example: β̂ = 0.14, se = 0.01 → β in[0.14±2 ·0.01] = [0.12,0.16] are consistent with thedata

20 / 23

Page 21: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Statistical Inference

Statistical Significance

β̂ is more than 2se away from 0: the effect isstatistically significantElection example: β̂ = 0.14 is statistically significantpositive effect: the electoral expenditure increases theprobability of winningWe don’t discuss the significance of the intercept:we’re not interestedCareful interpretation is required for interaction terms

21 / 23

Page 22: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Let’s run some logistic regression with R

22 / 23

Page 23: Research Methods in Political Science I - 9. Logistic ...yukiyanai.github.io/teaching/rm1/contents/docs/rm1-lec09-logistic.pdf · Research Methods in Political Science I 9. Logistic

Logistic Regression Interpreting Logistic Regression

Next Week

Maximum Likelihood Method(最尤法)

23 / 23