Generalized Linear Models ใน R
Richard Erickson
Instructor
Linear regression เข้าใจง่าย:
Poisson regression:
Log-odds ("logit"):
$\phi(x) = \text{ln}(\frac{p(x)}{1 - p(x)}) = \beta_0 + \beta_1 x$
Odds นำ exponential ($e^{x}$):
$\frac{p(x)}{1 - p(x)} = e^{\beta_0 + \beta_1x}$
Odds-ratio (OR) สำหรับตัวแปรต่อเนื่อง:
$\text{OR} = \frac{e^{\beta_0 + \beta_1(x +1)}}{e^{\beta_0 + \beta_1x}} = e^{\beta_1}$
ค่า OR:
ชายไม่สูบบุหรี่เทียบกับสูบบุหรี่ (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 ใน R