A calf either recovers from respiratory disease or it does not. A herd is classified as test-positive or test-negative. A cow is culled before her second lactation, or she stays. Epidemiology is full of questions whose answer is one of two categories, and logistic regression is the model most researchers reach for when they meet one.
Most software will fit it in a fraction of a second. The harder part is knowing what the numbers mean, which question they answer, and which decisions the analyst made, often without noticing, before pressing run. This article builds a conceptual map of the model so that later articles in this series (odds ratios, confounding, variable selection, specification, uncertainty and appraisal) have somewhere to attach.
Learning objectives
After reading this article you should be able to:
- Recognize research questions with binary outcomes and state when logistic regression is a reasonable candidate.
- Move from a 2×2 table to the equivalent logistic model and explain what each coefficient represents.
- Distinguish log odds, odds ratios and predicted probabilities.
- Explain why association, prediction and causal inference are different goals that call for different analytic decisions.
- Name three decisions that determine whether a model output can support a conclusion.
Contents
- 1. Binary outcomes in veterinary and public health research
- 2. Start from a 2×2 table
- 3. What the model does with this table
- 4. Why the logit scale?
- 5. What the model estimates depends on the question
- 6. Assumptions and data structure you cannot see in the output
- 7. Three decisions behind every output
- Key takeaways
- References
1. Binary outcomes in veterinary and public health research
A binary outcome has two mutually exclusive categories, usually coded 1 for the event of interest and 0 otherwise. In veterinary epidemiology typical examples include disease status of an animal at a given time, whether a herd is classified as infected, whether a treatment succeeded, mortality within a defined period, or a positive or negative test result. In human public health the same structure appears in infection, hospitalisation, vaccination status and adverse events.
Two cautions apply immediately. First, a binary outcome is not automatically a good one. Its definition (case definition, time window, diagnostic test and its error) belongs to the research design, and no model can repair an outcome that was poorly defined. Second, "binary" describes the variable, not the study. Whether the observations are independent, whether follow-up time varies, and whether animals are nested within herds all affect which model is appropriate
2. Start from a 2×2 table
The simplest binary-outcome analysis compares two groups. Consider the following hypothetical cohort of 400 calves followed for the first eight weeks of life. Half were housed in pens with poor ventilation and half in pens with adequate ventilation. The outcome is respiratory disease.
| Respiratory disease | No disease | Total | Risk | Odds | |
|---|---|---|---|---|---|
| Poor ventilation | 60 | 140 | 200 | 0.30 | 0.43 |
| Adequate ventilation | 30 | 170 | 200 | 0.15 | 0.18 |
The risk ratio is 0.30 / 0.15 = 2.0. The odds ratio is (60 × 170) / (140 × 30) = 2.43, with an approximate 95% confidence interval of 1.48 to 3.97 (Wald method). Both describe the same data. They are not the same quantity, and the difference matters.
3. What the model does with this table
Logistic regression models the log odds of the outcome as a linear function of the predictors:
logit(p) = ln( p / (1 − p) ) = β₀ + β₁x₁ + β₂x₂ + …
where p is the probability of the outcome. If we fit a model with one binary predictor (x = 1 for poor ventilation) to the table above, the estimates are β₀ = −1.73 and β₁ = 0.89. Each has a precise meaning:
- β₀ is the log odds of disease in the reference group (adequate ventilation). Its exponential, exp(−1.73) = 0.18, is the odds in that group.
- β₁ is the log odds ratio comparing poor with adequate ventilation. Its exponential, exp(0.89) = 2.43, is the odds ratio from the table.
- A predicted probability is obtained by reversing the transformation: p = 1 / (1 + exp(−(β₀ + β₁x))). For poor ventilation this returns 0.30, for adequate ventilation 0.15.
So one fitted model gives three different quantities: a coefficient on the log-odds scale, an odds ratio, and predicted probabilities. Confusing them is the most common source of misreported results, which is why distinguishing them comes first.
With a single binary predictor the model simply reproduces the table. Its value appears when several predictors enter together. In that case each coefficient is a conditional log odds ratio: it compares animals that differ in that predictor and have the same values of the other variables included in the model. That sentence is more demanding than it sounds, because it is only meaningful if the other variables were chosen sensibly.
4. Why the logit scale?
A probability is bounded between 0 and 1. A model that adds effects linearly to a probability can, for some combinations of predictors, return a value below 0 or above 1, and the variability of a binary outcome is not constant across the range of p. The logit transformation maps probabilities onto the whole real line, so a linear predictor can be unbounded while predicted probabilities always stay between 0 and 1. Estimation is by maximum likelihood.
This is not an argument that linear models for binary outcomes are never acceptable. Some analysts deliberately use a linear probability model or other binomial models to estimate risk differences or risk ratios directly. The point is that this is a deliberate choice with its own trade-offs, not a default.
5. What the model estimates depends on the question
The same command, the same dataset and the same software output can serve three quite different goals:
- Association (description): how is the outcome related to exposures in this population? The odds ratio is a summary of that relationship.
- Prediction: what is the probability of the outcome for a new individual, given their characteristics? Success is judged by calibration, discrimination and performance in new data.
- Causal inference: what would happen to the outcome if the exposure were changed? Answering this question requires more than identifying a statistically significant association. Researchers must consider whether the exposure preceded the outcome, whether confounding and potential biases have been adequately addressed, and whether the exposure represents a clearly defined intervention.
The three goals lead to different choices of covariates, different ways of judging the model and different wording of conclusions. A frequent weakness in published work is that a study designed as descriptive or predictive is written up with causal language, or the reverse. Being explicit about which goal the analysis serves is the single most protective habit an analyst can have.
6. Assumptions and data structure you cannot see in the output
Several conditions sit behind the coefficients and are not displayed in a regression table:
- Independence of observations: Animals within a herd, or patients within a clinic, tend to resemble each other. Ignoring clustering typically produces confidence intervals that are too narrow.
- Follow-up time: If animals are observed for different lengths of time, a binary outcome at the end of follow-up discards information, and a time-to-event or rate-based approach may be more appropriate.
- Outcome and exposure measurement: Imperfect tests and misclassified exposures distort estimates in ways that depend on the pattern of error.
- Specification: Continuous predictors are assumed to act linearly on the log-odds scale unless modelled otherwise, and interactions are absent unless included.
- Sample size and sparse data: Few events relative to the number of parameters, or empty cells, can bias estimates or cause estimation problems.
The useful idea is that a regression table reports estimates, not the validity of the conditions that make them interpretable.
7. Three decisions behind every output
Before any estimate deserves trust, three decisions have already been made, explicitly or by default:
- The question: What is the exposure, what is the outcome, what is the target population, and is the aim association, prediction or causal effect?
- The model: Which variables are included and why, how are continuous variables entered, and is the data structure respected?
- The interpretation: On which scale is the result reported, how is uncertainty communicated, and how far does the design allow the conclusion to go?
Key takeaways
- A binary outcome is a feature of a variable; whether logistic regression is appropriate also depends on the design, the data structure and the question.
- A fitted model yields log-odds coefficients, odds ratios and predicted probabilities. They are related but not interchangeable.
- With several predictors, a coefficient is conditional on the other variables in the model.
- Association, prediction and causal inference are different goals with different analytic requirements.
- The regression table shows estimates, not whether the assumptions behind them hold.
References
- Hosmer DW Jr, Lemeshow S, Sturdivant RX. Applied Logistic Regression. 3rd ed. Wiley; 2013. https://doi.org/10.1002/9781118548387
- Harrell FE Jr. Regression Modeling Strategies: With Applications to Linear Models, Logistic and Ordinal Regression, and Survival Analysis. 2nd ed. Springer; 2015. https://doi.org/10.1007/978-3-319-19425-7
- Dohoo I, Martin W, Stryhn H. Veterinary Epidemiologic Research. 2nd ed. VER Inc.; 2009. ISBN: 9780919013605.
- Hernán MA, Robins JM. Causal Inference: What If. Boca Raton: Chapman & Hall/CRC; 2020. https://www.hsph.harvard.edu/miguel-hernan/causal-inference-book/
- Hernán MA. The C-word: scientific euphemisms do not improve causal inference from observational data. Am J Public Health. 2018;108(5):616–619. https://doi.org/10.2105/AJPH.2018.304337
- Shmueli G. To explain or to predict? Stat Sci. 2010;25(3):289–310. https://doi.org/10.1214/10-STS330
- von Elm E, Altman DG, Egger M, et al. The Strengthening the Reporting of Observational Studies in Epidemiology (STROBE) statement: guidelines for reporting observational studies. Lancet. 2007;370(9596):1453–1457. https://doi.org/10.1016/S0140-6736(07)61602-X
- Sargeant JM, O'Connor AM, Dohoo IR, et al. Methods and processes of developing the Strengthening the Reporting of Observational Studies in Epidemiology–Veterinary (STROBE-Vet) statement. Prev Vet Med. 2016;134:188–196. https://doi.org/10.1016/j.prevetmed.2016.09.005