Logistic Regression Calculator
Fit a binary logistic regression model from numeric data or calculate a predicted probability from known coefficients.
Calculator is for informational purposes only. Terms and Conditions
Fit mode estimates coefficients by maximum likelihood using Newton/IRLS; Prediction mode evaluates the logistic function from coefficients you already know.
Choose a calculation mode
Fit a model from data or calculate probability from an existing model equation.
Enter the known values
Results update automatically after valid input changes.
Result
Primary answer first, followed by model coefficients, classification metrics, warnings, and calculation details.
Model summary
Coefficient and Odds Ratio Table
| Variable | β | SE | z | p-value | Odds Ratio | Confidence Interval |
|---|
Confusion Matrix
Show calculation steps Review the model equation, likelihood fitting, odds ratios, probability calculation, and performance checks
- Enter valid values to see the complete calculation.
ROC Curve
True-positive rate versus false-positive rate across probability thresholds. The diagonal reference represents chance-level ranking.
ROC curve will appear after a valid model fit.
Method, Sources, and Assumptions
Statistical method, interpretation basis, limitations, and verification references.
Fit mode estimates an intercept and numeric predictor coefficients by Newton/IRLS maximum likelihood. Odds ratios are exp(β). Wald confidence intervals use the inverse observed information matrix. ROC/AUC is calculated from fitted probabilities.
- Outcome values must be coded 0 and 1 and both classes must be present.
- Predictor columns must be numeric; categorical predictors should be dummy-coded before pasting.
- Blank or non-numeric cells are not silently dropped; correct incomplete rows before fitting.
- Inference assumes independent observations and a correctly specified logit model.
- Complete or near-complete separation and severe multicollinearity can make coefficient estimates unstable.
- In-sample AUC and classification metrics can overstate performance; use external or cross-validation for predictive claims.
Calculator guide
What the Logistic Regression Calculator Tells You
The Logistic Regression Calculator fits a binary logistic regression model from a 0/1 outcome and one or more numeric predictors, or it calculates a predicted probability from coefficients you already know. In fit mode, the main results include fitted coefficients, standard errors, p-values, odds ratios, confidence intervals, likelihood-based model statistics, a ROC curve with AUC, and threshold-dependent classification metrics.
Logistic regression models the probability that an observation belongs to the positive class, such as failure rather than no failure. The linear predictor acts on the log-odds scale, and the logistic function converts that unbounded value into a probability between 0 and 1. A positive coefficient increases the modeled log-odds as its predictor increases; a negative coefficient decreases them, holding the other predictors constant.
- Best for
- Binary outcomes coded 0 and 1 with numeric predictor columns.
- Primary fit result
- Regression coefficients, odds ratios, inference, ROC AUC, and classification performance.
- Second mode
- Convert a known intercept and coefficients into log-odds, odds, and predicted probability.
How to Use the Logistic Regression Calculator
Choose the mode that matches what you know. Use Fit logistic regression from data when you have observed rows of outcomes and predictors. Use Predict probability from coefficients when the regression equation has already been fitted elsewhere.
-
Choose Fit mode for a dataset
Paste comma-separated or tab-separated data into the regression-data box. The first column is the binary outcome and must contain both 0 and 1. Every remaining column is treated as a numeric predictor. A header row is recommended because the calculator uses those labels in the output. The calculator accepts up to 10 numeric predictors, requires at least six observations, and also requires enough rows relative to the fitted coefficient count to run the model. These are software minimums, not recommendations for statistically adequate sample size.
-
Set the classification threshold
The default threshold is 0.50. A fitted probability at or above the selected cutoff is classified as 1; a lower probability is classified as 0. Changing this cutoff changes the confusion matrix, accuracy, sensitivity, specificity, precision, recall, and F1 score, but it does not refit the regression coefficients.
-
Use Advanced Options only when they answer a real question
Fit mode lets you change the confidence level and optionally standardize predictors. With standardization enabled, each numeric predictor is transformed to mean 0 and sample standard deviation 1 before fitting, so the reported predictor odds ratios are interpreted per one-standard-deviation increase rather than per one original-unit increase.
-
Use Prediction mode for an existing model
Enter the intercept and coefficient/predictor pairs. The calculator forms the linear predictor, converts it to odds, applies the logistic function, and returns the predicted probability. Optional coefficient/predictor pairs should either be completed as a pair or left blank. Prediction mode applies coefficients that were estimated elsewhere; it does not refit the model or calculate coefficient uncertainty.
Inputs and Outputs Explained
The most important input decision is defining the positive outcome correctly. In this calculator, the first data column is the response and 1 is the modeled positive class; all other columns are numeric predictors used to estimate that probability.
- Binary outcome
- The observed response coded 0 or 1. Both classes must be present in the pasted dataset.
- Predictors
- Numeric explanatory variables. The calculator supports up to 10 predictor columns. Nominal categorical predictors should normally be converted to indicator/dummy variables with a clearly defined reference category. Do not simply assign arbitrary values such as 1, 2, and 3 to unordered categories, because the model would treat those values as a quantitative predictor.
- Predictor units and coding
- Prediction mode must use the same units, scaling, and categorical coding used when the coefficients were estimated. A coefficient fitted per °C cannot be applied directly to a Fahrenheit value, and a coefficient fitted per dollar cannot be applied directly to a value expressed in thousands of dollars without a corresponding coefficient rescaling.
- Coefficient \(\beta_i\)
- The estimated change in log-odds associated with a one-unit increase in predictor \(X_i\), holding the other fitted predictors constant.
- Odds ratio \(e^{\beta_i}\)
- The multiplicative change in odds associated with a one-unit predictor increase, holding the other predictors constant. An odds ratio is not a percentage-point change in probability.
- p-value and confidence interval
- The calculator uses Wald inference for individual coefficients. The p-value tests the null hypothesis that the coefficient equals zero; the confidence interval shows uncertainty in the estimated coefficient or odds ratio.
- ROC AUC
- A threshold-independent summary of how well the fitted probabilities rank observed positives above observed negatives. The calculator’s fit-mode AUC is in-sample, so it should not be treated as out-of-sample validation.
- Pseudo-R², AIC, and BIC
- Likelihood-based model-summary statistics. They are useful for assessing or comparing fitted models, but pseudo-R² values do not have the same variance-explained interpretation as ordinary linear-regression \(R^2\).
- Confusion matrix
- Counts of true negatives, false positives, false negatives, and true positives after the selected probability threshold converts probabilities into predicted classes.
Logistic Regression Formula and Calculation Method
Binary logistic regression models a linear combination of predictors on the log-odds scale and converts that value to an event probability with the logistic function. The coefficients are estimated numerically by maximum likelihood rather than by ordinary least squares.
Logit form
Plain language: the model makes log-odds a linear function of the predictors.
Probability form
Plain language: first calculate the linear predictor, then pass it through the logistic function to obtain a probability between 0 and 1.
Coefficient to odds ratio
Exponentiating a predictor coefficient converts its additive effect on log-odds into a multiplicative effect on odds.
These relationships are standard binary logistic regression relationships. Stanford’s STATS 202 notes describe the same probability/log-odds model and maximum-likelihood fitting with numerical methods such as Newton’s algorithm.
- \(p\)
- Positive-class probability The modeled probability that the outcome equals 1 for the specified predictor values.
- \(\beta_0\)
- Intercept The fitted log-odds when all predictors equal zero. It may have little practical interpretation when zero is outside the realistic range of one or more predictors.
- \(\beta_i\)
- Predictor coefficient The change in fitted log-odds per one-unit increase in predictor \(X_i\), with the other model predictors held constant.
- \(X_i\)
- Predictor value A numeric explanatory-variable value supplied in the dataset or Prediction mode.
- \(OR_i\)
- Odds ratio The factor by which the odds are multiplied for a one-unit increase in \(X_i\), holding other predictors constant.
Worked Logistic Regression Example
The calculator’s default example contains 40 illustrative equipment observations. Failure is the binary outcome, while temperature and operating hours are the two numeric predictors. The values below reproduce that exact default fit with predictor standardization turned off, a 95% confidence level, and a 0.50 classification threshold.
Fit the model by maximum likelihood
- Build the design matrix from an intercept plus the Temperature_C and Operating_Hours columns.
- Estimate the coefficients numerically by Newton/IRLS maximum likelihood until the coefficient update converges.
- Use the inverse observed information matrix to obtain coefficient standard errors, then compute Wald z statistics, p-values, and 95% confidence intervals.
- Exponentiate each predictor coefficient to obtain its odds ratio.
- Calculate fitted probabilities for all 40 observations, generate the ROC curve and AUC, then apply the 0.50 threshold to form the confusion matrix.
| Term | Coefficient β | SE | p-value | Odds ratio | 95% OR CI |
|---|---|---|---|---|---|
| Intercept | −7.91052 | 2.78885 | 0.0046 | 0.00037 | 0.000002 to 0.08677 |
| Temperature_C | 0.07437 | 0.03157 | 0.0185 | 1.07721 | 1.01258 to 1.14595 |
| Operating_Hours | 0.001128 | 0.000500 | 0.0241 | 1.001128 | 1.000148 to 1.002110 |
Result
ROC AUC = 0.8157
The fitted example has likelihood-ratio \(\chi^2(2)=12.5138\) with \(p=0.0019\), McFadden pseudo-\(R^2=0.2273\), AIC = 48.537, and BIC = 53.604. At the 0.50 classification threshold, the confusion matrix is TN = 18, FP = 4, FN = 7, TP = 11, giving 72.5% accuracy, 61.1% sensitivity, 81.8% specificity, 73.3% precision, and an F1 score of 66.7%.
How to Interpret Logistic Regression Results
Read logistic-regression output in layers: first understand the sign and scale of each coefficient, then the uncertainty around it, then model-level discrimination and fit, and finally the threshold-dependent classification results. No single statistic answers every question about model quality.
Coefficient and odds ratio
In the worked example, the temperature coefficient is 0.07437, so a 1°C increase multiplies the fitted odds of failure by about 1.077, holding operating hours constant. That is approximately a 7.7% increase in odds, not a 7.7 percentage-point increase in probability.
Controlled sensitivity
Because odds ratios multiply across equal increments, a 10°C increase in the example multiplies the fitted odds by \(e^{10(0.074371)}\approx2.10\), holding operating hours constant. A 1,000-hour increase multiplies the fitted odds by \(e^{1000(0.001128)}\approx3.09\), holding temperature constant.
Fast sanity check
Check whether coefficient signs, odds ratios, and confidence intervals agree. A positive coefficient must have an odds ratio above 1; a negative coefficient must have an odds ratio below 1. If an odds-ratio confidence interval includes 1, the corresponding coefficient confidence interval includes 0.
Do not interpret an odds ratio as a probability ratio
Probability, odds, and odds ratios are different quantities. UCLA’s statistical guidance illustrates the sequence from probability to odds to log-odds and explains why logistic-regression coefficients are naturally interpreted through exponentiated odds ratios. The same odds ratio can correspond to very different absolute probability changes depending on the starting probability and the values of other predictors.
What the p-value means
The coefficient p-value in this calculator is a Wald-test p-value for the null hypothesis \(\beta_i=0\). A small p-value is evidence against that null within the fitted model assumptions; it is not a measure of practical importance and does not prove causation. The coefficient estimate, confidence interval, subject-matter context, and sample design still matter.
What ROC AUC means
The ROC curve compares true-positive rate with false-positive rate as the classification threshold changes. AUC summarizes how well the fitted scores rank positives above negatives across thresholds. The calculator’s AUC is calculated on the same observations used to fit the model, so it can look better than performance on new data.
Why the classification threshold matters
The threshold converts a probability into a class label. Lowering the threshold generally classifies more cases as positive, which tends to increase sensitivity while also increasing false positives. Raising it tends to do the opposite. The best threshold depends on the relative cost of false positives and false negatives; 0.50 is a common default, not a universal optimum.
How to read AIC and BIC
AIC and BIC are primarily comparative measures. A value such as AIC = 48.5 is not inherently “good” or “bad” by itself. When comparing candidate models fitted to the same response and dataset, lower AIC or BIC indicates a better tradeoff between fit and model complexity under that criterion.
Why the pseudo-R² values differ
McFadden, Cox-Snell, and Nagelkerke pseudo-\(R^2\) use different likelihood-based definitions, so they should not be expected to have the same value. None should be interpreted as the percentage of outcome variance explained in the same way as ordinary least-squares \(R^2\).
Accuracy can hide class imbalance
Overall accuracy can look strong when one class is much more common than the other. Always inspect the confusion matrix and class-specific measures such as sensitivity, specificity, precision, and recall instead of judging a classifier from accuracy alone.
Discrimination is not calibration
ROC AUC measures discrimination: whether higher-risk observations tend to receive higher fitted scores. Calibration asks whether predicted probabilities agree with observed frequencies—for example, whether cases assigned probabilities near 70% experience the event about 70% of the time in an appropriate validation sample. The current calculator reports ROC/AUC but does not calculate a calibration curve or calibration statistic.
How to Report Logistic Regression Results
A useful report should distinguish individual predictor effects from overall model fit and should describe associations rather than implying causation unless the study design supports a causal interpretation.
Report the predictor effect
For the calculator’s illustrative equipment-failure model: “Temperature was positively associated with failure after controlling for operating hours, \(\beta=0.0744\), SE = 0.0316, \(z=2.36\), \(p=0.0185\), OR = 1.077, 95% CI [1.013, 1.146].” This states the coefficient, uncertainty, test result, and odds-ratio interpretation on the same scale.
Report overall model evidence separately
The same example can be summarized at the model level as: “The two-predictor model improved fit relative to the intercept-only model, likelihood-ratio \(\chi^2(2)=12.51\), \(p=0.0019\).” An individual Wald test and the overall likelihood-ratio test answer different questions and should not be treated as interchangeable.
State the predictor increment
Odds ratios are tied to the predictor scale. For temperature, OR = 1.077 is per 1°C. For operating hours, the one-hour OR is close to 1 because one hour is a small increment; over 1,000 hours the fitted odds multiplier is \(e^{1000(0.001128)}\approx3.09\), holding temperature constant.
Separate fit from validation
If you report AUC or classification metrics from the fitting dataset, label them as in-sample results. Do not describe them as validated predictive performance unless an independent validation or appropriate resampling procedure was actually performed.
Probability, Odds, and Log-Odds Reference
Logistic regression is easier to interpret once the three scales are separated. Probability is bounded between 0 and 1, odds are \(p/(1-p)\), and log-odds are the natural logarithm of the odds.
| Probability p | Odds p/(1−p) | Log-odds ln[p/(1−p)] |
|---|---|---|
| 0.10 | 0.1111 | −2.1972 |
| 0.25 | 0.3333 | −1.0986 |
| 0.50 | 1.0000 | 0.0000 |
| 0.75 | 3.0000 | 1.0986 |
| 0.90 | 9.0000 | 2.1972 |
These conversions follow directly from \(\text{odds}=p/(1-p)\) and \(\text{log-odds}=\ln(\text{odds})\). See UCLA OARC’s odds-ratio interpretation guide for an authoritative walkthrough of probability, odds, log-odds, coefficients, and odds ratios.
Common Logistic Regression Mistakes and Failure Modes
Most serious interpretation errors come from confusing odds with probability, treating training performance as validation, or trusting unstable coefficients when the data cannot support the fitted model.
Treating odds change as probability change
An odds ratio of 1.50 means the odds are multiplied by 1.50 for the specified predictor increment. It does not mean the predicted probability rises by 50% or by 50 percentage points.
Using 0.50 as an automatic decision threshold
A 0.50 cutoff is only a decision rule. Change the threshold when the costs of false positives and false negatives justify a different tradeoff, and evaluate the resulting sensitivity, specificity, precision, recall, and other relevant metrics.
Reading pseudo-R² as ordinary R²
McFadden, Cox-Snell, and Nagelkerke statistics are likelihood-based summaries. Do not translate a pseudo-R² of 0.23 into “23% of the variance explained” as if it were ordinary least-squares \(R^2\).
Ignoring complete or quasi-complete separation
If predictors perfectly or nearly perfectly distinguish the classes, complete or quasi-complete separation can occur and ordinary maximum-likelihood coefficient estimates can become extremely large or unstable. UCLA OARC describes complete separation as a case in which an outcome is completely separated by predictor values and finite maximum-likelihood estimates may fail to behave normally.
Ignoring multicollinearity
Highly redundant predictors can make individual coefficient estimates unstable even when overall prediction remains reasonable. Stanford’s logistic-regression notes specifically warn that collinearity can destabilize coefficients and affect convergence.
Calling in-sample AUC “validated” performance
The calculator’s ROC and classification metrics use the fitted dataset. That is useful for describing the fitted sample, but predictive claims require an appropriate validation procedure on data not used to estimate the same coefficients.
Logistic Regression vs. Linear Regression
Use logistic regression when the modeled outcome is binary and the goal is an event probability. Ordinary linear regression is designed for a continuous numeric outcome and does not constrain predictions to the 0-to-1 probability range.
Logistic regression
Models a binary response through log-odds and the logistic function. Coefficients are usually estimated by maximum likelihood, and effects are often communicated as odds ratios.
Linear regression
Models a continuous response directly as a linear combination of predictors, commonly with least squares. Coefficients represent changes in the response’s own units rather than changes in log-odds.
Assumptions, Limits, and Model Checks
Binary logistic regression does not require predictor variables to be normally distributed, but it does rely on a correctly specified binary-outcome model, an appropriate dependence structure, usable information in the data, and stable estimation.
Binary outcome and correct event coding
The response must represent two classes. This calculator expects 0 and 1 and treats 1 as the positive event. Reversing the event definition reverses the interpretation of the fitted probability and coefficient directions.
Independent observations for the ordinary model
Rows should represent observations that can reasonably be treated as independent for the fitted model. Repeated measurements, matched data, or clustered observations may require a model that accounts for within-group dependence.
Appropriate linearity on the logit scale
A continuous predictor does not need to have a linear relationship with raw probability. The standard model assumes its specified effect is linear on the log-odds scale unless nonlinear terms, transformations, splines, or interactions are deliberately added.
No destructive multicollinearity
Strongly redundant predictors can inflate uncertainty and make coefficient estimates sensitive to small data changes. Inspect the predictor structure rather than judging stability only from whether the algorithm converged.
No complete or near-complete separation
If a predictor or combination of predictors almost perfectly divides the two classes, standard maximum-likelihood coefficients can diverge or become unreliable. A convergence warning or extreme coefficient magnitude is a reason to investigate the data rather than simply report the number.
Adequate sample information
The familiar “10 events per variable” idea is a historical rule of thumb, not a universal guarantee. Adequacy depends on the number of fitted parameters, event fraction, total sample size, predictor distributions and correlation, expected effect sizes, separation risk, and whether the purpose is inference or prediction. The calculator’s software minimum is therefore not evidence that a dataset is large enough for reliable statistical conclusions.
Sources and Calculation Verification
The calculator implements standard binary logistic-regression relationships and numerical maximum-likelihood fitting. The worked example was independently recomputed, while the interpretation and limitation guidance below is grounded in authoritative statistical references.
- Stanford STATS 202 — Logistic Regression — supports the logistic probability/log-odds formulation, likelihood fitting, Newton-type numerical estimation, coefficient standard errors, Wald tests, likelihood-ratio testing, and cautions about collinearity and separation.
- UCLA OARC — Interpreting Odds Ratios in Logistic Regression — supports the probability-to-odds-to-log-odds relationship and odds-ratio interpretation.
- UCLA OARC — Complete and Quasi-Complete Separation — supports the discussion of perfect prediction/separation and unstable ordinary maximum-likelihood estimates.
- scikit-learn — ROC Curve Reference — supports ROC construction from binary labels and continuous prediction scores across classification thresholds.
- scikit-learn — Confusion Matrix Reference — supports the binary true-negative, false-positive, false-negative, and true-positive count convention used when evaluating thresholded predictions.
- van Smeden et al. — Sample Size for Binary Logistic Prediction Models — supports treating events-per-variable cutoffs as incomplete sample-size criteria rather than universal adequacy rules.
How the worked calculation was checked: the calculator’s 40-row default dataset was refit independently as an unregularized binary logistic model with an intercept, and the coefficient, standard-error, likelihood, information-criterion, ROC AUC, and threshold-classification results were compared numerically.
Logistic Regression Calculator FAQ
These questions address common points that are easy to misread after running a binary logistic regression.
What does a logistic regression coefficient mean?
A coefficient is the change in fitted log-odds for a one-unit increase in that predictor, with the other fitted predictors held constant. Exponentiating it gives the corresponding odds ratio.
What does an odds ratio greater than 1 mean?
It means the fitted odds of the positive outcome increase as the predictor rises by the stated unit increment, holding the other predictors constant. For example, an odds ratio of 1.20 corresponds to 20% higher odds per unit—not a 20-percentage-point increase in probability.
Does logistic regression require normally distributed predictors?
No. Ordinary binary logistic regression does not require numeric predictors to be normally distributed. More important concerns include model specification, dependence among observations, linearity of continuous effects on the logit scale as modeled, multicollinearity, sparse data, and separation.
Is 0.50 always the best classification threshold?
No. A 0.50 threshold is a convenient default, but the useful cutoff depends on the consequences of false positives and false negatives, class prevalence, and the purpose of the model. Change the threshold and inspect the resulting classification metrics rather than assuming 0.50 is optimal.
What is a good ROC AUC?
There is no universal AUC cutoff that makes a model “good.” An AUC of 0.5 corresponds to chance-level ranking in a binary setting, and higher values indicate stronger discrimination, but acceptability depends on the application, validation method, competing models, and consequences of errors.
Why can logistic regression fail to converge?
Common causes include complete or near-complete class separation, severe multicollinearity, too many coefficients for the information in the dataset, and numerical instability. Treat non-convergence as a model/data diagnostic, not as a reason to report the last coefficient values as if they were valid estimates.
Can this calculator fit categorical predictors?
The fit-mode dataset parser expects numeric predictor columns. Nominal categorical predictors should normally be converted into one or more indicator/dummy variables with a clearly defined reference category. Do not assign arbitrary numeric scores to unordered categories unless that quantitative ordering is genuinely part of the intended model.
How many observations do I need for logistic regression?
There is no universal minimum that guarantees a reliable model. The calculator enforces software-level minimum row requirements, but statistical adequacy depends on event frequency, the number of fitted parameters, predictor structure, expected effects, separation, and the purpose of the model. Historical events-per-variable rules can be useful warnings, but they should not be treated as universal design criteria.
Do predictor units matter in logistic regression?
Yes. The coefficient is tied to the units and scaling used when the model was fitted. A coefficient per °C must be paired with temperature in °C in Prediction mode unless the coefficient is transformed consistently. The same principle applies to dollars versus thousands of dollars, hours versus thousands of hours, and standardized versus unstandardized predictors.