Generalized Linear Models in R
Richard Erickson
Instructor
Default GLM for binomial family
Model of binary data
$Y = \text{Binomial}(p)$
Linked to linear equation
$\text{logit}(p) = \beta_0 + \beta_1 x + \epsilon$
Logit defined as
$\text{logit}(p) = \text{log}\left(\frac{p}{1-p}\right)$
Inverse logit defined as
$\text{logit}^{-1}(x) = \frac{1}{1 + \text{exp}(-x)}$
Function:
glm(y ~ x, data = dat, family = 'binomial')
Inputs:
y = c(0, 1, 0, 0, 1...)
y = c("yes", "no"...)
y = c("win", "lose"...)
# Or any 2-level factor
CommuteDays Bus
1 5 Yes
2 2 No
Generalized Linear Models in R