Skip to content

Home / DOE / Analyze / Binary Logistic Regression / Binary Logistic Regression How-To

Binary Logistic Regression How-To

This walkthrough runs this engine on an output with two outcomes and reads its report. You never select the engine. Run Regression chooses it because the output's declared type has exactly two outcomes, so the walkthrough is about setting that type and reading what comes back.

The data

The same three factors as every other DOE walkthrough, Temp in degrees C, Press in psi and Time in seconds, but the response is not a measurement. Bond is either Pass or Fail.

Eight settings run four times each, thirty-two runs. A two-outcome response needs more runs than a measured one, because each run carries far less information than a number does.

Press Copy for Excel, then paste the table into a blank worksheet.

Temp Press Time Bond
180 40 10 Fail
220 40 10 Fail
180 60 10 Fail
220 60 10 Pass
180 40 20 Pass
220 40 20 Fail
180 60 20 Fail
220 60 20 Pass
180 40 10 Fail
220 40 10 Pass
180 60 10 Fail
220 60 10 Fail
180 40 20 Fail
220 40 20 Pass
180 60 20 Fail
220 60 20 Pass
180 40 10 Fail
220 40 10 Pass
180 60 10 Pass
220 60 10 Fail
180 40 20 Fail
220 40 20 Pass
180 60 20 Pass
220 60 20 Pass
180 40 10 Fail
220 40 10 Fail
180 60 10 Fail
220 60 10 Pass
180 40 20 Fail
220 40 20 Pass
180 60 20 Pass
220 60 20 Pass

Fifteen of the thirty-two passed. Every setting of every factor produced at least one Pass and at least one Fail, and that matters more here than it would for a measured response: an outcome that never appears at one setting of a factor has no finite coefficient, and the fit walks off instead of converging.

Steps

  1. Put the data in Excel

    Press Copy for Excel above the table, click cell A1 in a blank worksheet, and press Ctrl+V. The header row lands in row 1 and the 32 runs in rows 2 through 33.

  2. Make a design sheet to hold it

    QXL DOE New > Create Design > Special > Create Custom Design. Set the number of factors to 3 and the number of runs to 32, then set the number of outputs to 1.

  3. Set the output's type to Binary

    Name the output Bond and set Type: to Binary. That is the whole of what picks this engine: Quantitative, Binary and Nominal are the three the list offers, and the choice decides which regression runs later.

  4. Name the event on the design sheet

    The sheet the builder writes carries a cell labelled Event under the output's name, with enter event value (optional) --> beside it. Type Pass into the cell to the right of Event.

    That is what makes Pass the outcome the report is about. The cell says optional and it is, but leave it blank and the engine chooses, and the coefficients then describe the other outcome with every sign reversed.

  5. Fill in the design sheet

    Copy the four columns into the three factor columns and the one output column, and name the factors Temp, Press and Time. The response column is the one marked enter response data here -->.

  6. Answer the two questions a custom design asks

    Leave Type: at Quantitative for all three FACTORS, which is a different list from the output's. On the interaction page add nothing: this walkthrough fits the three main effects only.

  7. Run the regression

    QXL DOE New > Analyze Design > Run Regression. No dialog: the type on the sheet decides that this engine runs.

Confirm the engine that ran

The report names it, and there is a convergence line above the coefficient table. On a fit that converged the line says so and names the iteration count. If the line is a red warning instead, stop reading the rest of the sheet: the coefficients shown are from the last iteration rather than from a converged fit, and every statistic below them is unreliable.

If it names a different engine than you expected, the output's declared type is not what you thought, and that is the thing to fix rather than anything about the fit.

The coefficient table

Term Coeff SE Z P Odds ratio 95% bounds
Const -0.1874 0.4350 -0.431 0.6666 0.8291 0.3535 to 1.9447
Temp (A) 1.1715 0.4783 2.449 0.0143 3.2268 1.2637 to 8.2399
Press (B) 0.5516 0.4458 1.237 0.2159 1.7361 0.7246 to 4.1592
Time (C) 0.8988 0.4718 1.905 0.0567 2.4568 0.9745 to 6.1934

The column is Z and not T, because a logistic coefficient is compared against the normal distribution rather than against a t distribution.

A coefficient here is a change in log odds, not a change in a probability. That is why the odds ratio column exists: it is the coefficient exponentiated, so Temp's 1.1715 becomes 3.2268. Read it as multiplication. Moving Temp one coded unit, which is 20 degrees, or half its experimental range, multiplies the odds of a Pass by about 3.2.

Check one column against the other. Every odds ratio is exactly its coefficient exponentiated, and each bound is the matching bound of the coefficient exponentiated, so nothing in those three columns is independent information.

An odds ratio of 1 means no effect, because multiplying odds by 1 leaves them unchanged. So an interval that contains 1 is the same statement as a p value above 0.05, and here Press and Time both have one: 0.7246 to 4.1592, and 0.9745 to 6.1934. Time's interval only just contains it, at p = 0.0567.

The model fit statistics

Statistic Value How to read it
LogLikelihood -16.0938 always negative, no absolute meaning. It exists to be compared
RSquaredU 0.2724 McFadden's pseudo R squared. Not a proportion of variation explained, and not comparable with a least squares R squared
AIC 40.1876 lower is better, and only against another model on the same data
BIC 46.0505 the same, charging more per term
RMSE 0.4139 the typical distance between an outcome and its predicted probability

None of the five means anything on its own, which is what the two tests below are for.

Testing the model as a whole

G is to a logistic fit what F is to a least squares one. It is twice the gap between the fitted model's log likelihood and that of a model holding only a constant:

Value
Log likelihood, constant only -22.1182
Log likelihood, full model -16.0938
G 12.0488
Degrees of freedom 3
P 0.00722

At p = 0.00722 the three factors together explain something. A small p value on G is the good outcome here.

Goodness of fit: where a large p value is what you want

Test Chi-square DF P
Pearson 1.5728 4 0.8137
Deviance 2.0560 4 0.7255

This is the one block on the sheet where a large p value is the good result. It compares the eight fitted probabilities against the eight observed pass rates, and a large p value says they are consistent: the model is the right shape. A small one would say the three main effects are not enough and something is missing.

The degrees of freedom are 4, the eight distinct factor settings less the four parameters fitted. That is why the thirty-two runs are grouped into eight for this test: a per-run Pearson statistic on data that is only ever 0 or 1 has no distribution worth quoting.

Hosmer-Lemeshow is not reported

Its result depends on how the data is grouped into bins and there is no single agreed way to do that, so the same data can pass or fail on a choice the test does not fix. Pearson and deviance are reported instead.

The predicted probabilities, against what happened

This is the part of the report to read if the coefficients do not mean much to you yet. One row per distinct setting:

Temp Press Time Passed Predicted P(Pass)
180 40 10 0 of 4 0.0568
220 40 10 2 of 4 0.3855
180 60 10 1 of 4 0.1537
220 60 10 2 of 4 0.6540
180 40 20 1 of 4 0.2666
220 40 20 3 of 4 0.7911
180 60 20 2 of 4 0.5229
220 60 20 4 of 4 0.9194

The fit is monotone in all three factors and the data is not. Look at 220, 40, 10 and 220, 60, 10: both passed twice out of four, and the model predicts 0.3855 for the first and 0.6540 for the second. A model of main effects cannot bend to match every cell, and the goodness of fit test above is the statement that the gaps are no bigger than thirty-two runs would produce by chance anyway.

The lowest and highest cells are the ones to read most confidently. Nothing passed at 180, 40, 10 and the model gives it 0.0568; everything passed at 220, 60, 20 and the model gives it 0.9194. It does not give either one 0 or 1, and it never will: the logistic curve approaches both ends without reaching them, which is also why a probability from this engine is never quite certain.

Things to try next

  • Change Type: to Quantitative and run again. Ordinary least squares runs instead, on a response that is only ever 0 or 1, and its predictions run outside 0 to 1 where this engine's cannot. That is the clearest argument for the logistic form.
  • Add the three two-factor interactions and run again. With 32 runs there is room for them. Watch AIC and BIC: the log likelihood can only improve, and those two say whether it improved enough to pay for three more terms.
  • Change the Event cell to Fail. Every coefficient keeps its size and changes sign, every odds ratio becomes its reciprocal, and the log likelihood, G and both goodness of fit statistics do not move at all.
  • Read the Math Details for how the coefficients are found, and Regression Results for every column on the report.

See Also