Skip to content
Tutorials Center
My learning

Topics

Lesson 31 of 39 ยท Regression and ANOVA

Binary Logistic Regression in SPSS: Odds Ratios

Model a yes/no outcome in SPSS with binary logistic regression: odds and log odds, the Exp(B) odds ratio, classification table, Hosmer-Lemeshow, Nagelkerke R squared.

Linear regression needs a scale outcome. When the outcome is a yes/no event (passed or failed, bought or did not buy, recovered or did not), you need binary logistic regression. It models the probability of the event as a function of predictors, and it reports results as odds ratios, which makes it one of the most used methods in health research, marketing and the social sciences.

From probability to odds to log odds

  • Probability p of the event: 0 to 1.
  • Odds = p / (1 - p). If p = .75, the odds are 3 (to 1).
  • Log odds (logit) = ln(odds), which ranges over all real numbers.

Logistic regression is a straight-line model for the log odds:

ln(p / (1 - p)) = b0 + b1 x1 + b2 x2 + ...

Turning that back gives probabilities that stay between 0 and 1, which a straight line for p could never guarantee.

Python Stand-in: probability, odds and the logistic curve

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that each extra hour multiplies the odds by the same factor, exp(0.8) = 2.23, while the probability change differs along the curve. That multiplier is what SPSS prints as Exp(B).

Preparing the data

  • The dependent variable must have two categories. Code the event of interest as 1 and the reference as 0 (SPSS predicts the category with the higher code).
  • Predictors can be scale, binary or categorical (declared in the Categorical dialog).
  • Rule of thumb: at least 10 events (and 10 non-events) per predictor.

Running it in SPSS

  1. Analyze > Regression > Binary Logistic.
  2. Dependent: passed (0/1). Covariates: the predictors.
  3. For nominal predictors with more than two categories, click Categorical, move them to Categorical Covariates, and choose Contrast "Indicator" with Reference Category First or Last, then Change. SPSS builds the dummies for you.
  4. Options: tick Classification plots, Hosmer-Lemeshow goodness-of-fit, CI for exp(B): 95%, and Casewise listing of residuals if you want outliers.
  5. Save: predicted probabilities (useful for ROC analysis).
  6. Paste:
Text
LOGISTIC REGRESSION VARIABLES passed
  /METHOD=ENTER hours prior_course
  /CATEGORICAL=prior_course
  /PRINT=GOODFIT CI(95)
  /CRITERIA=PIN(.05) POUT(.10) ITERATE(20) CUT(.5).

Reading the output

  1. Case Processing Summary and Dependent Variable Encoding: confirm which category is 1 (the event).
  2. Block 0: Beginning Block: the model with the constant only; its Classification Table shows the baseline accuracy from always predicting the more common outcome.
  3. Block 1: Method = Enter:
    • Omnibus Tests of Model Coefficients: chi-square, df and Sig. for the whole model. A small Sig. means your predictors improve on the constant-only model.
    • Model Summary: -2 Log likelihood, Cox & Snell R Square and Nagelkerke R Square. These are pseudo-R squared values; Nagelkerke runs from 0 to 1 and is the one usually reported. They do not mean "variance explained" in the linear sense.
    • Hosmer and Lemeshow Test: for fit; here a non-significant Sig. (above .05) is good, meaning no evidence of poor fit.
    • Classification Table: percent correctly predicted at the .5 cut-off, overall and per outcome. Compare with Block 0.
    • Variables in the Equation: for each predictor B, S.E., Wald, df, Sig. and Exp(B) with its 95% CI.

Interpreting Exp(B)

  • Exp(B) = 1: no effect. Above 1: higher odds of the event. Below 1: lower odds.
  • Exp(B) = 2.23 for hours: each extra hour multiplies the odds of passing by 2.23 (an increase of 123% in the odds), holding other predictors constant.
  • Exp(B) = 0.60: odds fall by 40% per unit.
  • If the 95% CI for Exp(B) includes 1, the predictor is not significant at .05.
  • Odds ratios are not risk ratios; for common events they exaggerate the risk change.
Python Stand-in: fitting a logistic regression by gradient steps

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

SPSS uses a faster method (iteratively reweighted least squares), but it converges to the same maximum-likelihood coefficients.

Assumptions and problems

  • Independent observations; no multicollinearity among predictors (check by running the same predictors in a linear regression and reading VIF).
  • Linearity of the logit for scale predictors (a Box-Tidwell check adds the predictor times its log).
  • Perfect separation (a predictor that predicts the outcome perfectly) breaks estimation: huge B values and standard errors, and a warning.
  • Rare events and small samples give unreliable coefficients.

Writing it up

"A logistic regression predicted passing from study hours. Each additional hour increased the odds of passing by a factor of 2.2 (OR = 2.2)." Add the omnibus chi-square, Nagelkerke R squared and the 95% CI from your own tables, and compare the classification accuracy with the baseline in Block 0.

For related tests when the outcome is a count table instead, see the chi-square test.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Exp(B) = 1.8 for a predictor. How do you read it?

    Exp(B) is an odds ratio: the factor by which the odds change per unit of the predictor.
  2. 2. Which Hosmer-Lemeshow result suggests an adequate fit?

    A non-significant result means no evidence that predicted and observed counts differ.
  3. 3. How should the dependent variable be coded?

    SPSS models the probability of the higher-coded category, so give the event the code 1.
  4. 4. A 95% CI for Exp(B) is [0.8, 2.5]. The predictor is:

    An odds ratio of 1 means no effect, and the interval contains it.

Summary

  • Binary logistic regression models the log odds of a 0/1 outcome (Analyze > Regression > Binary Logistic).
  • Declare categorical predictors in the Categorical dialog; code the event as 1.
  • Read the omnibus test, Nagelkerke R squared, Hosmer-Lemeshow, the classification table and Exp(B) with its CI.
  • Watch for separation, small event counts and multicollinearity.

Next: Chart Builder