Skip to course content
Free R statistics course

Statistical Data Analytics with R

Unit 10.04: Predict on the link scale, convert afterwards

Nobody outside statistics thinks in log-odds. Convert to probabilities at concrete values, and build the interval before converting.

Predict on the link scale, convert afterwards

The readable output of a logistic model is a table of predicted probabilities at values a reader recognises — at 0 months, at 12, at 24.

The technical point is the order of operations. Compute the prediction and its standard error on the link (log-odds) scale, form the interval there, and convert both endpoints afterwards. Doing it the other way produces intervals that can extend below 0 or above 1.

The resulting probabilities also make the model's non-linearity visible: the same change in the predictor moves the probability by different amounts depending on where you are on the curve.

This block predicts churn probability at six tenure values with intervals.

set.seed(705)
n <- 600
tenure  <- runif(n, 0, 48)
churn   <- rbinom(n, 1, 1 / (1 + exp(-(1.5 - 0.07 * tenure))))
model   <- glm(churn ~ tenure, family = binomial)

newdata <- data.frame(tenure = c(0, 6, 12, 24, 36, 48))
link <- predict(model, newdata, type = "link", se.fit = TRUE)
prob <- 1 / (1 + exp(-link$fit))
lo   <- 1 / (1 + exp(-(link$fit - 1.96 * link$se.fit)))
hi   <- 1 / (1 + exp(-(link$fit + 1.96 * link$se.fit)))

cat(sprintf("%8s %12s %20s\n", "tenure", "P(churn)", "95% CI"))
for (i in seq_len(nrow(newdata))) {
  cat(sprintf("%8d %12.3f      [%.3f, %.3f]\n",
              newdata$tenure[i], prob[i], lo[i], hi[i]))
}

cat("\nThe interval was built on the log-odds scale and converted afterwards,\n")
cat("which is why it never leaves [0, 1].\n\n")
cat("The same 6-month step changes the probability by different amounts:\n")
cat("  0 -> 6 months  :", round(prob[1] - prob[2], 3), "\n")
cat("  36 -> 48 months:", round((prob[5] - prob[6]) / 2, 3), "per 6 months\n")
cat("Report probabilities, not coefficients, to non-technical readers.\n")

Churn probability falls from 0.777 at tenure 0 to 0.138 at 48 months, and every interval stays inside [0, 1] because it was built on the log-odds scale first. The curvature shows in the step sizes: the first six months move the probability by 0.074, while between 36 and 48 months the same six-month step moves it by only 0.06. Intervals are widest at the extremes, where there is least data.

The mistake this prevents

The mistake is converting the endpoints of a probability-scale interval, or reporting a single probability without one. A predicted probability of 0.14 with an interval from 0.10 to 0.19 is a different message from 0.14 alone.

Takeaway

Produce a small table of predicted probabilities at meaningful predictor values, with intervals computed on the link scale. Give that table to non-technical readers instead of the coefficients.