what are the odds
what are the odds
What does it mean to be a binary variable?
Model | Outcome | Form |
---|---|---|
Ordinary linear Regression | Numeric | y≈β0+β1x |
Number of Doctors example | Numeric | √Number of doctors≈β0+β1x |
Logistic regression | Binary | log(π1−π)≈β0+β1x |
Model | Outcome | Form |
---|---|---|
Ordinary linear Regression | Numeric | y≈β0+β1x |
Number of Doctors example | Numeric | √Number of doctors≈β0+β1x |
Logistic regression | Binary | log(π1−π)≈β0+β1x |
How would you get the odds from the log(odds)?
How would you get the odds from the log(odds)?
Form | Model |
---|---|
Logit form | log(π1−π)=β0+β1x |
Probability form | π=eβ0+β1x1+eβ0+β1x |
probability | odds | log(odds) |
---|---|---|
π | π1−π | log(π1−π)=l |
probability | odds | log(odds) |
---|---|---|
π | π1−π | log(π1−π)=l |
log(odds) | odds | probability |
---|---|---|
l | el | el1+el=π |
what are the odds
what are the odds
data("MedGPA")ggplot(MedGPA, aes(Accept, GPA)) + geom_boxplot() + geom_jitter()
What is the equation for the model we are going to fit?
What is the equation for the model we are going to fit?
glm(Accept ~ GPA, data = MedGPA, family = "binomial")
## ## Call: glm(formula = Accept ~ GPA, family = "binomial", data = MedGPA)## ## Coefficients:## (Intercept) GPA ## 19.21 -5.45 ## ## Degrees of Freedom: 54 Total (i.e. Null); 53 Residual## Null Deviance: 75.8 ## Residual Deviance: 56.8 AIC: 60.8
glm(Accept ~ GPA, data = MedGPA, family = "binomial") %>% tidy()
## # A tibble: 2 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) 19.2 5.63 3.41 0.000644## 2 GPA -5.45 1.58 -3.45 0.000553
glm(Accept ~ GPA, data = MedGPA, family = "binomial") %>% predict()
## 1 2 3 4 5 6 7 8 9 10 ## -0.538 -1.737 1.590 -0.919 0.771 -1.083 -2.010 0.990 -1.028 -2.010 ## 11 12 13 14 15 16 17 18 19 20 ## -2.447 0.171 -1.356 -0.483 1.208 -0.101 -0.701 -0.101 1.480 -2.010 ## 21 22 23 24 25 26 27 28 29 30 ## -1.028 -1.356 -2.119 -1.956 -0.865 -0.210 0.444 -0.319 0.662 -1.628 ## 31 32 33 34 35 36 37 38 39 40 ## -0.538 2.353 -2.010 -0.974 1.535 -1.847 -0.101 0.662 -1.901 2.080 ## 41 42 43 44 45 46 47 48 49 50 ## 0.826 0.771 -0.538 -2.283 0.826 0.881 -2.447 2.626 1.262 -0.810 ## 51 52 53 54 55 ## 4.371 -0.210 0.226 3.935 0.444
glm(Accept ~ GPA, data = MedGPA, family = "binomial") %>% predict(type = "response")
## 1 2 3 4 5 6 7 8 9 10 ## 0.3688 0.1496 0.8306 0.2851 0.6838 0.2529 0.1181 0.7290 0.2634 0.1181 ## 11 12 13 14 15 16 17 18 19 20 ## 0.0797 0.5428 0.2049 0.3815 0.7699 0.4747 0.3315 0.4747 0.8146 0.1181 ## 21 22 23 24 25 26 27 28 29 30 ## 0.2634 0.2049 0.1072 0.1239 0.2963 0.4476 0.6093 0.4208 0.6598 0.1640 ## 31 32 33 34 35 36 37 38 39 40 ## 0.3688 0.9132 0.1181 0.2741 0.8227 0.1363 0.4747 0.6598 0.1300 0.8890 ## 41 42 43 44 45 46 47 48 49 50 ## 0.6955 0.6838 0.3688 0.0925 0.6955 0.7069 0.0797 0.9325 0.7794 0.3078 ## 51 52 53 54 55 ## 0.9875 0.4476 0.5563 0.9808 0.6093
what are the odds
what are the odds
Stat2Data
, tidyverse
, and broom
librariesdata("MedGPA")
MCAT
from GPA
Accept
from GPA
GPA
in the second model?what are the odds
what are the odds
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |