Calculators King

Regression and Correlation

Logistic Regression Calculator

Binary pairs are fitted with an intercept and a slope by Newton iteration, then a few predicted probabilities and the half-cut matches are counted.

Worksheet

Press Calculate to see the result.

Binary pairs are fitted with an intercept and a slope by Newton iteration, then a few predicted probabilities and the half-cut matches are counted.

What this calculator answers

Logistic regression keeps predictions between 0 and 1 by modelling the log odds as a straight line in x. A Newton, or iteratively reweighted, update fits the intercept and the slope from the binary outcomes. Each row must be coded 0 or 1, and both codes have to appear, because a column that is all successes or all failures does not identify a finite slope. After the fit, the page turns a few x values into probabilities and counts how many of those probabilities, rounded at one half, match the typed class. The page needs at least six rows.

The page reports the intercept, the log-odds slope, several predicted probabilities, and the count of predictions that match y at a 0.5 cut. Supporting counts and intermediate terms sit under the headline so a reader can see what was divided by what. When a checkbox or a tail setting changes the divisor or the rejection region, that choice appears in the steps rather than vanishing into a silent default.

The formula, written out

Simple logistic regression uses this relationship.

log odds = b0 + b1 x, probability = 1 / (1 + e^(-(b0 + b1 x)))

  • b0. Intercept on the log-odds scale.
  • b1. Change in log odds per unit of x.
  • probability. The fitted chance that y equals 1.
  • 0.5 cut. Predict class 1 when the probability is at least one half.

The Newton steps use the gradient and the Hessian of the Bernoulli log likelihood for an intercept and one slope. Iteration stops when the coefficients settle or after a fixed number of updates. The algebra is the named textbook identity for this worksheet. Intermediate products and quotients appear in order so a calculator and a pencil can agree to the displayed rounding. If a neighbouring page uses a different divisor or a continuity correction, that page says so on its own ticket.

A full worked example

Example loaded in the worksheet

The form is prefilled with a small example so every arithmetic step can be checked by hand. Change one field after you finish the walkthrough and confirm the ticket moves the way the formula predicts.

There are 8 rows, with 4 zeros and 4 ones. Both classes are present. Newton updates fit an intercept and one slope on the log-odds scale, starting from zeros. The updates stopped after 8 iterations.

The intercept is −6.9573 and the slope is 2.5259. A one-unit rise in x multiplies the fitted odds by 12.5025. Predicted probabilities include at x = 1 the probability is 0.0118; at x = 1.5 the probability is 0.0404; at x = 2 the probability is 0.1295.

Rounding each probability at 0.5 matches the typed y on 6 of 8 rows. That match count uses the same rows that were fitted. It is not a score on new rows.

Figures from the worked example
Log-odds slope2.5259
Intercept−6.9573
Matches at 0.56 of 8
Class counts4 zeros, 4 ones

A second situation

The outcome at x = 3 is flipped from 0 to 1

There are 8 rows, with 3 zeros and 5 ones. Both classes are present. Newton updates fit an intercept and one slope on the log-odds scale, starting from zeros. The updates stopped after 20 iterations.

The intercept is −142.1519 and the slope is 63.1521. A one-unit rise in x multiplies the fitted odds by 2.6706e+27. Predicted probabilities include at x = 1 the probability is 4.9069e−35; at x = 1.5 the probability is 2.5358e−21; at x = 2 the probability is 1.3105e−7.

Rounding each probability at 0.5 matches the typed y on 8 of 8 rows. That match count uses the same rows that were fitted. It is not a score on new rows.

Figures from the worked example
Log-odds slope63.1521
Intercept−142.1519
Matches at 0.58 of 8
Class counts3 zeros, 5 ones

Flipping a single class changes the likelihood, so both the intercept and the slope are refit. The match count can rise or fall by that one row. The second example changes the feature that this formula is sensitive to, and the ticket shows the new figure beside the same definition. That contrast is the fastest way to see which input owns the movement.

What moves when the input moves

The last x moved from 5 to 6 while its outcome stayed 1. The headline result went from 2.5259 to 2.5044.

The nudged inputs

There are 8 rows, with 4 zeros and 4 ones. Both classes are present. Newton updates fit an intercept and one slope on the log-odds scale, starting from zeros. The updates stopped after 8 iterations.

The intercept is −6.9026 and the slope is 2.5044. A one-unit rise in x multiplies the fitted odds by 12.2361. Predicted probabilities include at x = 1 the probability is 0.0122; at x = 1.5 the probability is 0.0412; at x = 2 the probability is 0.1308.

Rounding each probability at 0.5 matches the typed y on 6 of 8 rows. That match count uses the same rows that were fitted. It is not a score on new rows.

Figures from the worked example
Log-odds slope2.5044
Intercept−6.9026
Matches at 0.56 of 8
Class counts4 zeros, 4 ones

How to read the result

Read the slope on the log-odds scale. A positive slope means higher x goes with a higher fitted probability of class 1. The match count is a training-set tally, not a validated accuracy. Say the unit, the sample size or contract terms, and the formula name in the same sentence as the figure. A number without those three pieces invites a later reader to invent a definition that this page never used.

Write the result with its unit, the inputs that produced it, and the name of the formula. Write the result with its unit, the inputs that produced it, and the name of the formula. If the ticket shows a decision sentence, quote the alpha and the tail with it. If the ticket shows a money or dose figure, quote the rate and the schedule that produced it.

Assumptions that have to stay true

  • Every y is exactly 0 or exactly 1.
  • Both classes appear at least once.
  • At least six rows are typed.
  • You want a single slope plus an intercept, not extra predictors.

If an assumption above is false, do not average the discomfort away. Change the worksheet or change the question. A correct arithmetic step on the wrong model is still the wrong answer for the decision you are trying to make.

Mistakes that change the answer

  • Coding yes and no as 1 and 2. The failure class has to be 0.
  • Dropping the class that never occurred and still expecting a finite slope.
  • Treating the 0.5-cut match count as performance on new rows.
  • Reading the slope as a probability. It is a change in log odds.

Where a different calculator is the honest choice

Use the linear regression calculator when the response is a measurement rather than a class. Use the correlation coefficient calculator for a unit-free linear association of two measurements. Use multiple linear regression when the response is numeric and there are two predictors. Related links under the essay open pages that keep their own formulas instead of hiding a mode switch inside this ticket.

When the job changes, move to a page built for that job: Linear Regression Calculator, Correlation Coefficient Calculator, Multiple Linear Regression Calculator.

Check yourself

The fitted probability at a row is 0.70 and the typed y is 1. Does the 0.5 cut match?

0.70 rounds to class 1 at the one-half cut, and the typed y is 1, so that row matches.

Using the result in a sentence

Pass or fail against a score, a yes or no purchase against a price, and a lab call of detected or not detected are the binary tables this page fits. Keep the count, the unit, and the assumption list beside any copy of the number that leaves this browser tab.

Complete separation can push the slope toward a very large number. The match count reuses the same rows that were fitted, so it is a description of this table, not a promise about the next row. Pair the headline with the steps before you staff a route, set a grade boundary, or compare two contracts from a single number.

Questions people ask next

01What definition does the Logistic Regression Calculator commit to?

This page uses Simple logistic regression: log odds = b0 + b1 x, probability = 1 / (1 + e^(-(b0 + b1 x))). The Newton steps use the gradient and the Hessian of the Bernoulli log likelihood for an intercept and one slope. Iteration stops when the coefficients settle or after a fixed number of updates. If a textbook uses a different divisor, a different continuity correction, or a different rounding rule, the last digits can move, so the definition is printed above the result. The worksheet asks for Rows as x y, with y equal to 0 or 1, and it refuses a blank that the formula cannot interpret. Keep that printed definition in the sentence you write next to the figure so a later reader can rebuild the arithmetic without guessing which convention you chose.

02How should the worked example be read out loud?

In the loaded example the log-odds slope is 2.5259. Read the slope on the log-odds scale. A positive slope means higher x goes with a higher fitted probability of class 1. The match count is a training-set tally, not a validated accuracy. Say the unit and the count before you say whether the number is large or small. Read the steps in order rather than jumping to the headline, because the intermediate terms are where a swapped percent and proportion usually hide. If the ticket shows both a primary figure and a comparison figure, name which one you are quoting.

03What is the fastest way to get a misleading result?

Coding yes and no as 1 and 2. The failure class has to be 0. Complete separation can push the slope toward a very large number. The match count reuses the same rows that were fitted, so it is a description of this table, not a promise about the next row. A second common failure is leaving a checkbox or tail setting in the wrong state and then treating the number as if the default had matched your plan. Reset the example, change one input, and confirm the ticket moves in the direction the formula predicts before you trust a live run.

04When should I leave this page for a different calculator?

Use the linear regression calculator when the response is a measurement rather than a class. Use the correlation coefficient calculator for a unit-free linear association of two measurements. Use multiple linear regression when the response is numeric and there are two predictors. The related links under the essay go to those worksheets, which keep their own formulas instead of hiding them in a mode switch. If the question changed from a summary to a test, from a payment to a refinance, or from a raw score to a percentile, switch pages rather than forcing this ticket to answer a job it was not built for.

05What belongs in the sentence next to the number?

0.70 rounds to class 1 at the one-half cut, and the typed y is 1, so that row matches. Name the formula, the sample size or the inputs, and the unit before you compare the figure with someone else's. A bare number without those three pieces cannot be audited when a score, a rate, or a lab value is challenged later. Store the inputs beside the result whenever the figure will travel into a report.