When to use logistic regression
Use logistic regression when the outcome has two values, such as passed or failed, or ill or healthy, and you want to know how one or more predictors change the odds of it. Linear regression is the wrong tool here: it can predict probabilities below 0 or above 1. See logistic regression explained.
Worked example
The default data are 30 students: hours studied, whether they work part-time, and whether they passed (16 did).
- The model as a whole is significant: χ²(2, N = 30) = 18.40, p < .001, Nagelkerke R² = .61. It classifies 83.3% of students correctly (75.0% of those who passed and 92.9% of those who failed).
- Hours studied: B = 0.88, so each extra hour multiplies the odds of passing by e0.88 = 2.41 (95% CI 1.27 to 4.56, p = .007), holding part-time work constant.
- Part-time work: OR = 0.16 (95% CI 0.01 to 2.42, p = .188). The point estimate suggests much lower odds, but with 30 students the interval is huge and includes 1, so the data cannot tell.
In probabilities: a student who studied 5 hours and does not work has a predicted chance of passing of 85%. With a part-time job, it is 49%.
Reading odds ratios
An odds ratio of 2.41 does not mean “2.41 times as likely”. It multiplies the odds, and odds and probabilities only agree when the outcome is rare. See relative risk vs odds ratio.
Things to check
- Enough events: a common guideline is at least 10 events (in the smaller outcome group) per predictor term. The calculator warns when you fall below it.
- Separation: if a predictor perfectly splits the outcomes, the estimates run off to infinity. The calculator detects this and stops.
- Linearity in the log-odds for numeric predictors, and independent observations.
Accuracy
Coefficients, standard errors, p-values, odds-ratio intervals, log-likelihoods, McFadden R² and AIC match Python’s statsmodels Logit on 40 random datasets. The data stay in your browser.
Frequently asked questions
What is the difference between B and the odds ratio?
B is the change in the log-odds for a one-unit increase in the predictor. The odds ratio is e to the power B: the factor by which the odds are multiplied.
Which R squared should I report?
Logistic regression has no true R squared. Nagelkerke's is the one most often reported (SPSS shows it); McFadden's is common in economics. State which you used.
How do I include a categorical predictor?
Put it in the data as text, for example yes/no or a group name. The calculator creates dummy variables and uses the first level alphabetically as the reference.
What does complete separation mean?
A predictor perfectly divides the outcomes, for example everyone who studied more than 6 hours passed. The odds ratio is then infinite. Remove the predictor, add data, or use Firth's penalized regression.