O'Reilly logo

Data Analysis with R - Second Edition by Tony Fischetti

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required