Generalized Linear Models in R
Richard Erickson
Instructor
Linear regression is straight forward:
Poisson regression:
Log-odds ("logit"):
$\phi(x) = \text{ln}(\frac{p(x)}{1 - p(x)}) = \beta_0 + \beta_1 x$
Odds, take exponential ($e^{x}$):
$\frac{p(x)}{1 - p(x)} = e^{\beta_0 + \beta_1x}$
Odds-ratio (OR) for continuous variable:
$\text{OR} = \frac{e^{\beta_0 + \beta_1(x +1)}}{e^{\beta_0 + \beta_1x}} = e^{\beta_1}$
OR Values:
Non-smoking vs smoking males (Pesch et al. 2012)
glm_out <- glm(y ~ x, family = 'binomial')
coef(glm_out)
exp(coef(glm_out))
confint(glm_out)
exp(confint(glm_out))
library(broom)
glm_out <- glm(y ~ x, family = 'binomial')
tidy(glm_out, exponentiate = TRUE, conf.int= TRUE)
Generalized Linear Models in R