Skip to content
Celeus

Logistic regression

Shown in the app as logistic_regression. Part of the method reference, under Regression.

When to use

Model a binary outcome from predictors, adjusting for covariates.

What you provide

  • Outcome: one two-level column.
  • Predictors: one or more columns.

Options

Missing data

  • Complete case (listwise deletion)
  • Mean imputation (single)
  • Median imputation (single)
  • Multiple imputation

Multiple comparisons

  • Not adjustable for this method. Where it makes post-hoc comparisons, the procedure applies its own correction.

Confidence level

Every interval in the result is reported at the level you choose:

  • 90%
  • 95%
  • 99%

Other methods under Regression:

Guides that discuss this method

How to read the output

Logistic regression models a yes/no outcome, for example whether a student passes an exam or whether a seedling survives a season, from one or more predictors.

Coefficients and odds ratios. Each coefficient is on the log-odds scale. Exponentiated, it is an odds ratio: for a numeric predictor, the multiplicative change in the odds of the outcome per one-unit increase; for a categorical predictor, the odds in that category relative to the reference category, which is always the first category (an ordered category is compared with its first level too, never fitted as a polynomial trend). Each is adjusted for the other predictors in the model. An odds ratio above 1 means higher odds and below 1 lower odds; read it with its confidence interval. The headline result is the odds ratio for the first predictor.

Intervals. Confidence intervals are profile-likelihood intervals, which stay accurate where the simpler estimate-plus-or-minus interval does not (small samples, odds ratios far from 1). You can choose a 90%, 95% or 99% level, and every interval in the result uses it. Under multiple imputation the intervals are Wald intervals pooled across the imputed datasets by Rubin’s rules, and the Methods text says so.

Testing a whole predictor. A categorical predictor with three or more levels has several contrasts, so each predictor is also tested as a whole with a likelihood-ratio test, and the whole model is tested against a model with no predictors. When the first predictor has three or more levels, read its whole-predictor test before the single contrast in the headline. These tests are not computed under multiple imputation.

Missing outcomes. With mean or median imputation, only missing predictor values are filled. A row with a missing outcome is dropped and counted, because filling a yes/no outcome with an average would invent an outcome.

An odds ratio is not a risk ratio. When the outcome is common, the odds ratio is further from 1 than the corresponding risk ratio, so avoid reading it as “times as likely”.

Checks to read alongside. With few events per estimated parameter, coefficients are unstable; a common rule of thumb asks for about 10 events of the rarer outcome per parameter (Peduzzi and colleagues, 1996). The calibration check asks whether predicted probabilities match the observed outcome rates (Hosmer and Lemeshow). If a predictor separates the outcomes perfectly, ordinary estimates do not exist; the predictor’s likelihood-ratio test is still reported, and Celeus flags the fit and offers penalised (Firth) logistic regression instead.

Survey designs. When the data come from a complex survey (sampling weights, and optionally PSUs, strata and a finite population correction), the model is fitted to the design: estimates are weighted to the surveyed population, standard errors use Taylor-series linearisation, and the odds ratio’s confidence interval uses t on the design’s degrees of freedom. Each predictor also gets a design-based Wald F test.

A subpopulation is analysed by restricting the design, not the data. The events-per-parameter check still counts the unweighted rows, the calibration check and the power estimate are not computed, and a penalised (Firth) model is not available under a design, so a separated model is flagged with advice to simplify it.

Sources: Hosmer DW, Lemeshow S, Sturdivant RX (2013), Applied Logistic Regression, 3rd ed., Wiley, doi:10.1002/9781118548387. Peduzzi P et al. (1996), Journal of Clinical Epidemiology 49(12):1373-1379, doi:10.1016/S0895-4356(96)00236-3. Lumley T (2004), “Analysis of complex survey samples”, Journal of Statistical Software 9(1):1-19.

Worked examples

Celeus's result on a published or illustrative dataset, next to an independent computation and, where one exists, a published value. The data themselves are not reproduced here.

datasets::mtcars

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Henderson & Velleman (1981)
QuantityCeleusIndependent computationPublished valueAgrees
Estimate-8.08348-8.08348-Yes
p-value0.008433810.00843381-Yes

logistf::sex2

  • Source: Published dataset distributed with an R package
  • Licence: logistf (GPL)
  • Reference: Heinze G, Schemper M (2002), Statistics in Medicine 21:2409-2419 (the worked example); data from Cytel Inc., LogXact 9 user manual
QuantityCeleusIndependent computationPublished valueAgrees
Estimate16.734216.7342-Yes
p-value0.9832990.983299-Yes

MASS::birthwt

  • Source: Published dataset distributed with an R package
  • Licence: MASS (GPL)
  • Reference: Hosmer & Lemeshow (1989), Applied Logistic Regression
QuantityCeleusIndependent computationPublished valueAgrees
Estimate-0.0389946-0.0389946-Yes
p-value0.233440.23344-Yes

datasets::mtcars

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Henderson & Velleman (1981); independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Estimate-4.02397-4.02397-Yes
p-value0.00508820.0050882-Yes
Effect size0.01788180.0178818-Yes
Test statistic for each model term24.053624.0536-Yes
Whole-model likelihood-ratio statistic24.053624.0536-Yes
Number of observations3232-Yes
Confidence interval-7.69893, -1.83336-7.69866, -1.83328-Yes
Effect size confidence interval0.000453312, 0.1598750000.000453434, 0.159888000-Yes

datasets::mtcars

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Henderson & Velleman (1981); independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Estimate-4.02397-4.02397-Yes
p-value0.00508820.0050882-Yes
Effect size0.01788180.0178818-Yes
Test statistic for each model term24.053624.0536-Yes
Whole-model likelihood-ratio statistic24.053624.0536-Yes
Number of observations3232-Yes
Confidence interval-6.97910, -2.11505-6.97860, -2.11389-Yes
Effect size confidence interval0.000931141, 0.1206270000.000931609, 0.120767000-Yes

datasets::mtcars

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Henderson & Velleman (1981); independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Estimate-4.02397-4.02397-Yes
p-value0.00508820.0050882-Yes
Effect size0.01788180.0178818-Yes
Test statistic for each model term24.053624.0536-Yes
Whole-model likelihood-ratio statistic24.053624.0536-Yes
Number of observations3232-Yes
Confidence interval-9.27355, -1.34614-9.27305, -1.34474-Yes
Effect size confidence interval9.38746e-05, 2.60242e-019.39214e-05, 2.60609e-01-Yes

MASS::birthwt

  • Source: Published dataset distributed with an R package
  • Licence: MASS (GPL)
  • Reference: Hosmer & Lemeshow, Applied Logistic Regression; independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Estimate1.00391.0039-Yes
p-value0.0437550.043755-Yes
Effect size2.72892.7289-Yes
Test statistic for each model term4.425290, 0.505907, 5.321740, 0.0877314.425290, 0.505907, 5.321740, 0.087731-Yes
Whole-model likelihood-ratio statistic12.099112.0991-Yes
Number of observations189189-Yes
Confidence interval0.0229561, 1.99097000.0229922, 1.9909300-Yes
Effect size confidence interval1.02322, 7.322601.02326, 7.32230-Yes
Hosmer-Lemeshow calibration statistic3.312553.31255-Yes

MASS::birthwt (race as integer codes)

  • Source: Published dataset distributed with an R package
  • Licence: MASS (GPL)
  • Reference: Hosmer & Lemeshow, Applied Logistic Regression; independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Estimate1.00391.0039-Yes
p-value0.0437550.043755-Yes
Effect size2.72892.7289-Yes
Test statistic for each model term4.425290, 0.505907, 5.321740, 0.0877314.425290, 0.505907, 5.321740, 0.087731-Yes
Whole-model likelihood-ratio statistic12.099112.0991-Yes
Number of observations189189-Yes
Confidence interval0.0229561, 1.99097000.0229922, 1.9909300-Yes
Effect size confidence interval1.02322, 7.322601.02326, 7.32230-Yes

MASS::birthwt (race declared ordinal)

  • Source: Published dataset distributed with an R package
  • Licence: MASS (GPL)
  • Reference: Hosmer & Lemeshow, Applied Logistic Regression; independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Estimate1.00391.0039-Yes
p-value0.0437550.043755-Yes
Effect size2.72892.7289-Yes
Test statistic for each model term4.425290, 0.505907, 5.321740, 0.0877314.425290, 0.505907, 5.321740, 0.087731-Yes
Whole-model likelihood-ratio statistic12.099112.0991-Yes
Number of observations189189-Yes
Confidence interval0.0229561, 1.99097000.0229922, 1.9909300-Yes
Effect size confidence interval1.02322, 7.322601.02326, 7.32230-Yes

datasets::infert

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Trichopoulos et al. (1976), Br J Obstet Gynaecol 83; independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Estimate1.197211.19721-Yes
p-value1.543e-081.543e-08-Yes
Effect size3.310853.31085-Yes
Test statistic for each model term36.48680, 4.1496536.48680, 4.14965-Yes
Whole-model likelihood-ratio statistic36.559136.5591-Yes
Number of observations248248-Yes
Confidence interval0.793945, 1.6265800.793934, 1.626570-Yes
Effect size confidence interval2.21211, 5.086462.21208, 5.08639-Yes

datasets::esoph (expanded to 975 subjects)

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Breslow & Day (1980), Statistical Methods in Cancer Research I; independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Estimate1.980881.98088-Yes
Test statistic for each model term126.4880, 127.9330, 23.5443126.4880, 127.9330, 23.5443-Yes
Whole-model likelihood-ratio statistic285.617285.617-Yes

datasets::esoph (expanded, ordered factors)

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Breslow & Day (1980), Statistical Methods in Cancer Research I; independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Estimate1.980881.98088-Yes
Test statistic for each model term126.4880, 127.9330, 23.5443126.4880, 127.9330, 23.5443-Yes

datasets::Titanic (expanded to 2201 passengers)

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Dawson (1995), J. Statistics Education 3(3); independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Estimate2.420062.42006-Yes
p-value1.43183e-661.43183e-66-Yes
Effect size11.246511.2465-Yes
Test statistic for each model term352.9110, 119.0340, 18.8517352.9110, 119.0340, 18.8517-Yes
Whole-model likelihood-ratio statistic559.396559.396-Yes
Number of observations22012201-Yes
Confidence interval2.14859, 2.699352.14858, 2.69934-Yes
Effect size confidence interval8.57273, 14.870108.57268, 14.87000-Yes

carData::TitanicSurvival

  • Source: Published dataset distributed with an R package
  • Licence: carData (GPL)
  • Reference: Dawson (1995), J. Statistics Education 3(3); independent computation on the 1046 complete rows
QuantityCeleusIndependent computationPublished valueAgrees
Estimate-2.49784-2.49784-Yes
p-value3.78293e-513.78293e-51-Yes
Effect size0.08226210.0822621-Yes
Test statistic for each model term273.2390, 31.3441, 118.8860273.2390, 31.3441, 118.8860-Yes
Whole-model likelihood-ratio statistic432.167432.167-Yes
Number of observations10461046-Yes
Confidence interval-2.82906, -2.17762-2.82905, -2.17761-Yes
Effect size confidence interval0.0590684, 0.11331100.0590689, 0.1133120-Yes
Number of rows dropped for missing values263263-Yes

carData::TitanicSurvival

  • Source: Published dataset distributed with an R package
  • Licence: carData (GPL)
  • Reference: Dawson (1995), J. Statistics Education 3(3); the same multiple-imputation call
QuantityCeleusIndependent computationPublished valueAgrees
Estimate-2.50242-2.50242-Yes
p-value2.23132e-572.23132e-57-Yes
Confidence interval-2.74778, -2.25707-2.74778, -2.25707-Yes
Effect size0.08188620.0818862-Yes
Effect size confidence interval0.064070, 0.1046570.064070, 0.104657-Yes

datasets::mtcars (am removed in rows 3, 7 and 11)

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Henderson & Velleman (1981); independent computation on the 29 rows with an outcome
QuantityCeleusIndependent computationPublished valueAgrees
Estimate-3.72102-3.72102-Yes
p-value0.008838140.00883814-Yes
Effect size0.02420930.0242093-Yes
Test statistic for each model term20.834820.8348-Yes
Whole-model likelihood-ratio statistic20.834820.8348-Yes
Number of observations2929-Yes
Confidence interval-7.38670, -1.58527-7.38666, -1.58427-Yes
Effect size confidence interval0.000619434, 0.2048920000.000619461, 0.205098000-Yes

datasets::mtcars (rows 1-15)

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Henderson & Velleman (1981); independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Test statistic for each model term15.012115.0121-Yes
Whole-model likelihood-ratio statistic15.012115.0121-Yes
Number of observations1515-Yes

datasets::mtcars

  • Source: Published dataset distributed with an R package
  • Licence: base R (GPL)
  • Reference: Henderson & Velleman (1981); independent computation
QuantityCeleusIndependent computationPublished valueAgrees
Test statistic for each model term27.953427.9534-Yes
Whole-model likelihood-ratio statistic27.953427.9534-Yes
Number of observations3232-Yes

survey::apiclus1 (school-wide growth target met, Yes/No)

  • Source: Published dataset distributed with an R package
  • Licence: survey (GPL-2 | GPL-3)
  • Reference: Lumley T, "A survey analysis example" (survey package vignette) for the published coefficients; independent computation with the survey package
QuantityCeleusIndependent computationPublished valueAgrees
Estimate0.03992540.03992540.039925Yes
Test statistic3.208753.208753.209Yes
p-value0.007509610.007509610.00751Yes
Degrees of freedom1212-Yes
Confidence interval0.0128152, 0.06703570.0128152, 0.0670357-Yes
Test statistic for the term, predictor 110.296110.2961-Yes
p-value for the term, predictor 10.007509610.00750961-Yes
Test statistic for the term, predictor 24.690954.69095-Yes
p-value for the term, predictor 20.05117230.0511723-Yes
Effect size1.040731.04073-Yes
Effect size confidence interval1.01290, 1.069331.01290, 1.06933-Yes

survey::apistrat (school-wide growth target met)

  • Source: Published dataset distributed with an R package
  • Licence: survey (GPL-2 | GPL-3)
  • Reference: independent computation with the survey package
QuantityCeleusIndependent computationPublished valueAgrees
Estimate-0.00248964-0.00248964-Yes
Test statistic-0.187862-0.187862-Yes
p-value0.8511810.851181-Yes
Degrees of freedom194194-Yes
Confidence interval-0.0243926, 0.0194134-0.0243926, 0.0194134-Yes
Test statistic for the term, predictor 10.0352920.035292-Yes
p-value for the term, predictor 10.8511810.851181-Yes
Test statistic for the term, predictor 20.1174210.117421-Yes
p-value for the term, predictor 20.732220.73222-Yes
Test statistic for the term, predictor 33.636163.63616-Yes
p-value for the term, predictor 30.05801480.0580148-Yes
Effect size confidence interval0.975902, 1.0196000.975902, 1.019600-Yes

survey::nhanes (race and sex recoded to text labels; a missing cholesterol outcome is a domain restriction)

  • Source: Published dataset distributed with an R package
  • Licence: survey (GPL-2 | GPL-3)
  • Reference: independent computation with the survey package
QuantityCeleusIndependent computationPublished valueAgrees
Estimate-0.0848865-0.0848865-Yes
Test statistic-1.06263-1.06263-Yes
p-value0.315630.31563-Yes
Degrees of freedom99-Yes
Confidence interval-0.2655950, 0.0958222-0.2655950, 0.0958222-Yes
Test statistic for the term, predictor 13.105773.10577-Yes
p-value for the term, predictor 10.08157330.0815733-Yes
Test statistic for the term, predictor 230.3730.37-Yes
p-value for the term, predictor 24.87663e-054.87663e-05-Yes
Test statistic for the term, predictor 36.322816.32281-Yes
p-value for the term, predictor 30.03306460.0330646-Yes
Number of observations78467846-Yes
Number of rows dropped for missing values745745-Yes

Validation report

References

  1. Nelder, J. A., Wedderburn, R. W. M. (1972). Generalized linear models. Journal of the Royal Statistical Society, Series A 135: 370-384. doi:10.2307/2344614 doi:10.2307/2344614