COMP328 Fundamentals of Machine Learning

01 Learning objectives

By the end of this tutorial you will be able to

  • Define odds, odds ratio and log-odds, and convert freely between them and probability.
  • Interpret a logistic regression coefficient on the log-odds, odds-ratio and probability scales.
  • Compute and interpret odds ratios for both binary and continuous predictors.
  • Explain why the same odds ratio produces different changes in probability for different baseline risks, and compute the marginal effect.
  • Interpret a confidence interval for an odds ratio, and explain what "statistically significant" does and does not mean.
  • Recognise and correct the most common interpretation errors, including conflating odds with probability and treating odds ratios as risk ratios.
  • Present logistic regression results appropriately to technical and non-technical audiences.

Position in the unit

This tutorial is about what the fitted coefficients mean. It assumes the model form from T-02 and the estimation procedure from T-04, and it prepares the ground for T-06 (where the threshold interacts with the base rate) and T-07 (where regularisation shrinks the coefficients you are interpreting). The material here is the part of logistic regression that is used most often in practice — and misunderstood most often.

02 Motivating example

A hospital has fitted a logistic regression to predict 30-day readmission using data from several thousand discharged patients. The fitted model is:

z = −2.1 + 0.03·age + 0.8·diabetes + 0.4·prior_admissions − 0.6·discharge_plan

where age is measured in years, diabetes is 1 if the patient has a diabetes diagnosis and 0 otherwise, prior_admissions counts the number of admissions in the previous year, and discharge_plan is 1 if a structured discharge plan was put in place and 0 otherwise.

The clinical team asks a simple question: how much does diabetes increase the risk of readmission?

The coefficient is 0.8. Someone looks at it and says: "diabetes increases the probability of readmission by 0.8." That would be an 80-percentage-point increase — which is obviously impossible, since probabilities cannot exceed 1.

Someone else, a bit more careful, says: "diabetes multiplies the probability by 0.8." That is also wrong, and in the opposite direction: a multiplier less than 1 would mean diabetes reduces readmission risk, which contradicts the positive sign.

Both attempts fail because they assume the coefficient lives on the probability scale. It does not. The coefficient lives on the log-odds scale, and moving to the probability scale requires a transformation that depends on where the patient started.

The correct statement turns out to be: diabetes multiplies the odds of readmission by about 2.23 — an increase of roughly 123% in odds. But even this is not the full story, because the corresponding change in probability ranges from about 4 percentage points to about 16 percentage points depending on the patient. Same coefficient, same odds ratio, very different clinical significance.

Understanding why is the subject of this tutorial.

The interpretation trap

Logistic regression is one of the most widely used models in medicine, the social sciences and industry. It is also one of the most widely misinterpreted. The coefficients are on the log-odds scale; the output is on the probability scale; the ratio of odds is on a third scale again. Mixing them up produces statements that are confidently wrong — and because they sound plausible, the errors propagate into reports, policy briefs and published papers.

03 Concept explanation

3.1 Why probability is not the natural scale

A probability is a number in [0, 1]. That range creates two problems for interpreting coefficients.

First, a probability cannot increase by a fixed amount indefinitely. If p = 0.9 and something increases the risk, there is only 0.1 of headroom. The same effect that raises a probability from 0.1 to 0.2 cannot raise one from 0.9 to 1.0.

Second, probabilities are not additive in the way coefficients are. A logistic regression says that each feature contributes a fixed amount to a score — but that fixed contribution does not translate into a fixed change in probability.

The odds scale solves the first problem. The log-odds scale solves both.

3.2 Odds

The odds of an event are the ratio of the probability that it happens to the probability that it does not:

odds = p / (1 − p)

If p = 0.75, the odds are 0.75 / 0.25 = 3. This is usually expressed as "3 to 1 in favour" — three ways to win for every one way to lose. If p = 0.20, the odds are 0.20 / 0.80 = 0.25, or "1 to 4 in favour."

The range of odds is [0, ∞). This is better than probability because there is now no upper ceiling — an event can become arbitrarily more likely as the odds grow. But odds still cannot be modelled by an unrestricted linear function, because they cannot go below zero.

Odds are the language of betting, and this is not a coincidence. A bookmaker quoting "3 to 1" is quoting odds, because odds are the natural way to express a multiplicative relationship between risk factors.

3.3 Odds ratios

When a predictor changes, the odds change. The odds ratio (OR) is the factor by which they change:

OR = odds(condition present) / odds(condition absent)

An odds ratio of 2 means the odds double. An odds ratio of 0.5 means the odds halve. An odds ratio of 1 means no change — the predictor has no effect on the odds.

Odds ratios are the standard way to report logistic regression results in medicine, epidemiology and the social sciences. They are convenient because they are dimensionless — an OR of 2.2 means the same thing regardless of the baseline risk — and because they are directly available from the coefficients.

3.4 Log-odds, and why the model uses them

The log-odds, also called the logit, is the natural logarithm of the odds:

log-odds = log( p / (1 − p) )

As T-02 established, this is the scale on which logistic regression is linear:

log( p / (1 − p) ) = β₀ + β₁x₁ + … + βₚxₚ

The log-odds range over (−∞, ∞), so an unrestricted linear function is perfectly suited to modelling them. This is why the model is expressed on this scale, and why the coefficients live here.

The relationship between the three scales is a chain of transformations:

The chain

probability → odds (divide by 1 − p)
odds → log-odds (take the logarithm)
and back the other way: log-odds → odds (exponentiate), odds → probability (p = odds / (1 + odds)).

The table below gives anchor values on all three scales. It is worth internalising a few of these — particularly that p = 0.5 corresponds to odds of 1 and log-odds of 0, and that p = 0.1 and p = 0.9 correspond to log-odds of roughly −2.2 and +2.2.

The three scales side by side
Probability p Odds p/(1−p) Log-odds log(p/(1−p))
0.010.010−4.595
0.050.053−2.944
0.100.111−2.197
0.200.250−1.386
0.300.429−0.847
0.400.667−0.405
0.501.0000.000
0.601.5000.405
0.702.3330.847
0.804.0001.386
0.909.0002.197
0.9519.0002.944
0.9999.0004.595

The symmetry is worth noting. Because σ(−z) = 1 − σ(z), the log-odds of complementary probabilities are exact negatives: logit(0.1) = −2.197 and logit(0.9) = +2.197.

3.5 Interpreting a coefficient: three scales

A single coefficient βⱼ can be read on all three scales. Each reading is correct; each answers a different question. Using the readmission model, with β = 0.8 for diabetes:

Three readings of the same coefficient (β = 0.8)
Scale Statement Computation
Log-odds Diabetes increases the log-odds of readmission by 0.8. β = 0.8
Odds Diabetes multiplies the odds of readmission by 2.23. e^0.8 = 2.2255
Odds (% change) Diabetes increases the odds of readmission by about 123%. (2.2255 − 1) × 100
Probability Depends on the baseline risk — see Section 3.7. Not a single number

Notice that three of the four rows give a specific number, and only the probability-scale reading does not. That is the central difficulty: the probability-scale effect is not a property of the coefficient alone.

The rule to memorise

A coefficient βⱼ is additive on the log-odds scale and multiplicative on the odds scale. It is not additive or multiplicative on the probability scale.

3.6 Continuous and binary predictors

The interpretation differs slightly depending on whether the predictor is binary or continuous.

Binary predictors. For a variable that is 0 or 1, the interpretation is direct: the odds ratio compares the two groups. For diabetes: OR = e^0.8 = 2.23 — patients with diabetes have 2.23 times the odds of readmission compared with patients without diabetes, holding all other variables constant.

Continuous predictors. For a variable measured on a continuous scale, the odds ratio refers to a one-unit change. For age with β = 0.03:

OR per year = e^0.03 = 1.0305

Each additional year of age multiplies the odds of readmission by 1.03 — a 3% increase per year. Per year this sounds small; the compounding is what matters. For a ten-year difference:

OR per decade = e^(10 × 0.03) = e^0.3 = 1.3499

A decade of age multiplies the odds by 1.35 — a 35% increase. This is a much more useful number to report, and it is the sort of re-scaling that makes continuous predictors interpretable in practice.

Scaling continuous predictors for interpretation

When a one-unit change is not clinically or practically meaningful — one dollar of income, one gram of weight, one second of duration — consider rescaling the predictor before fitting. Dividing age by 10 gives a coefficient that directly represents the per-decade effect. The model is mathematically identical; the coefficients are simply easier to read.

3.7 The same odds ratio, different probability effects

This is the point that causes the most confusion, and it deserves careful attention.

The odds ratio for diabetes is 2.23. That number does not depend on the patient. But the corresponding change in probability does — because the probability scale is non-linear in the log-odds.

Consider three patients with different baseline risks. For each, we compute the predicted probability before and after adding diabetes to the model (which simply adds 0.8 to the score).

The same odds ratio, three different probability changes
Patient Baseline p With diabetes p Change in p Odds ratio
Low risk
45y, 0 admissions, plan
0.206 0.366 +16.0 pp 2.23
Medium risk
70y, 2 admissions, no plan
0.690 0.832 +14.2 pp 2.23
High risk
85y, 5 admissions, no plan
0.921 0.963 +4.2 pp 2.23

All three rows have the same odds ratio of 2.23. The change in probability ranges from 16 percentage points for the low-risk patient to just over 4 percentage points for the high-risk patient.

Why? Because the high-risk patient is already near the ceiling. Their probability of 0.921 cannot rise much, however favourable the odds become. The odds can still double — from 11.7 to 26.0 — but the probability can only move from 0.921 to 0.963.

This is the saturation behaviour of the sigmoid made concrete. It means that reporting an odds ratio alone can be misleading, and reporting a probability change requires specifying for whom.

3.8 Marginal effects: communicating on the probability scale

The standard solution is the marginal effect — the change in predicted probability associated with a one-unit change in a predictor, holding the other predictors at specified values.

For a continuous predictor, the marginal effect at a particular point is:

∂p/∂xⱼ = βⱼ · p · (1 − p)

This is a genuinely useful formula, and it explains the phenomenon in Section 3.7 in a single line. The derivative of the sigmoid is p(1 − p), which is largest at p = 0.5 (where it equals 0.25) and shrinks towards zero as p approaches 0 or 1. So the same coefficient βⱼ has its greatest effect on probability when the baseline risk is near 0.5, and its smallest effect at the extremes.

For a binary predictor, the analogous quantity is the change in predicted probability when the indicator switches from 0 to 1, evaluated at specified values of the other predictors. This is sometimes called the average marginal effect when it is computed for every observation and then averaged.

Average marginal effects are increasingly the preferred way to communicate logistic regression results to non-technical audiences, because they express effects in the units people actually care about — percentage points of probability — rather than in odds ratios.

3.9 Confidence intervals and statistical significance

A coefficient is an estimate, not a known truth. The fitted value of 0.8 is the most likely value given the data, but other values are also plausible. This uncertainty is captured by a confidence interval.

Confidence intervals for coefficients are typically computed on the log-odds scale — where the sampling distribution is closer to normal — and then exponentiated to give a confidence interval for the odds ratio. A 95% interval for the diabetes coefficient might be:

β ∈ [0.538, 1.063]

OR ∈ [e^0.538, e^1.063] = [1.71, 2.89]

Three things can be read from this interval.

  • The point estimate is OR = 2.23 — the single best guess.
  • The uncertainty is substantial. The true effect could plausibly be anywhere from a 71% increase in odds to a 189% increase. Both are compatible with the data.
  • Zero effect is excluded. The interval does not contain OR = 1, which corresponds to β = 0. This is what "statistically significant at the 5% level" means for a single coefficient.

What significance does not mean

A significant coefficient does not mean the effect is large, and a non-significant coefficient does not mean the effect is zero. With enough data, even a trivial effect becomes statistically significant. With too little data, even an important effect may fail to reach significance. The confidence interval tells you what you actually need to know — the range of plausible values — and it is always more informative than the significant/not-significant dichotomy.

3.10 The interpretation errors to avoid

The table below collects the mistakes that appear most often in practice. Each is followed by the correct statement.

Common interpretation errors and their corrections
Wrong statement Why it is wrong Correct statement
"β = 0.8 means an 80 percentage point increase in probability." The coefficient is on the log-odds scale, not the probability scale. "β = 0.8 means an 0.8 increase in log-odds."
"OR = 2 means twice as likely." It means twice the odds, not twice the probability. "OR = 2 means the odds are twice as high."
"OR = 2 means the risk is doubled." Only true when the outcome is rare, so that odds ≈ risk. "OR = 2 approximately doubles the risk when the outcome is rare."
"Diabetes raises readmission risk by 123%." 123% is the increase in odds, not in risk. "Diabetes raises the odds by 123%; the change in risk depends on the patient."
"The intercept β₀ = −2.1 is the baseline risk." The intercept is the log-odds when all predictors are zero, which is often not meaningful. "The intercept is a baseline offset; interpret it only if zero is a meaningful value for every predictor."
"The coefficient is not significant, so there is no effect." Absence of evidence is not evidence of absence. "The data are consistent with effects ranging from X to Y."
"The odds ratio changed when I added a covariate, so the earlier estimate was wrong." Odds ratios are non-collapsible; they legitimately change when the adjustment set changes. "The odds ratio is conditional on the covariates in the model."

Non-collapsibility: an advanced note

Logistic regression odds ratios have a property that linear regression coefficients do not: they change when you add or remove other covariates, even if those covariates are unrelated to the predictor you are interested in. This is called non-collapsibility, and it is a mathematical property of the odds ratio, not a sign of a mistake. The practical implication is that a logistic regression coefficient is always conditional on the other variables in the model, and comparing odds ratios across models with different covariates requires care.

3.11 Presenting results

Different audiences need different framings. The table below gives a rule of thumb.

Choosing a scale for your audience
Audience Recommended scale Rationale
Clinicians, policymakers Average marginal effects (probability points) Directly interpretable in the units that matter for decisions
Statisticians, epidemiologists Odds ratios with confidence intervals The standard convention; comparable across studies
Model developers Coefficients (log-odds) The scale on which the model is linear and additive
General public Absolute risks before and after Probabilities are the intuitive quantity; ratios are easily misread

A report that gives only odds ratios is not wrong, but it is incomplete. A report that gives odds ratios, confidence intervals, and average marginal effects gives readers everything they need to form their own judgement — which is the purpose of reporting results at all.

04 Visual illustration

Figure 1 plots odds against probability. The relationship is strongly non-linear, and the shape of the curve explains why the probability-scale effect of a coefficient depends on the baseline risk.

Odds as a function of probability A graph showing odds on the vertical axis and probability on the horizontal axis. The curve is relatively flat and low for probabilities below about 0.6, then rises steeply towards infinity as probability approaches 1. A dashed horizontal line marks odds equal to 1, and a dot marks the point where probability is 0.5 and odds are exactly 1. odds = 1 p = 0.5, odds = 1 odds grow without bound as p → 1 0.0 0.2 0.4 0.6 0.8 1.0 0 2 4 6 8 10 probability p odds p / (1 − p)
Figure 1. Odds as a function of probability. The relationship is roughly linear for small probabilities, then accelerates sharply as p approaches 1. A fixed multiplicative change in odds therefore corresponds to a much smaller change in probability when the baseline is already high.

Read the curve at the three patients from Section 3.7. The low-risk patient sits at p = 0.206, where the curve is still relatively flat: doubling the odds moves them a long way up the probability scale. The high-risk patient sits at p = 0.921, in the steep region where the curve is nearly vertical: doubling the odds barely moves them at all.

Figure 2 shows the fitted odds ratios for the readmission model, with 95% confidence intervals. This is the standard way to present logistic regression results in a report, and it is worth learning to read.

Forest plot of odds ratios for the readmission model A forest plot showing five predictors from the readmission model. The horizontal axis is on a logarithmic scale from 0.4 to 3.0. Each predictor is shown as a point estimate with a horizontal line indicating its 95 percent confidence interval. Diabetes, prior admissions and age per decade all have odds ratios above 1; a discharge plan has an odds ratio below 1; age per year has a point estimate very close to 1 with a narrow interval. A vertical dashed line marks odds ratio equal to 1. Diabetes 2.23 [1.71, 2.89] Prior admissions 1.49 [1.30, 1.71] Age (per decade) 1.35 [1.20, 1.52] Discharge plan 0.55 [0.42, 0.72] Age (per year) 1.03 [1.02, 1.04] 0.5 1.0 1.5 2.0 2.5 3.0 odds ratio (log scale) point estimate with 95% confidence interval
Figure 2. Odds ratios for the readmission model, with 95% confidence intervals. The vertical dashed line at OR = 1 marks no effect. Intervals that do not cross this line correspond to statistically significant coefficients at the 5% level.

Three features of Figure 2 are worth pointing out. First, the horizontal axis is on a logarithmic scale, so that OR = 0.5 and OR = 2 are equidistant from OR = 1. This is standard for odds-ratio plots, because the log-odds scale is where the uncertainty is symmetric. Second, the intervals vary enormously in width: the diabetes interval spans more than a factor of three, while the age-per-year interval is razor-thin. Third, the discharge-plan interval lies entirely below 1, indicating a protective effect — the only predictor in the model that reduces readmission odds.

05 Worked example

We work through the readmission model in detail, Computing every quantity that would appear in a report.

Worked example 1 · Full interpretation of one coefficient

The diabetes coefficient is β = 0.8. Suppose the reported standard error is SE = 0.134, giving a 95% confidence interval for β of [0.8 − 1.96×0.134, 0.8 + 1.96×0.134] = [0.538, 1.063].

Step 1 — point estimate on the odds scale.

OR = e^0.8 = 2.2255

Step 2 — percentage change in odds.

(2.2255 − 1) × 100 = 122.6%

Step 3 — confidence interval for the odds ratio.

Lower: e^0.538 = 1.712
Upper: e^1.063 = 2.895

OR ∈ [1.71, 2.89]

Step 4 — statistical significance.

The interval excludes 1, so the effect is significant at the 5% level. The p-value would be less than 0.05.

Step 5 — write the report sentence.

"Patients with a diabetes diagnosis had 2.23 times the odds of 30-day readmission compared with patients without diabetes, adjusting for age, prior admissions and discharge planning (95% CI 1.71 to 2.89; p < 0.05)."

Step 6 — add the probability-scale reading.

To express this on the probability scale, we must specify a baseline. Taking the medium-risk patient from Section 3.7 (70 years old, 2 prior admissions, no discharge plan, no diabetes), the predicted probability without diabetes is 0.690 and with diabetes is 0.832 — a 14.2 percentage-point increase.

"For a patient with the characteristics of our median case, a diabetes diagnosis was associated with an increase in predicted readmission risk from 69% to 83%."

Worked example 2 · A continuous predictor, three scales

The age coefficient is β = 0.03 per year. We work through all three scales.

Step 1 — per-year effect.

OR per year = e^0.03 = 1.0305

Each additional year of age multiplies the odds of readmission by 1.031 — a 3.05% increase in odds.

Step 2 — per-decade effect.

Because the model is additive on the log-odds scale, a 10-year change adds 10 × 0.03 = 0.3 to the log-odds:

OR per decade = e^0.3 = 1.3499

A decade of age multiplies the odds by 1.35 — a 35% increase. Note that this is not simply ten times the per-year percentage. Odds ratios compound: 1.0305^10 = 1.3499.

Step 3 — comparing two specific ages.

Comparing a 75-year-old with a 55-year-old is a 20-year difference, adding 20 × 0.03 = 0.6 to the log-odds:

OR = e^0.6 = 1.8221

The older patient has 1.82 times the odds of readmission.

Step 4 — marginal effect on the probability scale.

Using the marginal-effect formula ∂p/∂x = β · p · (1 − p), at a baseline risk of p = 0.5:

∂p/∂age = 0.03 × 0.5 × 0.5 = 0.0075

At p = 0.5, each additional year of age increases the predicted probability by about 0.75 percentage points. At a baseline risk of p = 0.9:

∂p/∂age = 0.03 × 0.9 × 0.1 = 0.0027

At p = 0.9, the same year of age increases the probability by only about 0.27 percentage points. The coefficient is identical; the probability-scale effect is nearly three times smaller.

Worked example 3 · A protective factor

The discharge-plan coefficient is β = −0.6. This is a binary predictor coded 1 if a plan was in place.

Step 1 — odds ratio.

OR = e^(−0.6) = 0.5488

Step 2 — percentage change.

(0.5488 − 1) × 100 = −45.1%

Having a discharge plan in place is associated with a 45% reduction in the odds of readmission, adjusting for the other variables.

Step 3 — the tempting but wrong phrasing.

It would be wrong to say "a discharge plan reduces readmission risk by 45%." That statement conflates odds with risk. The correct statement specifies the scale: "a discharge plan reduces the odds of readmission by 45%."

Step 4 — the probability-scale reading.

For the medium-risk patient (70 years, 2 prior admissions, no diabetes), the model gives p = 0.690 without a plan. With a plan, the score falls by 0.6:

z = 0.8 − 0.6 = 0.2
p = σ(0.2) = 1 / (1 + e^(−0.2)) = 1 / 1.8187 = 0.5498

The probability falls from 0.690 to 0.550 — a reduction of about 14 percentage points. This is the number a clinical team would find most useful, and it is the number that does not appear anywhere in the coefficient.

The pattern across the three examples

In every case, the odds ratio is a single number that applies to every patient. The probability-scale effect is a different number for every patient. When you write a report, decide which of these you need — and be explicit about it.

06 Interactive activity

Activity · Translate between the three scales

In this activity you will work with the readmission model and see the three scales in action. The goal is fluency: given any quantity on any scale, you should be able to move to the others.

  1. Compute the predicted probability for a 60-year-old patient with diabetes, 1 prior admission and a discharge plan.
  2. Compute the odds and the log-odds for the same patient. Verify that the log-odds you compute equal the linear score z from the model.
  3. Now suppose the patient does not have diabetes. Recompute the probability, the odds and the log-odds.
  4. Compute the odds ratio for diabetes directly from the two sets of odds you have just calculated. Do you get 2.23?
  5. Compute the change in probability. How does it compare with the 14.2 percentage-point change for the medium-risk patient in Section 3.7?
  6. Now work backwards: for what baseline probability does adding diabetes change the predicted probability by exactly 10 percentage points?
Companion notebook — scales and marginal effects Convert between probability, odds and log-odds; compute marginal effects; and plot probability change against baseline risk.
import numpy as np
import matplotlib.pyplot as plt

def sigmoid(z):
    return 1 / (1 + np.exp(-z))

def odds(p):
    return p / (1 - p)

def logit(p):
    return np.log(odds(p))

# Readmission model
def score(age, diabetes, prior_adm, discharge_plan):
    return -2.1 + 0.03*age + 0.8*diabetes + 0.4*prior_adm - 0.6*discharge_plan

# Patient: 60y, diabetes, 1 prior admission, discharge plan
z = score(60, 1, 1, 1)
p = sigmoid(z)
print(f"z = {z:.3f}")
print(f"p = {p:.4f}")
print(f"odds = {odds(p):.4f}")
print(f"logit(p) = {logit(p):.4f}  (should equal z)")

# Same patient without diabetes
z2 = score(60, 0, 1, 1)
p2 = sigmoid(z2)
print(f"\nWithout diabetes: z = {z2:.3f}, p = {p2:.4f}")
print(f"Odds ratio = {odds(p)/odds(p2):.4f}")
print(f"Change in p = {(p - p2)*100:.1f} percentage points")

# Probability change as a function of baseline risk
baseline_p = np.linspace(0.01, 0.99, 200)
baseline_z = logit(baseline_p)
with_diabetes_p = sigmoid(baseline_z + 0.8)

fig, ax = plt.subplots(figsize=(7.5, 5))
ax.plot(baseline_p, (with_diabetes_p - baseline_p) * 100, linewidth=2.6,
        color="#1f4e8c")
ax.set_xlabel("baseline probability (without diabetes)")
ax.set_ylabel("change in probability (percentage points)")
ax.set_title("The same odds ratio (2.23) produces different probability changes")
ax.grid(alpha=0.25)
plt.tight_layout()
plt.show()

The plot is the single most useful way to internalise Section 3.7. The curve peaks around p = 0.5 and falls away on both sides. At the peak, adding diabetes changes the probability by around 16 percentage points. Near p = 0.05 or p = 0.95, the same odds ratio changes the probability by only a few points.

This is the derivative β·p·(1−p) from Section 3.8 in graphical form. The quantity p(1−p) is the variance of a Bernoulli random variable, and it is largest at p = 0.5 — precisely where the sigmoid is steepest and where additional evidence has the most impact.

07 Self-check questions

Answer each question before revealing the solution.

Question 1

A model predicts p = 0.4. What are the odds? What is the log-odds?

Show answer

Odds = 0.4 / 0.6 = 0.6667. Log-odds = log(0.6667) = −0.405.

This matches the table in Section 3.4.

Question 2

A coefficient is β = 0.35. Interpret it on all three scales.

Show answer
  • Log-odds: a one-unit increase in the predictor adds 0.35 to the log-odds.
  • Odds: the odds are multiplied by e^0.35 = 1.419 — a 41.9% increase.
  • Probability: the change depends on the baseline. At p = 0.5, the marginal effect is 0.35 × 0.25 = 0.0875, or about 8.75 percentage points per unit.

Question 3

Two patients have predicted readmission probabilities of 0.15 and 0.85. The same risk factor raises both their log-odds by 0.5. Which patient experiences the larger change in probability?

Show answer

Let us compute both.

  • Patient 1: logit(0.15) = −1.735. After: −1.235. New probability = σ(−1.235) = 0.2253. Change: +7.5 percentage points.
  • Patient 2: logit(0.85) = +1.735. After: +2.235. New probability = σ(2.235) = 0.9033. Change: +5.3 percentage points.

Patient 1 experiences the larger change, because 0.15 is closer to 0.5 than 0.85 is. The further a baseline probability is from 0.5, the smaller the probability-scale effect of a given change in log-odds. (By symmetry, the two patients would experience identical changes if their baselines were symmetric around 0.5 — for example, 0.3 and 0.7.)

Question 4

An odds ratio for a treatment is 0.4 with a 95% confidence interval of [0.2, 0.8]. Interpret this result.

Show answer

The treatment is associated with a 60% reduction in the odds of the outcome. The interval excludes 1, so the effect is statistically significant at the 5% level. However, the uncertainty is substantial: the true effect could plausibly be as small as a 20% reduction or as large as an 80% reduction.

Question 5

Why is it wrong to say "an odds ratio of 2 means twice as likely"?

Show answer

Because odds and probability are different quantities. An odds ratio of 2 means the odds are twice as high, not the probability or risk.

For a rare outcome, the two are numerically close, and the statement is approximately true. For a common outcome, they diverge sharply. An odds ratio of 2 for an outcome with baseline probability 0.5 raises the probability to only about 0.667 — nowhere near "twice as likely."

Question 6

A model's intercept is β₀ = 0.7. Can this be interpreted as "the baseline log-odds"?

Show answer

Only with caution, and usually not. The intercept is the log-odds when every predictor equals zero. If zero is a meaningful value for every predictor — for example, if all predictors are binary indicators and zero means "absent" — then the intercept is interpretable.

But if any predictor is continuous, zero is often not meaningful (a patient with age zero, or an income of zero dollars). In such cases, the intercept is a baseline adjustment rather than a substantive quantity, and it should not be reported as though it described a realistic case.

08 Practice exercises

Work these by hand where possible, then verify computationally.

  1. Convert each of the following probabilities to odds and then to log-odds: 0.05, 0.25, 0.5, 0.75, 0.95.
  2. A coefficient is β = 1.5. What is the odds ratio? What percentage change in odds does it represent?
  3. An odds ratio is reported as 0.75. What is the corresponding coefficient on the log-odds scale? What percentage reduction in odds does it represent?
  4. A continuous predictor has β = 0.2 per unit. What is the odds ratio for a 5-unit increase? For a 10-unit increase?
  5. Using the readmission model, compute the predicted probability for a 55-year-old with no diabetes, 3 prior admissions and no discharge plan.
  6. For the same patient, compute the predicted probability if a discharge plan is put in place. What is the change in probability?
  7. A logistic regression reports OR = 1.8 with 95% CI [1.1, 2.9]. Is the effect statistically significant at the 5% level? What is the range of plausible percentage increases in odds?
  8. A marginal effect computation gives ∂p/∂x = 0.02 at a particular point. Interpret this in a sentence. Is this a property of the coefficient alone, or does it depend on where it is evaluated?

09 Problem sets

These problems require reasoning about interpretation rather than computation.

Problem 1 · A study abstract to critique

A published abstract states: "Diabetes was associated with a 2.2-fold increased risk of readmission (OR = 2.23, 95% CI 1.71–2.89)." Identify the errors in this sentence and rewrite it correctly. How would the sentence change if the outcome had been rare rather than common?

Problem 2 · Comparing two odds ratios

Model A reports OR = 3.0 for a rare outcome with baseline probability 0.02. Model B reports OR = 1.5 for a common outcome with baseline probability 0.40. Which predictor has the larger effect on the probability scale? Compute the probability change in each case, and discuss what this reveals about comparing odds ratios across contexts.

Problem 3 · The intercept puzzle

A logistic regression of readmission on age alone gives an intercept of −3.5. Interpret this value. Is it meaningful? What would have to be true for the intercept to be substantively interpretable? Compare with a model that includes only binary predictors.

Problem 4 · Why non-collapsibility matters

Suppose a researcher fits two models: one with a treatment variable alone, and one with the treatment plus a strongly prognostic covariate. The treatment odds ratio changes from 1.8 to 2.4 when the covariate is added. The researcher concludes that the first model was biased. Is this conclusion correct? Explain non-collapsibility and why the odds ratio legitimately changes when the covariate set changes.

Problem 5 · Choosing a scale for a policy brief

You are writing a one-page policy brief for a hospital board on the effect of discharge planning on readmission. The odds ratio is 0.55, and the average marginal effect is −8.5 percentage points. Which number would you lead with, and why? What additional information would you include to make the brief honest?

Problem 6 · Marginal effect at the mean vs. average marginal effect

One common approach computes the marginal effect at the mean of the predictors. Another computes the marginal effect for each observation and averages the results. These are not the same number. Explain why, and discuss which is more appropriate for reporting to a general audience.

10 Discussion and projects

Discussion questions

  1. Odds ratios are the standard reporting convention in medicine and epidemiology, despite being difficult to interpret on the probability scale. Is this a good convention, or should the field switch to marginal effects? What would be gained and lost?
  2. The non-collapsibility of odds ratios means that a coefficient depends on the other variables in the model. Does this make logistic regression coefficients "unstable"? Or is it a legitimate feature of a conditional model?
  3. A confidence interval can be narrow (precise) but centred on a trivial effect, or wide (imprecise) but centred on an important one. Which is more useful to a decision-maker? Does the answer depend on the decision?
  4. The marginal effect of a predictor depends on where it is evaluated. Does this make the concept of "the effect of X" incoherent in logistic regression? How would you respond to someone who insists on a single number?

Mini-project · Interpreting a real logistic regression

In this project you will fit a logistic regression to a dataset of your choice, compute all the quantities discussed in this tutorial, and write a short report aimed at two different audiences.

  • Choose a dataset

    A binary outcome with at least four predictors, and a mix of binary and continuous variables.

  • Fit the model

    Use scikit-learn with penalty=None for the unregularised fit.

  • Extract coefficients and standard errors

    Use statsmodels if you need standard errors and p-values, which scikit-learn does not provide.

  • Compute odds ratios with confidence intervals

    Exponentiate the coefficients and the interval bounds.

  • Compute marginal effects

    Use the formula β·p·(1−p) for continuous predictors, and evaluate at several values.

  • Write two report paragraphs

    One for a statistical audience using odds ratios, and one for a general audience using probabilities.

  • import numpy as np
    import pandas as pd
    import statsmodels.api as sm
    
    # Fit with statsmodels for full inference
    X = sm.add_constant(df[predictors])
    model = sm.Logit(df["outcome"], X).fit()
    
    # Coefficients with confidence intervals
    params = model.params
    conf = model.conf_int()
    conf.columns = ["lower", "upper"]
    
    results = pd.DataFrame({
        "beta": params,
        "OR": np.exp(params),
        "OR_lower": np.exp(conf["lower"]),
        "OR_upper": np.exp(conf["upper"]),
        "p_value": model.pvalues,
    })
    print(results.round(3))
    
    # Marginal effects for a continuous predictor
    def marginal_effect(beta_j, p):
        return beta_j * p * (1 - p)
    
    # Evaluate at several baseline probabilities
    for p in [0.1, 0.3, 0.5, 0.7, 0.9]:
        me = marginal_effect(params["age"], p)
        print(f"p = {p:.1f}: marginal effect of age = {me:.4f}")

    As you write the two report paragraphs, notice how differently the same model reads depending on the scale. The statistical audience wants the odds ratio and its interval; the general audience wants to know how much the probability changes for a typical case. Neither report is complete without the other, and a good analyst can produce both from the same fitted model.

    11 Summary

    This tutorial covered the three scales on which a logistic regression can be read, and the interpretation errors that arise from confusing them.

    • Probability, odds and log-odds are three views of one quantity. Their ranges are [0, 1], [0, ∞) and (−∞, ∞). The model is linear on the log-odds scale.
    • Coefficients are additive on the log-odds scale. A coefficient βⱼ is the change in log-odds per unit change in xⱼ.
    • Coefficients are multiplicative on the odds scale. The odds ratio is e^β, and the percentage change in odds is (e^β − 1) × 100.
    • There is no single probability-scale effect. The change in probability depends on the baseline risk. A coefficient has its largest probability effect near p = 0.5 and its smallest at the extremes.
    • Marginal effects express results on the probability scale. For a continuous predictor, ∂p/∂xⱼ = βⱼ · p · (1 − p). For binary predictors, compute the change in predicted probability directly.
    • Confidence intervals are essential. They express the range of plausible values for the coefficient or odds ratio. A significant result does not mean a large effect; a non-significant result does not mean no effect.
    • Odds ratios are not risk ratios. They coincide only when the outcome is rare. For common outcomes, the difference is substantial.
    • Odds ratios are non-collapsible. They change when other covariates are added or removed, even if those covariates are unrelated to the predictor of interest. A coefficient is always conditional on the model.
    • The intercept is rarely interpretable. It is the log-odds when every predictor equals zero, which is often not a meaningful case.
    • Different audiences need different scales. Odds ratios for statistical audiences; marginal effects and probabilities for clinical, policy and general audiences.

    Before moving to T-06

    You should be able to take any coefficient and interpret it on the log-odds, odds and probability scales; compute an odds ratio and its confidence interval; compute a marginal effect; and identify which of the common interpretation errors a given statement commits. You should also be able to explain, without reference to any formula, why the same odds ratio produces different probability changes for different patients.

    12 Further reading

    Core

    • Gelman, Hill & Vehtari — Regression and Other Stories, Chapters 13–14. An exceptionally clear treatment of logistic regression interpretation, with a strong emphasis on communicating results honestly and on the difference between the coefficient scale and the probability scale.
    • Hosmer, Lemeshow & Sturdivant — Applied Logistic Regression, Chapter 3. The standard reference for interpretation, including detailed discussion of odds ratios, confidence intervals and the presentation of results.
    • James, Witten, Hastie & Tibshirani — An Introduction to Statistical Learning, Section 4.3. Covers the basics of logistic regression interpretation, including the odds-ratio reading of coefficients.

    Supplementary

    • Norton, Dowd, Maciejewski & Wang — "Marginal Effects: Quantifying the Effect of Changes in Predictors" (2018). A widely cited paper on marginal effects in logistic regression, with worked examples and clear guidance on when to use them.
    • Mood, C. — "Logistic Regression: Why We Cannot Do What We Think We Can Do, and What We Can Do About It" (2010). A clear treatment of the difficulties in interpreting and comparing coefficients across logistic regression models, including a discussion of unobserved heterogeneity.
    • Pang, Kaufman & Platt — "Studying Noncollapsibility of the Odds Ratio with the Pearson Chi-Square Test" (2016). A short, accessible treatment of why odds ratios change when covariates are added.

    On reporting and communication

    • Schwartz & Woloshin — Know Your Chances. A book about communicating risk to the public, with extensive discussion of why ratios (including odds ratios) are so easily misread and why absolute risks are usually preferable.
    • Gigerenzer, Gaissmaier, Kurz-Milcke, Schwartz & Woloshin — "Helping Doctors and Patients Make Sense of Health Statistics" (2007). The classic review of statistical literacy in medicine, with numerous examples of how ratio-based reporting misleads.
    • Zikmund-Fisher et al. — "Percent Weight Change in Lifestyle Interventions" (2010). A study of how different framings of the same statistical result influence perception — a useful reminder that the choice of scale is not neutral.
    👤