Modules

Cheat sheet module 6

Logit (formula sheet)

  • odds = p/(1 - p); log-odds z = ln(p/(1 - p)) = b0 + b1 x1 + …
  • p = 1/(1 + exp(-z)); odds ratio = exp(b)
  • b = change in log-odds, not in percentage points. More units: exp(n b)

R

  • glm(y ~ x1 + x2, family = binomial, data = d)
  • predict(fit, newdata, type = "response") gives probabilities; without type log-odds
  • exp(coef(fit)), exp(confint.default(fit)): odds ratios with Wald interval
  • table(Predicted, Observed): confusion matrix. anova(m1, m2, test = "Chisq"): nested models

Reading output (Accepteert, n = 500)

  • Inkomen 0.0432 (z = 4.52), Koophuis 1.0102 (z = 4.37), Leeftijd -0.0141 (p = 0.06: not significant)
  • exp(b): Koophuis 2.746 [1.746; 4.320] = 2.75 times the odds, not the probability; Inkomen 10 units: exp(0.432) = 1.54; 1 = no effect
  • z = -2.1147 gives p = 0.1077. Without type = “response” you get log-odds
  • Null deviance 577.20, residual deviance 527.77, AIC 535.77 (lower is better)
  • McFadden pseudo-R² = 1 - ln L(model)/ln L(null) = 0.0856: not explained variance

Confusion matrix (threshold τ)

Actual 0 Actual 1
Predicted 0 TN FN
Predicted 1 FP TP

Mind the order. R (table) puts 0 first; practice exam 7.1 puts 1 first. Read the headers first.

  • accuracy = (TP + TN)/n; sensitivity = TP/(TP + FN); specificity = TN/(TN + FP); precision = TP/(TP + FP)
  • Cutoff 0.5: TN 356, FN 115, FP 12, TP 17: accuracy 0.746, sensitivity 0.129, specificity 0.967, precision 0.586
  • Cutoff 0.3: sensitivity 0.576, specificity 0.715. Lower threshold: sensitivity up, specificity down
  • Baseline “always no” = 0.736: accuracy 0.746 is barely better
  • ROC curve and AUC: 0.5 is guessing, 1 is perfect. Train 0.689, test 0.714

Decision rules

  • Skewed classes: accuracy against the baseline, look at sensitivity and precision
  • High cost of a missed case: lower threshold; 0.5 is a habit
  • Overfitting = gap between train and test (0.729 against 0.793: no overfitting). Too few predictors = underfitting
  • Judge on a test set or with cross-validation. More flexible model: less bias, more variance

Pitfalls

  • p = 0.06 is not a 6% chance of H0. Not significant = no evidence, not “no effect”
  • e^0.8 = 2.2: 2.2 times the odds, not 80% more probability
  • Largest coefficient is not the strongest predictor

Question 7.1 (9 p, 200 words)

  1. Coefficients: sign, significance, odds ratio, ceteris paribus
  2. Calculation with formula and numbers
  3. Why accuracy misleads
More
Learn
Practice
Play
Overview
Other courses
BM22Strategic Management
Display
Nederlands
Keyboard shortcuts
Everywhere
Search and jump
CtrlthenK
Search
/
This overview
?
Go to Today
GthenV
Go to Modules
GthenM
Go to Flashcards
GthenF
Go to Practice exams
GthenT
Go to Planner
GthenP
Close
Esc
Flashcards
Flip card
Space
Pick an answer
1–4
Next card
Enter
Questions and games
Pick an answer
1–4
Next
Enter