Using logistic regression in R

Performing logistic regression—an advanced and widely used classification method—could scarcely be easier in R. To fit a logistic regression, we use the familiar glm function. The difference now is that we'll be specifying our own error distribution and link function (the glm calls of last chapter assumed we wanted the regular linear regression error distribution and link function, by default). These are specified in the family argument:

  model <- glm(diabetes ~ ., data=PID, family=binomial(logit)) 

Here, we build a logistic regression using all available predictor variables.

You may also see logistic regressions being performed where the family argument looks like family="binomial" or family=binomial()—it's ...

Get Data Analysis with R - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.