Binary GLM for the Wells Dataset

Let’s learn how to fit binary GLMs on the Wells dataset.

The wells dataset for the binary GLM example

It looks like the probability of switching declines with distance, which seems like a reasonable expectation. Before we fit the GLM, we can avoid inconveniently small coefficient values by rescaling the distance in hundreds of meters:

wells$dist100 <- wells$dist/100

We can fit a GLM of switching versus distance, specify a binomial distribution and the default logit link function, and examine the residuals. Click the “Run” button in the code widget below to see this in action:

Get hands-on with 1200+ tech skills courses.