Lecture 05
Lecture 05
Lecture 05
School of Energy Science & Engineering
Linear Models
Weight
School of Energy Science & Engineering
R2 compares a measure of a good fit, SS(fit)
to a measure of a bad fit, SS(mean)
SS(mean)
• Size = 0.7 x weight + 0.86
Size
Weight
Weight
Obese
1
y= -x
1+ e
Not Obese
Obese 1
The curve
goes from
0 to 1
Not Obese 0
Probability
a mouse is
Obese
Not Obese
Obese
Not Obese
School of Energy Science & Engineering weight
Log(odds)
The Odds in favor of my team wining the game are 5 to 3:
æ 5 ö
æ p ö ç ÷ æ 5ö
log(odds) = log ç ÷ = log ç 8 ÷ = log ç ÷
è 1- p ø çç 1- 5 ÷÷ è 3ø
è 8ø
Probability
Of Obesity
Not Obese 0
weight
æ p ö
Log(odds of obesity) = log(odds) = log ç ÷
School of Energy Science & Engineering è 1- p ø
1
Log(odds of obesity)
0
weight æ 0.88 ö
log ç ÷=2
æ 0.5 ö è 1- 0.88 ø
log ç ÷=0
è 1- 0.5 ø æ 0.95 ö
æ 0.731 ö
log ç ÷=3
è 1- 0.95 ø
log ç ÷ =1
è 1- 0.731ø
School of Energy Science & Engineering
The coefficient for the line in logistic Regression
Log(odds of obesity)
Y = -3.48 + 1.83 x weight
e log(odds)
p=
1+ e log(odds)
e log(odds)
p=
1+ e log(odds)
An equation that takes log(odds)
as input and outputs probability
School of Energy Science & Engineering
An equation that takes probability as input and
outputs log(odds)
æ p ö
log ç ÷ = log(odds)
è 1- p ø
p
=e log(odds)
1- p
p = (1- p) e log(odds)
p = elog(odds) - pelog(odds)
p + pe =e
log(odds) log(odds) e log(odds)
p=
(
p 1+ e log(odds)
=e )
log(odds) 1+ e log(odds)
An equation that takes log(odds)
School of Energy Science & Engineering as input and outputs probability
• Now we use the observed status (obese or not obese) to
calculate their likelihood given the shape of the squiggly line
• Calculate the likelihood of the obese mice, given the shape of
the squiggle
• The likelihood that this mouse is obese, given the shape of the
squiggle, is the same as the predicted probability
• The likelihood that these mice are obese are 0.49, 0.9, 0.91,
091, 0.92
SS(mean)
Size
Weight Weight
e log(odds)
p=
1+ e log(odds)
We can call this LL(fit), for the log-likelihood of the fitted line,
and use it as substitute for SS(fit)
LL(fit)= -3.77
School of Energy Science & Engineering
We need a measure of a poorly fitted line
that is analogous to SS(mean)
SS(mean)
???
æ no of obese mice ö
= log ç ÷
è total no of mice not obese ø
æ5ö
= log ç ÷ = 0.22
è4ø
ee log(odds)
0.22
p
p== = 0.56
1+ee
1+
log(odds)
0.22
Weight
Weight
LL(overall probability)
-6.18 - -3.77
R =
2
= 0.39
School of Energy Science & Engineering
-6.18