Logistic Regression Calculator

Run logistic regression in your browser with odds ratios, average marginal effects, separation detection with a Firth option, AUC, and calibration checks.

What this calculator does

Logistic Regression is Module 6 of Analysis Studio, and it is a free module. It models a binary outcome: converted or not, passed or failed, responded or not, readmitted or not. The event level is confirmed by you before fitting, so the direction of every coefficient is stated rather than assumed.

Reports include odds ratios with intervals, McFadden, Nagelkerke, and Tjur pseudo-R squared, a classification table, AUC with a DeLong interval, a Hosmer-Lemeshow test with a calibration plot, and average marginal effects with delta-method standard errors. Two professional touches matter in practice. Separation is detected before fitting by a linear-programming check, and when the data separate, the module recommends the Firth penalized fit automatically rather than returning runaway coefficients. Under a survey design, the module fits a design-based quasi-binomial model through the Studio variance engine, with the design-free diagnostics omitted and the omission noted.

Fitting is by iteratively reweighted least squares. Intervals are Wald by default, with profile-likelihood intervals available.

The method, in plain terms

The model works on the log odds of the event:

log(p ÷ (1 − p)) = intercept + b₁x₁ + b₂x₂ + …

A coefficient exponentiates into an odds ratio: the factor by which the odds of the event multiply for a one-unit increase in that predictor, with the other predictors held fixed. Odds ratios are the currency of logistic reporting, and they mislead readers who hear them as probability ratios, which is why the module also reports average marginal effects: the average change in the probability of the event for a one-unit change in the predictor, in percentage points, computed case by case and averaged.

Worked example

A small trial with one binary predictor. The control group sees six events in twenty cases. The treated group sees twelve events in twenty.

  • Log odds in control: log(6 ÷ 14) = −0.847
  • Log odds ratio: log((12 ÷ 8) ÷ (6 ÷ 14)) = 1.253, with standard error 0.668
  • Odds ratio: 3.500, so the odds of the event in the treated group are three and a half times the odds in control
  • z = 1.875, p = 0.061

The probabilities tell the companion story: the event rate moves from 30 percent in control to 60 percent in the treated group, a thirty-point difference in rates carried by an odds ratio of 3.5. Both statements are true, and they answer different questions. The module reports both scales so the reader picks the right one for the decision at hand.

When the calculator fits, and when it does not

It fits when:

  • The outcome is genuinely binary and the event is defined without ambiguity.
  • Predictors may be continuous, binary, or categorical, and the question is association or prediction rather than proof of cause.
  • Events are numerous enough to support the predictor count. A working floor is roughly ten events per predictor, and the module warns when the events run thin.

It does not fit when:

  • The outcome has three or more unordered categories. That is multinomial logistic regression, Module 14.
  • The outcome is ordered categories. That is the proportional-odds model, also Module 14.
  • The outcome is a count. That is Poisson or negative binomial regression, Module 14 again.
  • A predictor separates the outcome completely and the Firth fit is declined. Ordinary logistic coefficients under separation run toward infinity, and any number printed from such a fit is an artifact.

Run it

Module 6: Logistic RegressionOpen in Analysis Studio →

Load your data, confirm the event level, choose predictors, and read the separation check before the coefficients.

Questions

How do I read an odds ratio of 3.5? The odds of the event are three and a half times as high for a one-unit increase in the predictor, other predictors held fixed. In the worked example, treated cases show odds of 12 to 8, or 1.5, against control odds of 6 to 14, or 0.43, and 1.5 divided by 0.43 is 3.5. An odds ratio is not a probability ratio: the rates in the example are 60 percent and 30 percent, a ratio of two.

What are average marginal effects? The change in the probability of the event, in points, averaged over the actual cases in the data. Where the odds ratio is a multiplier on a scale few people think in, the marginal effect says the event becomes thirty points more likely, which is usually the sentence a report needs.

What is separation, and why does the module stop for it? Separation means a predictor, or a combination, predicts the outcome perfectly in the sample. The ordinary maximum-likelihood coefficient then has no finite value. The module detects it before fitting and recommends the Firth penalized fit, which returns finite, slightly shrunken estimates that behave properly.

Which pseudo-R squared should I report? Report the one your field expects, and never compare it with an ordinary R squared. McFadden values run low by design; Nagelkerke rescales toward the familiar range; Tjur is the difference in average predicted probabilities between events and nonevents, and is the most directly interpretable of the three. The module reports all three so the choice is yours, with the numbers side by side.

Does it work with survey weights? Yes. Under a declared design the module fits through the design-based sandwich, matching the standard survey-package approach, and omits the diagnostics that have no design-based form, with a note saying so.

More Analysis Studio Modules