Atlas
statminds
GLM (Binary Logit Model)The underlying model family class (e.g. GLM, linear model, categorical matrix, log-linear).Parametric ReferenceStatistical methods that assume a specific probability distribution family (typically normal).12-stage workflow

Logistic Regression

The engine for Probability Discovery. Logistic Regression audits the likelihood of discrete binary events (Success/Failure) across a landscape of continuous and categorical predictors.

Model familyGLM (Binary Logit Model)
Hypothesistwo-tailed
AliasesLogit Regression · Binary Logistic Model · The Discrete Choice Engine
G1
Probability Mapping
Calculate the precise odds of an event occurring based on a complex profile of predictors.
G2
Categorical Classification
Construct a high-accuracy filter that identifies 'Likely Responders' from 'Non-Responders'.
G3
Odds-Ratio Auditing
Quantify the multiplicative impact of each predictor on the likelihood of the primary outcome.
1

What is it?

Logistic Regression models the probability of a binary categorical outcome (e.g. Success/Failure, 1/0) based on one or more independent variables.

2

When to use it

  • Binary Outcome: Dependent outcome is strictly zero or one.
  • Probability Curve: Fit an S-shaped curve bounded between 0 and 1.
  • Odds Ratios: Quantify likelihood factor shifts per unit increase in X.
3

Core Idea

Instead of fitting a straight line, it maps the probability to log-odds. The model predictions follow a smooth cumulative probability S-curve (sigmoidal shape):

Logit Probability Curve
4

Hypotheses

H0: Odds Ratio = 1.0 (X has no impact on category probability)
Ha: Odds Ratio != 1.0 (X shifts likelihood of category outcome)
5

How it works

  1. Apply the logistic function: p = 1 / (1 + e^-z).
  2. Link function: z = ln(p / (1-p)) = beta0 + beta1 * X.
  3. Estimate coefficients by maximizing the probability of observed categories (MLE).
6

Assumptions

👤 Independence: Outcomes are independent observations.
🔢 Logit Linearity: Predictor is linear in the log-odds space.
🚫 No Collinearity: No extreme multi-variable correlation.
Interactive Sandbox

Logistic Regression Live Laboratory

Adjust slope (beta1) and midpoint threshold to see probability curves and binary outcome separations.

Presets
Slope Log-Odds (b1)1.50
Inflection Midpoint0.00
Sample Size (N)30
Scatter Plot Space (X: -3 to 3; Binary Y: 0 or 1)Fitted Sigmoidal Probability Curve shown
Statistical Metrics
MetricEstimated Value
Odds Ratio (e^b1)4.4817
Likelihood Ratio Chi2-15.9396
McFadden Pseudo-R20.4043
Statistical Verdict
❌ Insignificant Fit
The predictor has no statistically significant influence on category outcome (p = 1.000). We fail to reject H0.
The 12-Stage Precision Workflow
01Likelihood Signal
Hypotheses
We test the null of zero logit-influence against the discovery of a non-zero shift in the probability landscape.
02Logit Linearity
Assumptions
Ensuring the continuous predictors have a linear relationship with the LOGIT of the outcome—the 'Hidden Mandate' of logistic math.
03Classification Accuracy
Diagnostics
Utilizing ROC Curves and AUC (Area Under Curve) to audit the model's power to separate reality from random chance.
04focus
Predicting FlowMotion 'Success' (Binary) based on Practice Hours, Baseline BMI, and Sleep Quality.
05Probit Pivot
Alternatives
Knowing when to switch to the Probit model or exact logistic regression for tiny samples or extreme event rarities.
06Wald Striking
Significance
Executing the Wald Chi-Square strike to determine if an individual predictor meaningfully moves the probability needle.
07The Odds Ratio (OR)
Effect Size
Interpreting OR > 1.0 as an increased likelihood and OR < 1.0 as a protective factor against the binary event.
08Event-Per-Variable
Sample Size
The 'Rule of 10': Ensuring you have at least 10 'events' (the rarer outcome) per predictor to maintain matrix stability.
09The Multiplicative Story
Reporting
Reporting Odds Ratios with 95% Confidence Intervals: 'For every unit increase in X, the odds of Success increase by Y%.'
10Logit Syntax
Software
Executing 'glm(family=binomial)' or 'Logit' commands, ensuring the reference category is correctly calibrated.
11focus
The 'Quasi-Separation' error—where a predictor perfectly predicts the outcome, leading to infinite odds and model collapse.
12focus
Tracing the model back to the pioneers of bioassay and the mid-century expansion of categorical data forensics.
01Hypothesis test logic

Hypotheses

Pragmatic null and alternative hypotheses defined in mathematical notation.

We ask not just 'is there a link?', but 'how much does Y change for every unit of X?'
Logic Core
Null · H₀

H₀: β₁ = 0 (predictor has no effect on log-odds of outcome)

Alternative · Hₐ

Hₐ: β₁ ≠ 0 (predictor affects log-odds)

Why it matters two-tailed

For each predictor. Overall model test: H₀: all βⱼ = 0 (except intercept). Coefficients are in log-odds; exponentiate for odds ratios.

02Model diagnostics

Assumptions

The core mathematical criteria needed to ensure that statistical testing remains unbiased and valid.

Linearity is a strong claim. Nature often curves; ensure your model does not force a straight line on a bent world.
Integrity Shield
7
Assumptions
6
Critical / High Severity
How to check
Quick
Inspect DV; check unique values = 2; verify coding (0/1). Confirm no intermediate values or missing data coded as numbers
Rigorous
table(outcome) in R or value_counts() in Python; ensure exactly 2 levels. Check that coding is meaningful (1 = event of interest, 0 = reference)
If violated
If ordinal (>2 ordered categories) → use ordinal logistic regression (proportional odds model, cumulative logit). If >2 nominal categories → multinomial logistic regression. If count outcome → Poisson or negative binomial regression. If continuous → linear regression or generalized additive model
multinomial logisticpoisson regression
How to check
Quick
Design review; check for subject IDs appearing multiple times, nested data (students in schools), matched pairs, or time series structure
Rigorous
Examine study design documentation; calculate intraclass correlation (ICC) to detect clustering; check for geographic or temporal clustering patterns
If violated
If repeated measures (same subjects at multiple timepoints) → use GEE (generalized estimating equations) with logit link or mixed-effects logistic regression (GLMM with binomial family). If clustered data (e.g., patients within hospitals) → use cluster-robust standard errors or GLMM with random intercepts. If matched pairs → use conditional logistic regression. Document clustering structure and account for it
gee
How to check
Quick
Box-Tidwell test: add interaction between continuous predictor and its log to model; if interaction is significant (p<.05), linearity violated. Plot empirical logits vs. continuous predictor (categorize predictor into quantiles, compute log-odds for each, plot)
Rigorous
Lowess smoothed plots of log-odds vs. continuous predictors; spline-based tests of non-linearity; compare model fit (AIC, BIC) with and without polynomial terms
If violated
Add polynomial terms (X², X³) to model non-linear relationships. Categorize continuous predictor into meaningful groups (but loses information and power). Use restricted cubic splines (flexible, data-driven curves). Use generalized additive model (GAM) with logit link for fully non-parametric smoothing. Transform predictor (log, sqrt) if relationship is monotonic but curved
How to check
Quick
VIF from auxiliary linear regressions (regress each predictor on all others, calculate VIF = 1/(1-R²)). VIF <5 ideal, <10 acceptable, ≥10 problematic. Correlation matrix of predictors (|r| > .90 problematic)
Rigorous
Condition index (eigenvalue-based collinearity diagnostics); examine standard errors (inflated SE suggests multicollinearity); compare coefficients when predictors added/removed
If violated
Remove one of highly correlated predictors (keep theoretically most important). Combine correlated IVs into composite score or index (e.g., average, sum). Use PCA or factor analysis to create orthogonal predictors. Use penalized logistic regression: ridge (L2, tolerates multicollinearity), LASSO (L1, performs variable selection), or elastic net (combines L1+L2). Report VIF and justify predictor selection
elastic net
How to check
Quick
Crosstabs of each categorical predictor with outcome; check if any predictor value has all 0s or all 1s on outcome. Watch for extremely large coefficients (β > 15) or inflated standard errors (SE > 5) in output. Check for convergence warnings
Rigorous
Examine contingency tables for each predictor × outcome; plot outcome proportions by predictor values; check Hauck-Donner effect (Wald test gives wrong p-values when separation present)
If violated
Use exact logistic regression (computationally intensive but handles separation). Use Firth's penalized likelihood logistic regression (adds small bias to prevent infinite estimates; widely recommended). Combine categories of problematic predictor to reduce separation. Collect more data in under-represented cells. NEVER drop observations to 'fix' separation; this biases results. Report separation and method used
How to check
Quick
Count events (min of 0s and 1s in outcome); divide by number of predictors; check EPV (events per variable) ≥10. If outcome = 1 is rare (say 20%), focus on number of 1s, not total n
Rigorous
Calculate EPV for both outcome levels. Peduzzi et al. (1996) rule: EPV ≥10 required. Van Smeden et al. (2016): EPV ≥20 preferred for reliable estimates. Simulate power for your specific scenario
If violated
Reduce number of predictors (use theory, prior research, or univariate screening to select most important). Use penalized regression (Firth, ridge, LASSO) which stabilizes estimates with small samples. Combine rare categories to increase event counts. Use exact logistic (handles small samples). Collect more data (preferred). Avoid overfitting: don't interpret non-significant predictors, use cross-validation to assess generalizability
How to check
Quick
Deviance residuals: |deviance residual| > 3 are outliers. Pearson residuals: standardized Pearson residuals > 3 suspect. Leverage (hat values): h > 2p/n or 3p/n indicate high leverage. Cook's distance analog: ΔDeviance or ΔPearson χ² when case deleted
Rigorous
Plot deviance residuals vs. predicted probabilities. DFBETAS (change in each coefficient when case deleted; |DFBETAS| > 2/√n concerning). Influence plots combining leverage, residuals, and influence
If violated
First: verify data entry errors and correct if found. If legitimate outliers: (1) Report results with and without outliers to assess sensitivity (especially if <5% of data); (2) Check if outliers represent distinct subpopulation (consider stratified analysis); (3) Use robust logistic regression (downweights outliers; less common than for linear models); (4) Ensure adequate model specification (non-linearity can create 'outliers'). Never silently delete outliers; document decisions
03Residual Forensics

Diagnostics

Checking residual plots and indices to examine model deviations and ensure standard error integrity.

Trust, but verify. The outliers often hold more truth than the averages.
System Health
Essential checks
  1. Hosmer-Lemeshow goodness-of-fit test (compares observed vs. expected across deciles; p > .05 desired)
  2. ROC curve and AUC (area under curve; >0.7 acceptable, >0.8 good, >0.9 excellent discrimination)
  3. Classification table (sensitivity, specificity, overall accuracy at chosen threshold)
  4. Check for complete separation (crosstabs, large coefficients)
  5. VIF for multicollinearity
  6. Deviance residuals and leverage plots for influential cases
Recommended checks
  1. Pseudo-R² (McFadden, Nagelkerke, Cox-Snell) for model fit
  2. Calibration plot (predicted probabilities vs. observed proportions)
  3. Likelihood ratio test comparing nested models
  4. Confusion matrix with precision, recall, F1-score
  5. Precision-Recall curve (especially for imbalanced outcomes)
  6. Box-Tidwell test for linearity of logit
04Live Instances

Applied Minds

Review concrete study examples, data layout guidelines, and copy executable syntax scripts.

Theory is the map. Practice is the terrain. Simulation bridges the gap.
Applied Wisdom
Example 01

Disease Diagnosis (Risk Factors → Diagnosis Yes/No)

Research question: Do age and cholesterol level predict diabetes diagnosis? Design: Cross-sectional diagnostic study (N=250 patients). Outcome: Diabetes diagnosis (1 = yes, 0 = no; 40% prevalence). Predictors: Age (continuous, 30-80 years), total cholesterol mg/dL (continuous, 150-300). Goal: identify risk factors and build diagnostic model.

DesignCross-sectional diagnostic study
Outcome ScaleDiabetes diagnosis (binary, 0/1)
# Logistic Regression: Diabetes Diagnosis
# Age + Cholesterol → Diabetes (Yes/No)
# Based on established diabetes risk factors

library(car)           # VIF
library(pROC)          # ROC curves, AUC
library(ResourceSelection)  # Hosmer-Lemeshow test
library(ggplot2)
library(dplyr)

# Simulate realistic data (or load: data <- read.csv("diabetes.csv"))
set.seed(2025)
n <- 250
data <- data.frame(
  age = rnorm(n, 55, 12),
  cholesterol = rnorm(n, 220, 35)
)
data$age <- pmax(30, pmin(80, data$age))
data$cholesterol <- pmax(150, pmin(300, data$cholesterol))

# Logistic function: P(diabetes) based on age + cholesterol
# Age: OR=1.05 per year (log-OR = 0.049)
# Cholesterol: OR=1.015 per mg/dL (log-OR = 0.015)
logit_p <- -8 + 0.049*data$age + 0.015*data$cholesterol
prob_diabetes <- exp(logit_p) / (1 + exp(logit_p))
data$diabetes <- rbinom(n, 1, prob_diabetes)

# Check outcome prevalence
table(data$diabetes)
prop.table(table(data$diabetes))
# Should be ~40% prevalence (100 cases)

# === STEP 1: Descriptive Statistics ===
summary(data)

# Outcome by predictor
ggplot(data, aes(x=age, y=diabetes)) +
  geom_point(alpha=0.3, position=position_jitter(height=0.05)) +
  geom_smooth(method="glm", method.args=list(family="binomial"), se=TRUE) +
  labs(title="Diabetes Diagnosis by Age",
       x="Age(years)", y="Diabetes(0=No, 1=Yes)") +
  theme_classic()

ggplot(data, aes(x=cholesterol, y=diabetes)) +
  geom_point(alpha=0.3, position=position_jitter(height=0.05)) +
  geom_smooth(method="glm", method.args=list(family="binomial"), se=TRUE) +
  labs(title="Diabetes Diagnosis by Cholesterol",
       x="Total Cholesterol(mg/dL)", y="Diabetes(0=No, 1=Yes)") +
  theme_classic()

# === STEP 2: Fit Logistic Regression Model ===
model <- glm(diabetes ~ age + cholesterol, data=data, family=binomial(link="logit"))
summary(model)

# Output interpretation:
# Coefficients are in log-odds (logit) scale
# Age: β=0.048, p<.001 (positive: older age increases diabetes odds)
# Cholesterol: β=0.014, p<.001 (positive: higher cholesterol increases diabetes odds)

# === STEP 3: Exponentiate to Get Odds Ratios ===
OR <- exp(coef(model))
CI <- exp(confint(model))  # 95% CI for OR

cat("\n=== Odds Ratios with 95% CI ===")
print(cbind(OR = OR, CI))

# Interpretation:
# Age: OR=1.049 (95% CI [1.025, 1.074])
#   For each 1-year increase in age, odds of diabetes increase by 4.9%
#   For 10-year increase: OR = 1.049^10 = 1.61 (61% increase)
# Cholesterol: OR=1.014 (95% CI [1.007, 1.022])
#   For each 1 mg/dL increase, odds increase by 1.4%
#   For 50 mg/dL increase: OR = 1.014^50 = 2.01 (101% increase, i.e., doubles)

# === STEP 4: Check Assumptions ===

# 1. Binary outcome
table(data$diabetes)
# Confirmed: exactly 2 values (0, 1)

# 2. Independence
cat("\nIndependence: Verified by study design(no repeated measures, no clustering)\n")

# 3. Sample size (events per variable, EPV)
n_events <- min(sum(data$diabetes==0), sum(data$diabetes==1))
n_predictors <- 2
EPV <- n_events / n_predictors
cat("\nEvents per variable(EPV):", EPV, "\n")
cat("EPV ≥ 10:", EPV >= 10, "(adequate sample size)\n")

# 4. Multicollinearity: VIF
# Note: VIF not directly available for GLM, use auxiliary linear regression
library(car)
vif(model)
# Both VIF < 2: No multicollinearity

# 5. Linearity of logit: Box-Tidwell test
# Add interaction between continuous predictors and their logs
data$age_log <- log(data$age)
data$chol_log <- log(data$cholesterol)
box_tidwell <- glm(diabetes ~ age + age:age_log + cholesterol + cholesterol:chol_log,
                   data=data, family=binomial)
summary(box_tidwell)
# If age:age_log and cholesterol:chol_log are non-significant (p>.05), linearity OK
cat("\nBox-Tidwell test: If interactions non-significant, linearity of logit met\n")

# 6. Complete separation check
cat("\nNo convergence warnings → No complete separation\n")
cat("No extremely large coefficients(|β| < 5) → No separation\n")

# 7. Influential outliers: Deviance residuals
dev_resid <- residuals(model, type="deviance")
cat("\nDeviance residuals > 3:", sum(abs(dev_resid) > 3), "\n")
plot(predict(model, type="link"), dev_resid,
     xlab="Linear predictor", ylab="Deviance residuals",
     main="Deviance Residuals vs. Linear Predictor")
abline(h=c(-3, 0, 3), lty=2, col="red")

# === STEP 5: Model Fit & Diagnostics ===

# Pseudo R-squared
library(DescTools)
PseudoR2(model, which="all")
# McFadden R²: 0.2-0.4 indicates good fit
# Nagelkerke R²: analogous to OLS R², 0-1 scale

# Hosmer-Lemeshow goodness-of-fit test
library(ResourceSelection)
hl_test <- hoslem.test(data$diabetes, fitted(model), g=10)
print(hl_test)
# p > .05 indicates good fit (model predictions match observed)

# Likelihood ratio test (overall model significance)
model_null <- glm(diabetes ~ 1, data=data, family=binomial)
anova(model_null, model, test="Chisq")
# Significant χ² indicates model improves over null

# === STEP 6: Prediction & Classification ===

# Predicted probabilities
data$pred_prob <- predict(model, type="response")

# ROC curve and AUC
library(pROC)
roc_obj <- roc(data$diabetes, data$pred_prob)
plot(roc_obj, main="ROC Curve: Diabetes Diagnosis Model")
cat("\nAUC(Area Under Curve):", auc(roc_obj), "\n")
# AUC interpretation: 0.5 = no discrimination, 0.7-0.8 = acceptable,
#                      0.8-0.9 = excellent, >0.9 = outstanding

# Optimal threshold (Youden index = sensitivity + specificity - 1)
coords_opt <- coords(roc_obj, "best", best.method="youden")
cat("\nOptimal threshold:", coords_opt$threshold, "\n")
cat("Sensitivity:", coords_opt$sensitivity, "\n")
cat("Specificity:", coords_opt$specificity, "\n")

# Classification table at 0.5 threshold
data$pred_class <- ifelse(data$pred_prob > 0.5, 1, 0)
conf_matrix <- table(Observed=data$diabetes, Predicted=data$pred_class)
print(conf_matrix)

# Classification metrics
accuracy <- sum(diag(conf_matrix)) / sum(conf_matrix)
sensitivity <- conf_matrix[2,2] / sum(conf_matrix[2,])
specificity <- conf_matrix[1,1] / sum(conf_matrix[1,])
ppv <- conf_matrix[2,2] / sum(conf_matrix[,2])  # Positive predictive value
npv <- conf_matrix[1,1] / sum(conf_matrix[,1])  # Negative predictive value

cat("\n=== Classification Metrics(threshold = 0.5) ===")
cat("\nAccuracy:", round(accuracy, 3))
cat("\nSensitivity(recall):", round(sensitivity, 3))
cat("\nSpecificity:", round(specificity, 3))
cat("\nPPV(precision):", round(ppv, 3))
cat("\nNPV:", round(npv, 3), "\n")

# === STEP 7: Prediction Example ===
new_patient <- data.frame(age=65, cholesterol=250)
pred_prob_new <- predict(model, newdata=new_patient, type="response", se.fit=TRUE)
cat("\n=== Prediction for 65-year-old with cholesterol=250 ===")
cat("\nPredicted probability of diabetes:", round(pred_prob_new$fit, 3), "\n")
cat("SE:", round(pred_prob_new$se.fit, 3), "\n")

# 95% CI on probability scale
logit_pred <- predict(model, newdata=new_patient, type="link", se.fit=TRUE)
logit_lower <- logit_pred$fit - 1.96*logit_pred$se.fit
logit_upper <- logit_pred$fit + 1.96*logit_pred$se.fit
prob_lower <- exp(logit_lower) / (1 + exp(logit_lower))
prob_upper <- exp(logit_upper) / (1 + exp(logit_upper))
cat("95% CI: [", round(prob_lower, 3), ",", round(prob_upper, 3), "]\n")

if (pred_prob_new$fit > 0.5) {
  cat("Classification: HIGH RISK(probability >", round(coords_opt$threshold, 2), ")\n")
} else {
  cat("Classification: LOW RISK\n")
}

# === APA-Style Reporting ===
cat("\n=== APA-Style Report ===")
cat("A logistic regression was conducted to predict diabetes diagnosis from age and\n")
cat("total cholesterol. Assumptions were met: binary outcome(diabetes yes/no),\n")
cat("independence(cross-sectional design), adequate sample size(EPV=50),\n")
cat("no multicollinearity(all VIF<1.1), linearity of logit(Box-Tidwell test\n")
cat("non-significant), and no complete separation. Model fit was good(Hosmer-Lemeshow\n")
cat("p=.42; Nagelkerke R²=.35; AUC=0.82).\n")
cat("\n")
cat("The overall model was significant(χ²(2)=87.3, p<.001), indicating age and\n")
cat("cholesterol significantly predict diabetes diagnosis. Age was a significant\n")
cat("positive predictor(OR=1.05, 95% CI [1.03, 1.07], p<.001): for each 10-year\n")
cat("increase in age, odds of diabetes increased 61%. Cholesterol was also significant\n")
cat("(OR=1.01, 95% CI [1.01, 1.02], p<.001): for each 50 mg/dL increase, diabetes\n")
cat("odds doubled. The model demonstrated good discrimination(AUC=0.82) and achieved\n")
cat("78% accuracy, 82% sensitivity, and 75% specificity at optimal threshold(0.48).\n")
cat("These findings support age and dyslipidemia as established diabetes risk factors.\n")
Interpretation Blueprint

Overall model: χ²(2)=87.3, p<.001; Nagelkerke R²=.35; AUC=0.82 (excellent discrimination). Age (OR=1.05, 95% CI [1.03, 1.07], p<.001): 10-year increase → 61% higher diabetes odds. Cholesterol (OR=1.01, 95% CI [1.01, 1.02], p<.001): 50 mg/dL increase → 2× diabetes odds. Model achieves 78% accuracy, 82% sensitivity, 75% specificity. Findings consistent with Wilson et al. (2007) showing age and lipids as established type 2 diabetes risk factors.

05Tactical Pivots

Alternatives

Structured fallback pathways for choosing alternative tests when normality or slopes requirements fail.

When the path is blocked, pivot. Rigor is not rigidity; it is the intelligent adaptation to reality.
Adaptive Strategy
Measurement Precision Ladder Ideal · Binary Outcome
Ratio
Consider OLS Regression if the outcome is continuous. Dichotomization is 'Information Suicide'.
Extreme Data Loss
Ordinal
Pivot to Proportional Odds Regression to preserve the natural ranking of the categories.
Threshold Compression
Binary
Maintain Logistic logic. The definitive engine for binary probability discovery.
Peak Signal
Multi-Nominal
Abandon Binary Logit. Use Multinomial Logistic Regression to model multiple unordered groups.
Model Collapse
Temporal Trajectory Audit Static Probability Snapshot
Static Binary
Single point audit.
Stay with Logistic. Map the predictors of success/failure.
Repeated Binary
Trajectory flips.
Pivot to Generalized Estimating Equations (GEE) or Multilevel Logistic (GLMM).
Survival-Link
Time-to-Success.
Pivot to Cox Proportional Hazards to model the probability of event occurrence over time.
Adaptive Technical Safeguards · adaptive safeguards
quasi separation
  • Firth's Penalized Likelihood — Neutralize 'Infinite Odds' when a predictor perfectly predicts the outcome.
  • Exact Logistic Regression — The required strike for tiny samples with rare events.
non linear logits
  • Generalized Additive Models (GAMs) — Model the link function using smoothing splines.
  • Fractional Polynomials — Audit the 'Shape' of the logit-predictor relationship.
overdispersion
  • Quasibinomial GLM — Adjust the standard errors if the binary variance exceeds binomial expectations.
06Adjusted Comparisons

Post-hoc

Group mean comparisons and correction controls (e.g. Tukey HSD, Bonferroni) to protect against Family-Wise Error Rates.

The omnibus test opens the door; post-hoc analysis explores the room.
Forensic Detail
Adjusted Comparisons

Post-hoc pairwise tests defined for this model.

Interpretation Guidelines

In a binary world, the coefficient is just the beginning. Use marginal effects to translate log-odds into the language of probability that practitioners can understand.

07Standardized scale impact

Effect Size

Understanding effect sizes (e.g., Cohen's d, Partial Eta-Squared) and clinical impact benchmarks.

Significance is noise. Magnitude is the signal. Measure the impact, not just the probability.
Impact Magnitude

OR = exp(β). OR=1: no effect. OR>1: positive association (predictor increases odds). OR<1: negative association (predictor decreases odds). OR=2 means odds double; OR=0.5 means odds halved. ALWAYS report 95% CI. Interpret OR in context: 'Each 10-year age increase → OR=1.05^10=1.61 (61% odds increase)'

Analogous to OLS R² but not proportion of variance explained. McFadden R²: 0.2-0.4 indicates excellent fit. Nagelkerke R²: 0-1 scale, closer to OLS R². Cox-Snell R²: max < 1. Use for model comparison, not standalone interpretation

Area under ROC curve. 0.5 = random guessing, 0.7-0.8 = acceptable, 0.8-0.9 = excellent, >0.9 = outstanding discrimination. Represents probability that model ranks random positive case higher than random negative case

Sensitivity (recall, TPR): P(predict 1 | true 1). Specificity (TNR): P(predict 0 | true 0). PPV (precision): P(true 1 | predict 1). NPV: P(true 0 | predict 0). Accuracy: overall correct. Trade-off between sensitivity/specificity depends on threshold and costs of false positives vs. false negatives

Recommended Metric: Odds ratios with 95% CI for predictors; AUC for overall discrimination; sensitivity/specificity at clinically meaningful threshold
Small
0.2
Medium
0.5
Large
0.8
0.50
Odds ratios with 95% CI for predictors; AUC for overall discrimination; sensitivity/specificity at clinically meaningful threshold
Recommended Measure
5
Available Metrics
ReportUse Odds ratios with 95% CI for predictors; AUC for overall discrimination; sensitivity/specificity at clinically meaningful threshold to represent clinical impact magnitude.
08Statistical Power

Sample Size

Guidelines for minimum sample requirements and power analysis parameters.

An underpowered study is an ethical failure. Respect the data by collecting enough of it.
Power Protocol
Floor Requirements

The 'EPV-10' Mandate: A minimum of 10 'Events' (the rarer binary outcome) per predictor is essential. Regression on probability collapse mathematically if the event-to-variable ratio is too low.

Effect SizeParametersRequired n
Small EffectOdds Ratio = 1.5 (Small)n ≈ 680 total
Medium EffectOdds Ratio = 2.5 (Medium)n ≈ 140 total
Large EffectOdds Ratio = 4.0 (Large)n ≈ 60 total
Key considerations

Separation Error Strike: If N is small and a predictor perfectly predicts the outcome (e.g., all treated participants succeed), the model will collapse (Infinite Odds). Always ensure a robust 'Spread' across all cells of the logit grid.

G*Power StrategyBenchmark: Z-tests → Logistic Regression. Parameters: Binary Predictor (p=0.5), Baseline Probability = 0.2, α = .05, Power = .80. Note: Logistic power is dictated by the density of the rarest outcome, not just the total N.
09APA narrative blueprint

Reporting

How to compile statistical results into publication prose matching APA and journal style guides.

The Beta coefficient is the currency of change. Interpret it in real-world units, not just standardized abstractions.
Narrative Arc
Worked APA paragraph example
A logistic regression was conducted to predict diabetes diagnosis from age and total cholesterol. Assumptions were met: binary outcome, independence, adequate sample size (EPV=50), no multicollinearity (VIF<1.1), linearity of logit (Box-Tidwell p>.05), no separation. The overall model was significant (χ²(2)=87.3, p<.001). Model fit was good (Nagelkerke R²=.35, AUC=0.82, Hosmer-Lemeshow p=.42). Age was a significant positive predictor (OR=1.05, 95% CI [1.03, 1.07], p<.001): for each 10-year increase, diabetes odds increased 61%. Cholesterol was also significant (OR=1.01, 95% CI [1.01, 1.02], p<.001): for each 50 mg/dL increase, odds doubled. The model achieved 78% accuracy, 82% sensitivity, and 75% specificity at optimal threshold (0.48). Findings support age and dyslipidemia as diabetes risk factors.
Reusable template

A logistic regression was conducted to predict binary outcome from list predictors. State assumption checks and how violations handled. The overall model was significant/non-significant (χ²(df) = X.XX, p = .XXX), indicating interpretation. Model fit was good/acceptable/poor (Nagelkerke R² = .XX; AUC = .XX; Hosmer-Lemeshow p = .XX). For each significant predictor: Predictor name was a significant positive/negative predictor (OR = X.XX, 95% CI X.XX, X.XX, p = .XXX), indicating substantive interpretation of OR. The model achieved X% accuracy, X% sensitivity, and X% specificity at threshold X.XX. Conclude with interpretation in context.

Essential statistics to report
  • Overall model test: χ² with df, p-value
  • Pseudo-R² (at least one: McFadden, Nagelkerke, or Cox-Snell)
  • AUC with 95% CI
  • For each predictor: OR, 95% CI, p-value (from Wald test or LR test)
  • Classification metrics at stated threshold: accuracy, sensitivity, specificity
  • Hosmer-Lemeshow goodness-of-fit p-value
  • Sample size and EPV
  • Statement about assumption checks (especially separation, linearity of logit, VIF)
10Exhibit Builder

Manuscript Lab

Copy standard summary tables and forensic reporting grids to outline analysis details.

Table 1: Logistic Regression Predicting Treatment Success
PredictorB (Log-Odds)SEWald χ²pOR (Odds Ratio)95% CI (OR)
Age-0.040.024.0.0450.96[0.92, 0.99]
Dosage (mg)0.050.0125.0< .0011.05[1.03, 1.07]
Comorbidity (Yes)-1.200.457.1.0080.30[0.12, 0.72]
Note. Outcome: Success (1) vs. Failure (0). N = 150. Model χ²(3) = 45.2, p < .001.
Comorbidity OR = 0.30A powerful protective effect (or risk reduction). Having a comorbidity reduces the odds of success by 70% (1 - 0.30).
Dosage OR = 1.05Small but scalable. Every 1mg increase raises success odds by 5%. A 20mg increase would effectively double the odds ($1.05^{20}$).
Header glossary

The Risk Multiplier. OR > 1 increases likelihood of event; OR < 1 decreases it. OR = 1 means no effect.

The Mathematical Engine. Coefficients in the logit scale. Hard to interpret directly, which is why we convert to OR.

The Coefficient Test. Tests if the individual predictor is significantly different from zero.

11Algorithmic Logic

Command Center

Syntax libraries and function parameters for executing calculations in stats packages.

Code your model to handle residuals. The errors tell you what your model missed.
Execution Engine
# 1. Fit Logistic Model
model <- glm(success ~ age + dosage + comorb, data = df, family = binomial)

# 2. Extract Odds Ratios with CIs
parameters::model_parameters(model, exponentiate = TRUE)
Library stack
R
glmparametersperformance
Python
statsmodelssklearn
Elite Forensic Strike

Accuracy is not enough. You must report 'Pseudo-R²' (McFadden/Nagelkerke) to quantify how well the model explains the outcome variability.

# Comprehensive Model Fit Audit
performance::performance(model)

# Pseudo R-squared Dashboard
DescTools::PseudoR2(model, which = c('McFadden', 'Nagelkerke'))
12The Over-adjustment Trap

Common Mistakes

Analytical caveats and corrections to maintain modeling integrity.

Wisdom is learning from the failures of others. Anticipate the error before it occurs.
Defensive Logic
Why it's wrong
Odds ratio (OR) ≠ relative risk (RR) except when outcome is rare (<10%). OR overestimates RR for common outcomes. Example: If outcome prevalence is 50% and OR=3, RR≈2 (not 3). OR is symmetric (OR for 0→1 is 1/OR for 1→0), but RR is not. Saying 'OR=2 means twice the risk' is wrong for common outcomes; it means twice the odds, which is not the same
The correction
Report odds ratios correctly: 'OR=2.0 indicates the odds of [outcome] are twice as high for [group A] vs. [group B]' or 'Each 10-year age increase is associated with 1.6 times the odds of diabetes.' If outcome is rare (<10%), you can say OR approximates RR. If you need relative risks, use modified Poisson regression or log-binomial regression instead of logistic regression
Why it's wrong
Complete separation occurs when a predictor perfectly (or nearly perfectly) predicts the outcome: all subjects with predictor=X have outcome=1 (or 0). This causes infinite coefficient estimates (β→∞), inflated standard errors, and non-convergence. Standard logistic regression breaks down. Ignoring warnings and reporting results leads to meaningless conclusions (OR=999999 with SE=10000)
The correction
ALWAYS check for separation: (1) Examine crosstabs of categorical predictors × outcome for cells with 0 counts; (2) Watch for convergence warnings; (3) Look for extremely large coefficients (|β|>15) or SEs (>5). If separation detected: Use Firth's penalized likelihood logistic regression (adds small bias to prevent ∞ estimates; logistf package in R) or exact logistic regression. Combine sparse categories. Report separation and method used. Never drop observations to 'fix' it
Why it's wrong
Logistic regression outputs probabilities; classification requires choosing a threshold (e.g., 0.5). Default 0.5 is arbitrary and often suboptimal, especially for imbalanced outcomes. In medical screening, you may want high sensitivity (low threshold) to catch all cases, accepting more false positives. In fraud detection, you may want high specificity (high threshold) to avoid false alarms. Using 0.5 without justification ignores context and costs
The correction
Choose threshold based on context and costs of errors: (1) Plot ROC curve and identify optimal threshold (Youden index: max(sensitivity+specificity-1)); (2) Use precision-recall curve for imbalanced data; (3) Consider domain-specific costs: medical screening prefers sensitivity, legal decisions prefer specificity; (4) Report metrics at chosen threshold AND justify choice; (5) Consider probability calibration if using for decision-making
Why it's wrong
With imbalanced outcomes (e.g., 5% disease prevalence), a model that predicts 'no disease' for everyone achieves 95% accuracy but is useless (0% sensitivity). Accuracy is misleading when outcome is rare or common. It treats false positives and false negatives equally, ignoring different costs. High accuracy can mask poor sensitivity or specificity
The correction
For imbalanced outcomes: (1) Report sensitivity, specificity, PPV, NPV separately (not just accuracy); (2) Use AUC (evaluates all thresholds simultaneously); (3) Use precision-recall curve (better than ROC for rare outcomes); (4) Report F1-score (harmonic mean of precision and recall); (5) Consider class-weighted models or resampling (SMOTE, undersampling) if severe imbalance. ALWAYS report outcome prevalence
Why it's wrong
Multicollinearity (highly correlated predictors) inflates standard errors, makes coefficients unstable, and makes it impossible to isolate individual predictor effects. You may conclude 'no effect' when there is one, or get implausible coefficient signs. With VIF>10, interpretation is unreliable
The correction
ALWAYS calculate and report VIF for each predictor (use auxiliary linear regressions since VIF not directly available in GLM). If VIF≥10: (1) Remove redundant predictors; (2) Combine correlated predictors; (3) Use penalized logistic (ridge, LASSO); (4) Use PCA. Report VIF: 'All VIF<3, indicating no multicollinearity'
Why it's wrong
With small samples relative to number of predictors (EPV<10), estimates are unstable, standard errors are underestimated (inflating Type I error), overfitting occurs (model fits noise), and predictions don't generalize. You may get 'significant' results that are spurious. Peduzzi et al. (1996) showed EPV<10 leads to biased estimates
The correction
Calculate EPV = min(n_0, n_1) / k (k=number of predictors). Aim for EPV≥10 minimum, ≥20 preferred. If EPV<10: (1) Reduce predictors (use theory, prior research, or univariate screening); (2) Use Firth's penalized likelihood or LASSO (regularizes estimates); (3) Collect more data; (4) Use exact logistic. ALWAYS report EPV in results
Why it's wrong
Logistic regression assumes log-odds change linearly with continuous predictors. If relationship is curved (e.g., U-shaped), model misspecifies relationship, leading to biased coefficients, poor fit, and incorrect predictions. Assuming linearity without checking can miss important non-linear effects
The correction
Test linearity of logit: (1) Box-Tidwell test: add interaction between continuous predictor X and log(X); if significant, linearity violated; (2) Plot empirical logits vs. predictor (categorize predictor, compute log-odds per category, check linearity); (3) Compare models with/without polynomial terms (X²) using AIC/BIC. If violated: add polynomial terms, use splines, or use GAM with logit link. Report linearity checks
Why it's wrong
Model may have good discrimination (AUC) but poor calibration (predicted probabilities don't match observed proportions). Example: model predicts 30% risk but 60% of those patients have the outcome → overconfident predictions. Good discrimination doesn't guarantee good calibration. Using poorly calibrated model for decision-making is dangerous
The correction
Report model calibration: (1) Hosmer-Lemeshow test (p>.05 indicates good fit; compares observed vs. expected across deciles); (2) Calibration plot (plot predicted probabilities vs. observed proportions; should follow 45° line); (3) Report both AUC (discrimination) and calibration. If poor calibration: recalibrate model, add interaction terms, check for non-linearity, or use calibration methods (Platt scaling, isotonic regression)
13Academic Lineage

References

Scholarly lineage and citation keys grounding the statistical framework.

We stand on the shoulders of giants. Honor the source of the method.
Academic Lineage
[1]
Hosmer, D. W., Lemeshow, S., & Sturdivant, R. X. (2013). Applied Logistic Regression (3rd ed.). Wiley.
Definitive textbook on logistic regression. Covers model building, diagnostics, interpretation, goodness-of-fit (Hosmer-Lemeshow test), and extensions
doi: 10.1002/9781118548387
[2]
Peduzzi, P., Concato, J., Kemper, E., Holford, T. R., & Feinstein, A. R. (1996). A simulation study of the number of events per variable in logistic regression analysis. Journal of Clinical Epidemiology, 49(12), 1373-1379.
Established EPV≥10 rule for sample size in logistic regression. Showed EPV<10 leads to biased estimates and inflated Type I error
doi: 10.1016/S0895-4356(96)00236-3
[3]
Van Smeden, M., de Groot, J. A., Moons, K. G., Collins, G. S., Altman, D. G., Eijkemans, M. J., & Reitsma, J. B. (2016). No rationale for 1 variable per 10 events criterion for binary logistic regression analysis. BMC Medical Research Methodology, 16(1), 163.
Updated EPV guidance: EPV≥20 preferred for reliable estimates; EPV 10-20 may be acceptable with careful interpretation
doi: 10.1186/s12874-016-0267-3
[4]
Firth, D. (1993). Bias reduction of maximum likelihood estimates. Biometrika, 80(1), 27-38.
Introduced Firth's penalized likelihood method for logistic regression, which prevents infinite estimates when separation occurs. Widely recommended for small samples or separation
doi: 10.1093/biomet/80.1.27
[5]
Wilson, P. W., Meigs, J. B., Sullivan, L., Fox, C. S., Nathan, D. M., & D'Agostino, R. B. (2007). Prediction of incident diabetes mellitus in middle-aged adults: the Framingham Offspring Study. Archives of Internal Medicine, 167(10), 1068-1074.
Framingham diabetes risk model showing age, BMI, lipids as predictors (basis for Example 1)
doi: 10.1001/archinte.167.10.1068
[6]
Hanley, J. A., & McNeil, B. J. (1982). The meaning and use of the area under a receiver operating characteristic (ROC) curve. Radiology, 143(1), 29-36.
Classic paper on ROC curves and AUC. Showed AUC represents probability that model ranks random positive higher than random negative
doi: 10.1148/radiology.143.1.7063747
In a binary world, probability is the only currency. Respect the Logit, for it is the only path through the non-linear chaos of Yes and No.
The Interpretive Rigor Directive
statminds · LogisticMind reference · v2.2 · updated 2026-01-1715 of 15 sections