Generalized Linear Models in R
Richard Erickson
Instructor
Does commute distance change the probability of taking the bus?
ggplot(bus, aes(x = MilesOneWay, y = Bus)) + geom_point()
gg_jitter <- ggplot(bus, aes(x = MilesOneWay, y = Bus)) +
geom_jitter(width = 0, height = 0.05)
print(gg_jitter)
gg_jitter + geom_smooth()
str(bus)
bus$Bus2 <- as.numeric(bus$Bus) - 1
gg_jitter + geom_smooth()
gg_jitter + geom_smooth(method = 'glm')
ggJitter +
geom_smooth(method = 'glm',
method.args = list(family = "binomial"))
gg_jitter +
geom_smooth(method = 'glm',
method.args = list(family = binomial(link = 'logit')),
se = FALSE, color = 'red') +
geom_smooth(method = 'glm',
method.args = list(family = binomial(link = 'probit')),
se = FALSE, color = 'blue')
Generalized Linear Models in R