Skip to course content
Free R statistics course

Statistical Data Analytics with R

Unit 10.02: The family argument is the whole difference

glm() without family = binomial fits a linear model, and R will not warn you.

The family argument is the whole difference

glm(y ~ x, family = binomial) fits a logistic regression. Omitting the family argument gives you a Gaussian fit — an ordinary linear model — with no error and no warning, and everything downstream is wrong.

The coefficients are on the log-odds scale. A positive value means the predictor raises the log-odds of the outcome; the size is not directly interpretable as a probability change.

Instead of R-squared, logistic output reports deviance. The drop from null deviance to residual deviance is what the predictors contributed, on the degrees of freedom they consumed.

This block fits churn on tenure and a support-contact indicator.

suppressPackageStartupMessages(library(broom))
set.seed(703)
n <- 500
tenure  <- runif(n, 0, 48)
support <- rbinom(n, 1, 0.35)
p_true  <- 1 / (1 + exp(-(1.4 - 0.07 * tenure + 0.9 * support)))
churn   <- rbinom(n, 1, p_true)
d <- data.frame(churn, tenure, support)

model <- glm(churn ~ tenure + support, data = d, family = binomial)
print(tidy(model))

cat("\nfamily = binomial is what makes this logistic. Leaving it out fits a\n")
cat("linear model and R will not complain.\n\n")
cat("Coefficients are on the LOG-ODDS scale:\n")
cat("  tenure  :", round(coef(model)["tenure"], 4),
    "log-odds per extra month\n")
cat("  support :", round(coef(model)["support"], 4),
    "log-odds for having contacted support\n\n")
cat("Null deviance:", round(model$null.deviance, 1),
    " Residual deviance:", round(model$deviance, 1), "\n")
cat("The drop of", round(model$null.deviance - model$deviance, 1),
    "on", model$df.null - model$df.residual, "df is this model's contribution.\n")

Tenure enters at −0.0769 log-odds per extra month and support contact at +1.28, both with very small p-values. The null deviance of 690.6 falls to a residual deviance of 555.3 — a drop of 135.3 on 2 degrees of freedom, which is this model's contribution. Neither coefficient can be read as a probability without conversion.

The mistake this prevents

The mistake is forgetting family = binomial. The output looks plausible, the coefficients are on a different scale from the one you think, and nothing in the printout says so.

Takeaway

Always pass family = binomial and check that the output mentions deviance rather than residual standard error. Read coefficients as log-odds and convert before interpreting.