0% found this document useful (0 votes)
9 views3 pages

Logistic Regression - Example

Uploaded by

Nakul Arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Logistic Regression - Example

Uploaded by

Nakul Arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Logistic Regression

❖ Probability: p=m|n; where m = Number of Favorable Outcomes & n = Total


Number of Outcomes
❖ Odds: o=p|1-p or [Number of favorable outcomes | number of unfavorable
outcomes = m|n-m]
❖ Odds Ratio: Ratio of two Odds = [p1|1-p1] | [p0|1-p0]
❖ Log Odds (or Logit): ln(p|1-p) is used for Uniform and Symmetrical
Scaling of Odds ensures Normality of Odds (or Odds Ratio). The logit
function ln(p|1-p) = 0 when p = 0.5 and Undefined when p = {0 or 1}
❖ If logit = ln(p|1-p) = 𝛂; then logit-1 = p = exp(𝛂)|1+exp(𝛂)
❖ Logistic Regression: ln(p:y=1|1-p) = b0 + b1*x; where p is Probability
that y = 1. Thus, p(y=1) = exp(b0+b1*x)|1+exp(b0+b1*x).

Example
Consider ‘cars_data’ (R dataset: mtcars), where the Drive Type of Car {am:
a=automatic=0 & m=manual=1} is regressed on (say) Car Mileage {mpg}. Here,
the Dependent variable {am} is a Categorical variable having values {0,1}
and therefore not Normally distributed; whereas the Independent variable
{mpg} is a Continuous Numeric variable.

am vs mpg ln(p:am=1|1-p) = b0 + b1*mpg

A N Mitra, 2022.
1
Logistic Regression

Logistic Regression: ln(p|1-p) = b0+b1*mpg; where p is Probability of am=1


(car is of manual drive type). Thus, p(am=1) = [exp(b0+b1*mpg) |
1+exp(b0+b1*mpg)] => Probability that the Car has Manual Drive.

Logistic Regression Results (in R)

Call: glm(formula = logreg_model, family = "binomial", data = cars_data)

Deviance Residuals:
Min 1Q Median 3Q Max
-1.5701 -0.7531 -0.4245 0.5866 2.0617

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -6.6035 2.3514 -2.808 0.00498 **
mpg 0.3070 0.1148 2.673 0.00751 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 43.230 on 31 degrees of freedom


Residual deviance: 29.675 on 30 degrees of freedom
AIC: 33.675

Odds_Ratio 2.5 % 97.5 %


(Intercept) 0.001355579 1.350747e-05 0.1360428
mpg 1.359379288 1.085394e+00 1.7025269

Thus, p(am=1) = exp(-6.6+0.3*mpg)|1+exp(-6.6+0.3*mpg)

mpg 15 16 17 18 19 20 21 22 23 24 25

p(am=1) 0.11 0.14 0.18 0.23 0.29 0.35 0.43 0.50 0.57 0.65 0.71

odds 0.12 0.16 0.22 0.30 0.41 0.54 0.75 1.00 1.33 1.86 2.45

odds_ratio 1.00 1.33 1.83 2.50 3.42 4.50 6.25 8.33 11.08 15.50 20.42

or_%_inc 0:0 1:33 2:83 3:150 4:242 5:350 6:525 7:733 8:1008 9:1450 10:1942

A N Mitra, 2022.
2
Logistic Regression

Inferences
1. Probability that a Car has Manual Drive Type [p(am=1)] increases with
the increase in Mileage (mpg).
2. Cars with [mpg<22] have low Probability (p<0.5) of having Manual Drive
Type. Cars with [mpg>22] have high Probability (p>0.5) of having
Manual Drive Type.
3. At mpg=22, p(am=1)=0.5 and odds=1 (that is Odds are Even); implies
that, at mpg=22, the Probability of a Car having Automatic or Manual
Drive Type is equal.
4. An 1 unit increase in {mpg} increases the Odds (not Probability) of
Car being Manual (am=1) by 33%.

A N Mitra, 2022.
3

You might also like