10:00
What does it mean to be a binary variable?
Application Exercise
10:00
\[\log\left(\frac{P(Y=1|x)}{1 - P(Y = 1|x)}\right) = \beta_0 + \beta_1 x\]
for simplicity, let’s write \(P(Y=1|x)\) as \(p\)
\[\log\left(\frac{p}{1 - p}\right) = \beta_0 + \beta_1 x\]
\[\exp\left\{\log\left(\frac{p}{1 - p}\right)\right\} = \frac{p}{1 - p} = \exp\{\beta_0 + \beta_1 x\}\]
\[{\require{color}\colorbox{#86a293}{$\exp$}}\left\{\log\left(\frac{p}{1 - p}\right)\right\} = \frac{p}{1 - p} = {\require{color}\colorbox{#86a293}{$\exp$}}\{\beta_0 + \beta_1 x\}\]
Let’s start with ‘undoing’ the log
\[\frac{p}{1 - p} = e^{\beta_0 + \beta_1 x}\\ p = (1-p)e^{\beta_0 + \beta_1x}\]
\[\frac{p}{1 - p} = e^{\beta_0 + \beta_1 x}\\ p = ({\require{color}\colorbox{#86a293}{$1-p$}})e^{\beta_0 + \beta_1x}\]
Move (1-p) to the other side of the equation
\[p = (1-p)e^{\beta_0 + \beta_1x}\\ p (1+e^{\beta_0+\beta_1x}) = e^{\beta_0 + \beta_1x}\]
\[p = (1-p)e^{\beta_0 + \beta_1x}\\ p (1+e^{\beta_0+\beta_1x}) = e^{\beta_0 + \beta_1x}\]
Distribute that \((1-p)\) and then move the part with \(p\) back to the other side of the equation so we can solve with respect to \(p\)
\[p (1+e^{\beta_0+\beta_1x}) = e^{\beta_0 + \beta_1x}\\ p = \frac{e^{\beta_0 + \beta_1x}}{1 + e^{\beta_0 + \beta_1x}}\]
\[p (1+e^{\beta_0+\beta_1x}) = e^{\beta_0 + \beta_1x}\\ p = \frac{e^{\beta_0 + \beta_1x}}{1 + e^{\beta_0 + \beta_1x}}\]
Solve for \(p\)!
We can equivalently write this as
\[p = \frac{1}{1 + e^{-(\beta_0 + \beta_1x)}}\]
__ | Scored | Missed | Total |
---|---|---|---|
Distance < 9 | 39 | 22 | 61 |
Distance \(\ge\) 9 | 61 | 78 | 139 |
Total | 100 | 100 | 200 |
__ | Scored | Missed | Total |
---|---|---|---|
Distance < 9 | 39 | 22 | 61 |
Distance \(\ge\) 9 | 61 | 78 | 139 |
Total | 100 | 100 | 200 |
\(OR = \frac{39/22}{61/78} = \frac{1.77}{0.78} = 2.27\)
“the odds of scoring was 2.27 times higher when the shots were within 9 inches compared with those further away”
Application Exercise
08:00
How would you get the odds from the log(odds)?
Form | Model |
---|---|
Logit form | \(\log\left(\frac{p}{1-p}\right) = \beta_0 + \beta_1x\) |
Probability form | \(\Large{p} = \frac{e^{\beta_0 + \beta_1x}}{1+e^{\beta_0 + \beta_1x}}\) |
probability | odds | log(odds) |
---|---|---|
\(p\) | \(\frac{p}{1-p}\) | \(\log\left(\frac{p}{1-p}\right)=l\) |
log(odds) | odds | probability |
---|---|---|
\(l\) | \(e^l\) | \(\frac{e^l}{1+e^l} = p\) |