Fitting a logistic regression
Pittsburgh is a city located in Allegheny County, PA, USA. Commuters living in this area have different options for commuting to work, including taking the bus. Using data from 2015, you will see if the number of commuting days per week increases the chance somebody will ride the bus. The choice of riding the bus is a binary outcome, hence you will use a logistic regression to model this data.
This exercise is part of the course
Generalized Linear Models in R
Exercise instructions
- Using the data.frame
bus
, fit a logistic regression in R usingglm()
with a"binomial"
family. The variableBus
should be predicted byCommuteDays
. - Save the model as
bus_out
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Build a glm using the bus data frame that models Bus predicted by CommuteDays
bus_out <- ___