statcompute

Regression & correlation

Logistic Regression Calculator

Model a yes/no outcome from one or more predictors, and read the result as odds ratios.

Updated August 2026Runs in your browser — nothing is uploadedVerified against R
The outcome column must contain only 0 and 1. A header row names the coefficients.

The calculation runs in your browser, so this box needs JavaScript. The formula, the worked example and the interpretation below do not.

01

How to read this result

Coefficients are on the log-odds scale, which nobody thinks in. Exponentiate one and you get an odds ratio: the multiplier on the odds of the outcome for a one-unit rise in that predictor, holding the others fixed. An odds ratio of 4.5 means the odds multiply by 4.5 per unit.

An odds ratio is not a risk ratio. When the outcome is common the two diverge sharply, and reporting one as the other overstates the effect. See relative risk for the difference.

The likelihood-ratio test replaces F. It compares the fitted model against an intercept-only model and is reported as a chi-square. Individual predictors get z tests (Wald tests) in the coefficient table.

Pseudo-R² is not R². McFadden's version compares log-likelihoods rather than variances, and its scale is different: values of 0.2 to 0.4 indicate an excellent fit by McFadden's own account. Judging it against the 0.7 you might expect from a linear model will mislead you.

Perfect separation breaks the model, not the software. If a predictor separates the outcomes completely, the maximum-likelihood estimate is infinite. The calculator says so rather than returning a very large number and pretending it converged.

02

The formula

ln(p1p)=b0+b1x1++bkxk
p
the probability of the outcome
p/(1p)
the odds
bj
the change in log-odds per unit of xⱼ

Rearranged, p = 1/(1 + e^−η), the logistic function — which is what keeps every prediction strictly between 0 and 1.

Odds ratio

ORj=ebj

Fitted by iteratively reweighted least squares (Fisher scoring), the same algorithm R's glm uses.

03

Worked example

Hours of study against passing an exam

Twenty students, their hours of study, and whether they passed. This is the standard teaching example for logistic regression, and it shows why linear regression will not do: a straight line would predict probabilities above 1 for the hardest workers.

Hours: 0.5, 0.75, 1, 1.25, 1.5, 1.75, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 4, 4.25, 4.5, 4.75, 5, 5.5 — with pass = 0 for the first six, then a mix, then 1 for the last six.

  1. Start from coefficients of zero and iterate the weighted least-squares update.
    Fisher scoring converges in about five iterations
  2. The fitted coefficients, on the log-odds scale.
    b₀ = −4.078, b₁ = 1.505
  3. Exponentiate the slope to read it as an odds ratio.
    e^1.505 = 4.50
  4. So each extra hour multiplies the odds of passing by about 4.5.
    z = 2.39, p = 0.0167
  5. Compare the fitted model against an intercept-only one.
    deviance 27.73 → 16.06, χ² = 11.67 on 1 df, p = 0.00064
intercept −4.078slope (log-odds) 1.505odds ratio per hour 4.50p (slope) 0.0167AIC 20.06

The model puts the 50% point at 4.078/1.505 = 2.71 hours. Below that, passing is less likely than not; above it, more — which is a far more useful summary than the coefficient itself.

Checked against R's glm(pass ~ hours, family = binomial).

The calculator above is loaded with these numbers by the Load the worked example button.

04

Assumptions, and when to use something else

  • A binary outcome, coded 0 and 1.
  • Independent observations.
  • Linearity in the log-odds — the relationship between each predictor and the log-odds is a straight line, not the relationship with the probability, which is S-shaped by construction.
  • Enough events. The usual rule of thumb is at least 10 events (and 10 non-events) per predictor. With fewer, the coefficients are badly biased.
  • No perfect separation. If a predictor perfectly divides the outcomes, the estimate is infinite and the fit will not converge — which the calculator reports explicitly.
  • The outcome is a measurementLinear regressionA continuous outcome does not need the logistic link.
  • You have one binary predictor and one binary outcomeOdds ratio calculatorA 2×2 table gives the same odds ratio without fitting a model.
  • You want risk rather than oddsRelative riskWhen the outcome is common, the odds ratio overstates the risk ratio.
  • You want to test association in a tableChi-square testFor categorical predictors, a contingency table may be all you need.
05

Questions people ask

Why not just use linear regression on a 0/1 outcome?

Because it predicts probabilities below 0 and above 1, its residuals cannot be normal or constant-variance, and its standard errors are therefore wrong. The logistic link fixes all three by modelling the log-odds instead.

How do I interpret an odds ratio of 4.5?

Each one-unit increase in the predictor multiplies the odds of the outcome by 4.5, holding the other predictors fixed. Note that this is odds, not probability: going from odds of 1:1 (50%) to 4.5:1 is a move to 82%, while going from 1:100 to 4.5:100 is a move from 1% to 4.3%.

What is McFadden's pseudo-R²?

One minus the ratio of the fitted model's log-likelihood to the null model's. It is not comparable to a linear model's R²: McFadden considered values of 0.2 to 0.4 to represent excellent fit.

What is perfect separation?

A predictor that divides the outcome exactly — everyone above a threshold passed, everyone below failed. The maximum-likelihood estimate is then infinite and the fit cannot converge. The remedies are penalised (Firth) logistic regression, or combining categories.