Skip to main content
Advanced Statistical Methods

Logistic Regression Recap, Odds Ratios, and Principal Component Analysis

Published: 2026-08-11
Level: postgraduate
Audience: Postgraduate students in Advanced Statistical Methods

Prerequisite Knowledge

This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.

Previously Covered in This Subject

  • Logistic regression equation — covered in Lecture 10 (Logistic Regression: When the Dependent Variable Is Dichotomous)
  • Odds and odds ratios — covered in Lecture 10 (Odds, Odds Ratios, and Interpretation)
  • The Simon's coupon example — covered in Lecture 10 (The Simon's Coupon Example: Fitting Logistic Regression in R)
  • Significance testing of the regression — covered in Lecture 9 (Significance Testing of the Regression: T Test and F Test)
  • Chi-square distribution — covered in Lecture 5 (The Chi-Square Distribution)
  • Dimensionality reduction, PCA, and LDA — covered in Lecture 10 (Dimensionality Reduction: PCA and LDA)

12.1 The Logistic Regression Equation and Why It Is Used

12.1.1 The Two Equivalent Forms of the Logistic Model

Hook: Why would anyone build a model whose prediction is squeezed between 0 and 1, when a straight line is so much simpler? Because when the answer we want is a yes/no outcome — 0 or 1 — a straight line predicts nonsense like probabilities of 1.4 or −0.2, and an S-shaped curve cannot.

We open by revisiting logistic regression from the previous session, where it was introduced as an advanced regression technique in comparison with general linear regression and multiple linear regression. The logistic regression equation is usually written in one of two equivalent shapes. The first shape places the exponential in the numerator and the denominator:

The verbal description in class was "e power beta 0 plus beta 1x by 1 plus e power beta 0 plus beta 1x". The second shape is the same expression flipped into a one-over-one-plus-minus-exponential form: "1 by 1 plus e power minus beta 0 plus beta 1x":

Both forms give the identical probability; the second one simply rewrites the exponent with a minus sign. Here is the algebra that shows why , with :

So the two shapes are the same model wearing two different outfits; whichever one appears in an output, the probability it produces is identical. Here is the expected value of the response given the predictor, is the intercept term, and is the coefficient on . The symbol is Euler's number, , the base of the natural logarithm. When the model has several predictors, the exponent simply grows more terms, , and the same structure holds:

12.1.2 Why an S-Shaped Curve for a 0/1 Response

The nature of drives the choice of model: the response must be either 0 or 1, that is, it must be a categorical or classified variable. Whenever the dependent variable behaves like this — a variable built from 0s and 1s — the best model to recommend is this S-shaped curve, the logistic function, and that is exactly where the exponential term shows up. A straight line is the wrong tool for a 0/1 outcome; the S-shape keeps the predicted values trapped between 0 and 1.

Intuition: Think of the logistic curve as a dimmer switch that can never leave the range from off to full. No matter how far you push the knob, the light stays between 0 (off) and 1 (full). The knob position is ; the brightness is , the probability. The mapping works because the exponential in the equation blows up as the exponent grows, but the denominator grows along with it, so the fraction can never reach or pass 1. The analogy stops at one point: a dimmer is roughly linear in the middle and saturates at both ends, and that saturation at exactly 0 and exactly 1 is precisely what a linear switch could not do.

The example below runs the formula at four values of to see that saturation happen with real numbers.

Worked example: plugging numbers into the S-curve. Take a single-predictor logistic model with and , the textbook's illustrative model. Follow the computation at three values of :

At : the exponent is . Then , so

At : the exponent is , and , so

At : the exponent is , and , so

At : the exponent is , and , so .

Sense-check: every answer lies inside (0, 1): 0.001, 0.269, 0.881, 0.9997 — climbing toward 1 as grows, never touching 0 or 1, which is exactly what a probability of a 0/1 outcome needs.

To see the shape, picture the graph with the independent variable on the horizontal axis and the probability on the vertical axis (from 0 to 1). The curve is S-shaped: it starts nearly flat at the bottom left, hugging 0, then rises steeply through the middle, then flattens again at the top right, approaching 1 without ever reaching it. The midpoint of the climb happens where the exponent equals 0, which here means , so : at that point . Two landmarks matter: the curve never crosses the 0 line and never crosses the 1 line (both are asymptotes), and the steepest rise is near the middle. The takeaway: one formula produces every probability from near-0 to near-1, with the steep part reserved for values of near the midpoint.

Scope and assumptions: this S-shaped model is chosen because is a 0/1 variable, and the output is read as a probability. The curve stays in for any real exponent, so no boundary constraints are needed. If the outcome instead takes many ordered categories (low, medium, high), or is a count (0, 1, 2, 3 purchases), the plain two-class logistic model no longer applies. If observations are not independent — for example repeated measurements on the same customer — the model's uncertainty statements stop being trustworthy. Within these limits, the logistic function is the standard recommendation for a binary outcome.

12.1.3 Estimating the Coefficients from the Output

The second important point is how and are estimated; these are the regression coefficients, or logistic regression coefficients. In simple linear regression, partial derivatives give us and directly: we take the derivatives of the error sum of squares, equate them to 0, and solve for closed-form formulas for both coefficients. Logistic regression behaves nonlinearly, so this closed-form route is beyond the scope of the course. To dodge that mathematical difficulty, we estimate and with the help of the output: we read the coefficient estimates straight from the software output and anticipate their values by looking at the numbers there. This description covers the one-predictor structure, ; with more predictors we simply extract each coefficient the same way. In practice the software reaches these numbers by an iterative numerical algorithm (the one R labels "Fisher's scoring", seen in Section 12.7), but the exam skill is reading the finished estimates, not re-running the algorithm by hand.

There is also an interpretation warning attached to these coefficients. It is not the straightforward linear-regression reading — "one unit of increase in , what is the influence on ?" That reading does not carry over cleanly, because the entire expected value of is treated as a probability. The measure we use to interpret the model instead is the odds ratio, covered in Section 12.2.

Pitfalls:

  1. Reading as a linear slope. In linear regression, one unit more in moves the mean of by the slope, everywhere. In logistic regression the effect of one unit depends on where the curve is steep or flat, so no single "unit effect" exists. (The professor flagged exactly this reading in class.)
  2. Fitting a straight line to 0/1 data. The line can predict below 0 or above 1, which cannot be probabilities.
  3. Mixing up the two equivalent forms — writing in the numerator, or losing the minus sign when converting between forms.
  4. Treating as an observed value. is the probability that , not a prediction that equals .

In practice, this is how binary-outcome models are read in business and health analytics: a bank estimating the probability that a credit-card application is approved, a retailer estimating the chance that a mailed coupon is redeemed, a doctor estimating the chance of a disease given test results. Logistic regression is the standard first tool for such yes/no predictions, and its output is interpreted through odds and the odds ratio, the next stop on the arc.

12.1.4 Student Questions and Answers

Q: Can we read the logistic coefficient the same way we read a linear regression slope — a one unit increase in the predictor changes the outcome like the slope changes the mean? A: No — that reading is not straightforward here. In linear regression a one unit increase in changes the mean of by the slope, but in logistic regression the entire expected value of is treated as a probability, squeezed between 0 and 1 by the S-shaped curve. The influence of a one unit increase depends on where you are on the curve: near the middle a small step changes the probability a lot, near the ends almost nothing. We interpret the model with the odds ratio instead, which gives one number per predictor.

That settles the opening question. The takeaway below is the one to carry into the next section.

Recap: logistic regression is the S-curve model for a 0/1 outcome, written in two equivalent exponential forms, with coefficients read from software output rather than solved in closed form. Bridge: because the coefficients cannot be read like slopes, the next section introduces the odds and the odds ratio — the language in which a logistic model is actually interpreted.

12.2 Odds and the Odds Ratio

12.2.1 Odds: Success over Failure

Hook: If a probability of 0.75 means "three times out of four", what does it mean for a horse to be offered "3 to 1" at a race track? That is a different number with the same information — and it is the number logistic regression wants to talk in.

The odds ratio is the very important measure we use to interpret logistic regression. Many software packages print the formula or the value directly in the output; the only real skill on our side is interpreting whatever numerical value we get. The odds of an event are defined as the probability of the success divided by the probability of not having the success:

where is the probability of the event we code as 1. If , the odds are 1, meaning success and failure are equally likely; as climbs toward 1, the odds grow without bound.

Worked example: converting probabilities into odds. For a sequence of probabilities, apply the same step every time: divide by .

For : — success happens once for every three failures, "1 to 3".

For : — success and failure are equally likely, "1 to 1".

For : — success happens three times for every failure, "3 to 1".

For : — "9 to 1".

Sense-check: the odds rise as rises, are exactly 1 at , and blow up as approaches 1 — while a probability can never exceed 1, an odds can be any positive number, which is why the two scales feel different.

A table makes the difference between the two scales visible, with the probability on one side and the equivalent odds on the other:

Probability Odds
0.10 0.111
0.25 0.333
0.50 1
0.75 3
0.90 9

The two numbers carry the same information, but they live on different scales: probability is trapped between 0 and 1, odds runs from 0 to infinity. Pick the odds when you want multiplicative comparisons ("three times as likely in odds"), and stay with probability when you want an answer between 0 and 1.

12.2.2 The Odds Ratio from the Coefficients

For logistic regression there is a simple relationship that lets us anticipate the odds ratio from the coefficient column of the output. To find the odds ratio for , we raise to the power ; for , we raise to the power :

The values are exactly the numbers in the coefficients column of the output. This is the shortcut we use to anticipate the odds ratio without any further computation.

Why ? The relationship is not magic; it falls out of the model algebra. The odds for a given are the ratio of the model's two pieces:

The common denominator cancels, so the odds are simply the exponential inside the logistic equation. Now increase by one unit, and form the odds ratio — the odds at divided by the odds at :

So is exactly the factor by which the odds multiply when increases by one unit, with every other variable held constant. The full log-odds view of the same relationship gets its own derivation in Section 12.6.

Reading the number: an odds ratio of 1 means the two events have identical odds, so the variable changes nothing. An odds ratio greater than 1 means the predictor raises the odds of the event — for example 3 means "three times the odds". An odds ratio below 1 means the predictor lowers the odds — for example 0.5 means "half the odds".

Pitfalls:

  1. Confusing odds with probability. Odds of 3 is not probability 3; it is the ratio of success probability to failure probability.
  2. Confusing the odds ratio with the odds. The odds ratio is a quotient of two odds, not a single event's odds; a single number by itself says nothing about how likely an event is.
  3. Reading "odds ratio = 2" as "probability doubles". The odds double; the probability moves by a different, smaller amount (for example odds 0.4 to 0.8 moves the probability from 0.286 to 0.444).
  4. Forgetting the base of the shortcut. needs the natural exponential, not or a bare .

12.2.3 Where the Numbers Live: Minitab versus R

There is a practical difference between the two software outputs used in class. In the Minitab output the odds ratio is already present, printed in the output itself. In the R output the odds ratio is not printed for you, so you must explicitly calculate it with , taking from the coefficients column and then interpreting that number.

Real-world: this is how working analysts read logistic regression output — Minitab hands you the odds ratio ready-made, while R users compute from the coefficients column as a routine step. The same habit shows up across statistics: medical researchers report odds ratios for risk factors, marketers report odds of redemption per customer segment, and credit teams report how much a predictor multiplies the odds of default.

Recap: odds are success over failure, , and the odds ratio for any predictor is from the coefficient column — the multiplicative change in odds for a one-unit increase. Bridge: with the shortcut in hand, the next section runs the full drill on the Simon Store data with two predictors, where each number in the chain gets computed by hand.

12.3 Worked Example: Simon Store with Two Predictors

12.3.1 The Data and the Estimated Equation

We revisit the Simon Store example introduced in the previous session, where the data has a response and two independent variables and . In this example records whether the customer used a coupon or not (coded 1 for using the coupon, 0 for not using it), is the annual spending of the customer (a continuous variable), and indicates whether the customer holds a Simon credit card (coded 1 for yes, 0 for no). One variable is continuous and the other is categorical, both feeding the single 0/1 response. A pilot study on a small amount of data was worked in the previous session, and we now carry the same problem further.

The study behind the numbers: Simon sent an expensive four-color catalog with a 50-dollar discount coupon to a random sample of 100 customers — 50 cardholders and 50 non-cardholders — and recorded who used the coupon. The first ten rows of the data set look like this (spending in thousands of dollars, so 2.291 means 2,291 dollars):

Customer Annual spending (in thousands) Simon card Coupon used
1 2.291 1 0
2 3.215 1 0
3 2.135 1 0
4 3.924 0 0
5 2.528 1 0
6 2.473 0 1
7 2.384 0 0
8 7.076 0 0
9 1.182 1 1
10 3.345 0 0

From the output we write the estimated logistic regression equation, taking spending as and credit-card holding as . The intercept was written as 2.14 only because of the space constraint on the slide — the coefficient was truncated to two digits — and the coefficients shown are 0.34 for and 1.09 for :

Two clarifications pin the equation down exactly. First, the minus sign belongs to the intercept: the intercept estimate is negative, as printed (full precision ), while both coefficients are positive, 0.34 and 1.09 (full precision 0.342 and 1.099). Second, the two equivalent shapes of the logistic model (Section 12.1) were mixed while reading the equation aloud — "e power minus 2.14 plus 0.34x1 plus 1.09x2" — but the shape written above is the working one, since it reproduces the fitted probabilities in the output. As a check: at , , the exponent is , giving , exactly the table value 0.4102; with the full-precision coefficients , the result is 0.4102 to four digits.

Reading the estimate column. This is what the estimate column, or coefficients column, of the output refers to: whenever we are asked to express or calculate the equation, we focus on that column. The same column feeds the odds-ratio shortcuts from the same output: raising to the power 0.34 gives about 1.41, and with the full-precision coefficients, and — the value the output prints as the odds ratio for the card. The coefficient column in the R output is where both the equation and these odds ratios come from.

Real-world: this exact workflow — a retailer mailing a costly catalog only to customers whose fitted probability of redemption is high — is how direct-mail targeting runs at scale. The fitted probabilities themselves drive the mailing decision (send only above a 0.40 cutoff), while the odds ratios explain to management why the card variable matters.

12.3.2 Worked Computation: Odds for x1 = 2 and x2 = 1

The output table gives the fitted probability for each combination of the predictors. For a customer who spent 2,000 dollars last year (, spending measured in thousands) and has a Simon credit card (), the table value is:

The odds in favor of using the coupon for these customers are then:

So we take the probability of success, 0.4102, divide by the probability of failure, , and land at 0.6956. The odds of using the coupon for a 2,000-dollar spender with a Simon card are about 0.70.

Sense-check the odds. Odds below 1 are expected here, because the probability 0.4102 is below 0.5 — success is slightly less likely than failure, so the odds ratio-style number must come out below 1. Try it on a calculator: 0.4102 divided by 0.5898 is 0.6956, and no other step is involved.

12.3.3 Worked Computation: Odds for x1 = 2 and x2 = 0

Now take the same spending level but a customer without a Simon credit card, . The table gives:

Only this single value changes; everything else in the calculation is the same pattern. The odds in favor of using the coupon here are:

Sense-check. With a probability of only 0.1881, failure outweighs success by roughly four to one, so the odds of about 0.23 make sense: for every 100 successes among such customers, there are about 432 failures. The two computed odds, 0.6956 and 0.2318, are the two ingredients for the odds ratio in the next subsection.

12.3.4 Worked Computation: The Odds Ratio

The odds ratio is nothing but the odds with divided by the odds with :

Interpretation. We interpret this value in plain language: the estimated odds in favor of using the coupon for customers who spent 2,000 dollars last year and have a Simon credit card are about three times greater than the estimated odds in favor of using the coupon for customers who spent 2,000 dollars last year and do not have a Simon credit card. The same conclusion follows from the shortcut , which rounds to about 3 — and with the full-precision coefficient, , which is why the ratio comes out around 3. The two routes agree, which is the built-in consistency of the method.

12.3.5 The Invariance Property of the Odds Ratio

There is a deeper point hiding in this computation: the odds ratio for each independent variable is computed while holding all other independent variables constant — but it does not matter which constant value you hold them at. We did the division with and versus 0 and got about 3. If instead we set , , or (spending of 3,000, 4,000, or 5,000 dollars) and again compare against , the odds ratio still comes out somewhere around 3. It is immaterial what value you take for ; keeping the other variables constant at any level leaves the odds ratio unchanged.

Check it with the output's fitted probabilities for three different spending levels:

Spending Odds Odds Odds ratio
3 0.4948 0.4948/0.5052 = 0.9794 0.2460 0.2460/0.7540 = 0.3263 0.9794/0.3263 = 3.00
4 0.5796 1.3785 0.3148 0.4594 3.00
5 0.6599 1.9403 0.3927 0.6466 3.00

The algebra shows why the constant never matters. The odds at any point equal the exponential in the model, (Section 12.2), so the odds ratio for is:

The terms containing cancel out of the ratio completely — whatever level of spending you hold constant, the result is the same single number .

That is the beauty of the odds ratio and the reason we reach for it when interpreting logistic regression: it gives one stable, comparable number per predictor instead of a reading that shifts with the point on the curve. Whenever you talk about the odds ratio for , you are keeping at some constant; the constant itself is irrelevant to the ratio.

Pitfalls:

  1. Reporting the odds ratio as a probability ratio. The value 3.0 means the odds triple, not that cardholders are three times as likely to use the coupon (the probabilities 0.4102 and 0.1881 are about 2.2 times apart).
  2. Forgetting the "holding constant" clause. The odds ratio for is defined with fixed; it is not a marginal comparison that ignores spending.
  3. Quoting a ratio from truncated coefficients. With the slide's 1.09 the shortcut gives about 2.97; with the output's 1.099 it gives 3.001. Quote the precision you actually used, and expect small rounding wobbles.
  4. Forgetting the direction of the effect. An odds ratio of 3 for the card variable means cardholders have higher odds of using the coupon; a ratio below 1 would mean the opposite.

The whole worked example, in one breath:

Recap: for the two-predictor Simon Store model, the fitted probabilities 0.4102 and 0.1881 become odds 0.6956 and 0.2318, whose ratio is about 3 — the same number the shortcut delivers, and one that stays fixed no matter what value the other variable is held at. Bridge: next, the same exercise with the spending variable dropped, to see what changes when the model has only the credit-card indicator.

12.4 Worked Example: Simon Store with One Predictor

12.4.1 The Estimated Equation from the R Output

To show what changes when a predictor is dropped, the annual spending column was deleted entirely from the Simon Store data and the R code was run again with only the credit-card variable left. The expected output, exactly what R produces, is the basis for the whole exercise. Asked to write the logistic regression equation relating and , we write the estimated equation:

where is the Simon credit-card indicator (1 for having the card, 0 for not having it). The coefficient on in the output is , which is where the 1.02 in the equation comes from: the equation is written with the rounded value 1.02, and every computation in this session uses 1.02 (the coefficient column value 1.0245 rounds to 1.02; a single spoken pass said "1.04x", a slip of the tongue — the printed equation carries 1.02). The intercept estimate is .

With one predictor, the write-versus-estimate distinction is worth keeping straight: to write the equation we use the symbolic form with and ,

and to estimate it we replace those symbols with the values in the output: becomes and becomes 1.02. This two-step habit — symbolic form first, numbers second — is the same drill used for every logistic output in the course.

Write versus estimate. "Write the logistic regression equation" always means the symbolic shape with and (or for two predictors). "Estimate the equation" means substituting the coefficient-column numbers: here and . Getting the two steps separated is the difference between a formula and a fitted model.

12.4.2 Worked Computation: Odds Ratio and Its Interpretation

The only predictor here is the credit-card indicator, so there is one odds ratio to compute. Using the shortcut formula:

You can verify this with a calculator: to the power 1.025 lands at 2.78 (more precisely , and the rounded coefficient gives — either way, about 2.78).

Interpretation and sense-check. The conclusion reads: the estimated odds of making a purchase for a customer who has a Simon credit card are 2.78 times greater than the estimated odds of making a purchase for a customer who does not have a Simon credit card. We can speak only in terms of having the card versus not having the card, because that is the only variable left in the model — which is exactly the point of the odds-ratio interpretation. Sense-check: dropping the spending variable shrank the odds ratio for the card from about 3.0 (in the two-predictor model) to 2.78, because spending and cardholding overlap in what they explain; the card effect is partially absorbed by spending when both are present.

A comparison of the two fitted models shows what one variable's presence changes:

Two-predictor model One-predictor model
Predictors spending , card card only
Intercept
Card coefficient 1.09 1.02
Odds ratio for the card
Interpretation target coupon use given both predictors coupon use given card status alone

When to pick which: use the two-predictor model when you want the card effect with spending controlled; use the one-predictor model when spending data is unavailable — and remember the odds ratio then mixes the card effect with the spending differences between cardholders and non-cardholders.

Pitfalls:

  1. Saying the probability is 2.78 times greater. The odds are 2.78 times greater; the probabilities (about 0.28 without the card, 0.52 with it) are less than twice apart.
  2. Reading the coefficient itself instead of . The coefficient 1.0245 is a log-odds change; only its exponential is the odds ratio.
  3. Extending the conclusion to spending. With one predictor you cannot say anything about spending — the model contains no spending information.
  4. Confusing the two models' odds ratios. 3.0 (two predictors) and 2.78 (one predictor) are different quantities with different conditioning, not a contradiction.

The one-predictor example closes with its summary:

Recap: with only the credit-card indicator in the model, the estimated equation is , and the single odds ratio is the whole interpretation of the model.

Exam note: this exact sequence — write the equation, estimate it from the output, compute the estimated logit, compute the estimated probability, find the odds ratio, state the conclusion — is the drill to practice, since it is the same pattern used for the worked outputs in class (textbook problem TXMA page 737, problem 46 follows it step by step).

12.5 The G Statistic and Model Significance

12.5.1 Null Deviance minus Residual Deviance

Hook: Two fitted logistic models can look great in a spreadsheet — but how do we prove that the predictors actually improve the fit, instead of the improvement being luck of the sample?

Model significance for logistic regression is checked with the G statistic, which is nothing but the chi-square statistic. The formula from R is simply the difference between the null deviance and the residual deviance:

For the single-predictor Simon Store example:

with degrees of freedom 1. The degrees of freedom are not computed here; they come with the output, and for this model it is 1.

What the two deviances mean. The null deviance measures how badly the model fits when it contains only the intercept — no predictors at all. The residual deviance measures how badly the fitted model fits with the predictors included. Both are twice the log-likelihood gap between the model and a perfect fit, so a smaller deviance is a better fit. The difference between them is the amount of poor fit the predictors have removed: the bigger the drop, the more the model's explanatory power. The degrees of freedom for the G statistic equal the number of predictors in the model — 1 for the credit-card-only model, 2 for the model with spending and the card. In the two-predictor output the same test appears as a chi-square of 13.63 with 2 degrees of freedom.

12.5.2 The Decision Rule

The G statistic tests the model as a whole. The hypotheses are the same in spirit as in multiple regression:

  • : all coefficients on the predictors are 0 — the model is no better than the intercept-only model.
  • : at least one coefficient is not 0 — the predictors add real explanatory power.

To conclude at a chosen level of significance whether a significant difference exists, we consult the chi-square distribution table at 1 degree of freedom and validate the value against it. In Minitab, the p-value corresponding to the chi-square value is printed in the output, and we can conclude directly from the p-value. If the p-value is not printed, it is our responsibility to calculate it explicitly and compare. The logic is the same as always: if the p-value is less than , reject the null hypothesis; otherwise accept the null hypothesis.

Worked decision for the Simon Store one-predictor model. Take .

Step 1 — the test statistic: .

Step 2 — degrees of freedom: 1 (one predictor in the model).

Step 3 — the critical value: the chi-square table at 1 degree of freedom and gives 3.841. The rule: reject when .

Step 4 — compare: , so we reject the null hypothesis.

Step 5 — cross-check with the p-value: for a chi-square of 6.07 with 1 degree of freedom the p-value is about 0.014, and , so the same conclusion follows. At the critical value is 6.635 and the p-value 0.014 is not below 0.01 — the conclusion would flip, which shows the level of significance matters.

Conclusion: the credit-card variable contributes significant explanatory power to the model; the model as a whole is significant.

Real-world: this is the significance gate that runs before any logistic result is reported — journals, regulators, and model-review boards all want to know whether the fitted model beats the intercept-only baseline, and the printed p-value next to the chi-square is the standard evidence. The G statistic does for logistic regression the same job that and adjusted do in linear regression output: one number that summarizes whether the model is worth taking seriously.

Pitfalls:

  1. Using the wrong degrees of freedom. It equals the number of predictors, not the sample size; quoting 100 degrees of freedom for a 1-predictor model changes the critical value completely.
  2. Comparing with a t-table. The G statistic follows the chi-square distribution; the decision rule needs the chi-square critical value (3.841 at 1 degree of freedom and ).
  3. Concluding per-variable significance from the overall test. tests the model as a whole; individual coefficients get their own tests in the output.
  4. Reading "accept the null" as "the predictors are useless". Failing to reject only means the evidence in this sample is not strong enough — a different sample or more data may change the verdict.

12.5.3 Student Questions and Answers

Q: In the previous session someone asked what exactly this value is all about — where does the G statistic come from and what does it test? A: It is the chi-square statistic, computed from the R output as the null deviance minus the residual deviance: here , with 1 degree of freedom. It speaks to the significance of the model as a whole, the same job that and adjusted do in linear regression output. If the p-value is not printed next to the chi-square value, look up the chi-square distribution table at 1 degree of freedom; if the p-value is printed, use it. Compare with : reject the null when is less than , accept it otherwise.

The decision rule, distilled:

Recap: the G statistic is the chi-square for the whole model — null deviance minus residual deviance (6.07 here, with 1 degree of freedom) — and significance is decided by comparing the chi-square value or its p-value with the chosen .

Exam note: for the G statistic the decision rule is fixed: compare the p-value with and reject the null when is less than ; accept the null otherwise.

12.6 The Logit Function: When the Log of Odds Is Linear

12.6.1 Deriving the Relationship between Odds and the Model

Hook: A curve that starts flat, rises steeply, and flattens again is nonlinear — so how can we analyze it with the straight-line toolkit we already know? Answer: take the log of the odds, and the S-curve turns into a straight line.

There is an interesting relationship between the odds and the exponent in the logistic regression equation, and it is worth deriving once in full. We know the simple formula for odds is by , and the logistic regression equation gives . If this is , then is , and we substitute both into the odds:

The denominator of the compound fraction flips and the common term cancels between numerator and denominator:

So the odds are exactly the exponential in the logistic equation. Next, take natural logs on both sides; the and the cancel:

This is the step that deserves emphasis: the natural log of the odds in favor of is a linear function of the independent variable. What started as a nonlinear S-curve becomes a straight line once we take the log of the odds.

12.6.2 The Logit Function

That linearized quantity has a name: the logit function. We write it as

and its estimate as , using the fitted coefficients and from the output. So the model is linear in the log-odds space even though it is nonlinear in probability space.

Why the logit is allowed to be any number. The probability lives in , so the odds live in , and the natural log of the odds lives in — the whole real line. That is exactly what a linear expression can produce: any real number, no matter what is. This is the complete chain of transformations in one direction:

and the reverse direction, which is the logit: from a probability, form the odds, take the natural log, and a straight line appears.

This is also why log transformations are used in practice: to convert nonlinear relationships into linear ones and then work out the entire analysis in the linear space. From the logistic equation we get two observations worth keeping: first, what odds are and how to interpret the odds ratio; second, the natural log of odds always equals a linear function of the independent variable — that is what the logit transformation is all about.

Real-world: the logit link is the standard bridge in applied work — analysts fit a linear model to log-odds and convert predictions back to probabilities with the S-curve. Banks, insurers, and medical researchers all report their logistic findings in logit form, because the linear coefficients are easy to compute, to test, and to explain in the log-odds space.

Pitfalls:

  1. Using the wrong logarithm. The logit uses the natural logarithm, base — the one that cancels with . A base-10 log would not cancel and would give a different (wrong) line.
  2. Believing the probability itself is linear. Only is linear in ; stays S-shaped. Graph against and you see a curve, not a line.
  3. Confusing with . The logit is any real number; only after the inverse transform do you get something between 0 and 1.
  4. Reporting the logit as the answer. A fitted logit of is not a probability; it must be inverted before it can be read as one.

12.6.3 Worked Computation: Estimated Probabilities from the Estimated Logit

For the single-predictor Simon Store example, the estimated logit is , straight from the estimated equation. To recover the estimated probability of using the coupon, we invert the logit:

For a customer who does not have a Simon credit card, substitute :

Try that on a calculator: the exponential of minus 0.94 over 1 plus the exponential of minus 0.94 gives about 0.28 (the full-precision output value quoted in the session is 0.279 — the tiny difference is the rounding of the printed coefficients). For a customer who has the Simon credit card, replace with 1:

The full chain in numbers. Coefficient column → estimated logit → probability via the S-curve:

Customer type
No Simon card 0 0.3906 0.28
Simon card 1 1.0833 0.52

Sense-check: the estimated probability of using the coupon jumps from about 0.28 for non-cardholders to about 0.52 for cardholders — the card moves a customer from "probably not" to "slightly more likely than not", consistent with an odds ratio of 2.78 in favor of cardholders. Estimating the probability of the event is always the aim in logistic regression.

12.6.4 Practice Problem: Textbook Page 737, Problem 46

There is another simple example to practice the whole drill: the textbook problem TXMA page 737 problem 46, with one dependent and one independent variable, where the data was collected, the problem worked through, and the output already given. The setting: a bank wants more customers to sign up for payroll direct deposit, and believes the average monthly checking balance predicts who will sign up. The dependent variable is coded 1 if the customer signed up for payroll direct deposit and 0 if not; the independent variable is the average monthly checking balance (in hundreds of dollars).

Work through it in this order: (1) write the logistic regression equation relating and , expressed in terms of and ; (2) estimate the equation by replacing and with the values in the output; (3) compute the estimated logit, as the linear combination; (4) compute the estimated probability; (5) find the odds ratio for and state the conclusion by looking at that single number.

Recap: the logit equals — a straight line in log-odds — and probabilities come back by inverting the logit with the S-curve formula.

Exam note: this exact sequence — write, estimate, estimated logit, probability, odds ratio, conclusion — is the drill to practice, since it is the same pattern used for the worked outputs in class. For practice, the Simon Store data and the bank data are the ones shared for the assignment work.

12.7 Reading the R Output: AIC, Fisher's Scoring, and Significance Stars

12.7.1 AIC and Model Comparison

Hook: The R output prints a jumble of extra numbers below the coefficients — is a big AIC bad? Should we worry when the output says "Fisher scoring iterations: 6"? The answer in both cases is: it depends on context, and this section sorts out which numbers need which context.

The R output carries more values than we used so far, and two of them deserve a brief understanding. The first is the AIC value. AIC is the Akaike Information Criterion — a full form worth remembering. Generally speaking, this value is useful when we compare different models against each other. For an individual model standing alone, there is no good AIC value and no bad AIC value; deciding anything from a single number does not matter. When we do have a comparison among models, AIC takes care of that point: the model with the lowest AIC offers the best fit in terms of the AIC value — if it is lower and lower, it is the better fit. We simply cannot justify anything by looking at one value in isolation. BIC and many other criteria of the same family exist; in time series models, all these metrics are routinely used to justify a choice.

What the criterion is counting. The AIC balances two opposite pressures: a model with more predictors always fits its own data at least as well, but each extra parameter risks fitting noise. AIC scores that trade-off as

where is the maximized likelihood (the probability the fitted model assigns to the observed data — bigger is better, so is a penalty for poor fit) and is the number of estimated parameters (each parameter adds a penalty of 2). The first term rewards fit; the second term punishes complexity. Between two candidate models on the same data, the one with the smaller AIC is the better compromise. BIC is the same idea with a heavier complexity penalty, instead of , where is the sample size — which is why BIC tends to prefer simpler models than AIC on the same data.

Real-world: AIC and BIC are standard tools in model selection, especially in time series work, where candidate models are ranked by these criteria and the lowest wins. The same habit shows up whenever a statistician has to choose among competing specifications — the criteria never judge one model alone, they rank a field of candidates.

12.7.2 Fisher's Scoring and Convergence

The second value is Fisher's scoring, which talks about the convergence of the model. There are two states: converging and diverging. When the output shows "Fisher's scoring needed six iterations to perform the fit", that is the typical count — in general, six iterations are required, and if the count comes in below that, it is well and good. It is a numerical algorithm of sorts, reporting how the model converged on the available data set. For huge data sets, these scores help us talk about convergence behavior.

What Fisher's scoring does. Because the logistic model has no closed-form least-squares solution (Section 12.1), the software has to find the coefficients numerically. Fisher's scoring is the iterative procedure it runs: start with a guess for , measure how far the current fit is from the data, update the guesses in the direction that improves the likelihood, and repeat. "Six iterations" means the procedure cycled six times before the updates became so small that further changes would be meaningless — the estimates had converged. The count is a health report: a small number means the fit settled quickly; a fit that fails to converge (the "diverging" state) means the coefficient estimates are not trustworthy.

Real-world: Fisher's scoring is the iterative numerical procedure statistical software runs to fit logistic-type models; the iteration count is the convergence report that practitioners glance at when fitting on large data. On very large data sets, analysts watch this line because a model that takes hundreds of iterations — or never converges — usually signals a data problem, such as a predictor that separates the two outcome groups perfectly.

12.7.3 Significance Stars and p-values

The significance codes — the three stars, two stars, and so on — are the interpretation with the help of p-values. More stars means more significant: three stars appear when the p-value is much, much smaller. The rule stays the same: compare with . This connects to the previous session's discussion of how to justify model significance in various ways — , adjusted , and the other values in different outputs. In logistic regression, the chi-square value (the G statistic) tells us, to some extent, the significance of the model.

Pitfalls:

  1. Judging a single AIC value. One number in isolation says nothing; only differences between models fitted to the same data carry meaning.
  2. Reading stars as effect size. Three stars say "the p-value is very small", not "the effect is large" — a tiny but precisely estimated coefficient can earn three stars.
  3. Treating "lower AIC" as universally true. AIC compares models on the same data; it is a relative ranking tool, not an absolute quality score.
  4. Ignoring the convergence line. If Fisher's scoring reports divergence, the printed coefficients are meaningless — no stars, p-values, or odds ratios should be quoted from a diverged fit.

12.7.4 Student Questions and Answers

Q: Is a single AIC value good or bad on its own? Can we judge the significance of the model from it? A: Generally speaking, the AIC value is useful only when we have a comparison between different models. For an individual model we have no good or bad AIC value, and deciding on that does not matter. The model with the lowest AIC offers the best fit in terms of the AIC value — if it is less and less, it is the best fit. We cannot justify anything by simply looking at the value in isolation; AIC gets invoked only when models are being compared, and then the lowest one wins.

From the output reading, one summary line:

Recap: AIC ranks competing models — lowest wins, single values mean nothing; Fisher's scoring reports whether the fit converged; stars encode p-value size, and the decision rule stays "compare with ". Bridge: from reading model output we now step back to a different kind of problem — shrinking the data itself — which is where dimensionality reduction begins.

12.8 Dimensionality Reduction: The Big Idea

12.8.1 Definition and Objective

Hook: Imagine a data set with fifty columns, most of them moving in step with each other. Do you really need all fifty, or could a handful of carefully built new columns carry nearly everything the fifty did?

We now switch to a new topic: reducing the dimension of a data set. If the original data is, say, five-dimensional, we may want to move it to three-dimensional, two-dimensional, or one-dimensional space; that transformed data is what the reduction produces. Dimensionality reduction is the transformation of data from a higher dimensional space into a lower dimensional space that retains the meaningful properties of the original data. The phrase to underline is "retains": we should maintain the maximum amount of information present in the original data — not at the cost of that information. Another way to say it: we reduce the size of the data set while keeping as much of the variation as possible. Reducing from higher to lower dimension while preserving this objective is the whole game.

12.8.2 Variation Is Information

A compact identity drives everything that follows: variation, in the statistical sense, is information. Information, in the statistical sense, is variation — the two go together. The amount of information in a data set is nothing but the amount of variation, the maximum variation the set is going to capture. So when we ask how well a reduction performs, we ask how much of the original variation it keeps; keeping the maximum amount of variation is the objective of every reduction technique.

Intuition: Think of a wall painted one flat color versus a wall covered in a mural. The flat wall varies hardly at all — every square meter looks like every other, so it carries almost no information. The mural varies a lot: colors, shapes, edges — and that variation is exactly its information. A data set works the same way. A column that never changes (every customer spends exactly the same) tells us nothing; a column that varies a lot can separate customers into very different groups. The analogy stops at one point: not all variation is equally useful, since random noise is also variation — which is why the next sections care about how much variation each new dimension captures, not merely that it varies.

Put the identity to work as a working rule:

The working rule. The measure of "information retained" by any reduction is the amount of variation kept. If a reduction keeps 95% of the original variation, it has kept 95% of the information, in the statistical sense used here; if it keeps 40%, it has thrown most of the information away. Every dimensionality-reduction technique is judged by this single yardstick: how much of the original variation survives the transformation.

12.8.3 Two Main Techniques: PCA and LDA

Two reduction techniques stand out: Principal Component Analysis (PCA) and Linear Discriminant Analysis (LDA). People working in machine learning and AI call these unsupervised and supervised learning, and the terms are used there all the time; from a mathematical perspective, as a mathematical teacher would put it, these words are not used that frequently — the techniques are mathematical techniques. Anyone with a bit of linear algebra, who knows eigenvalues and eigenvectors, will find the conceptual understanding of PCA and LDA easy, because those tools are exactly what PCA and LDA rest on.

The name of PCA already indicates the idea: you transform your original data into its transformed data, and that transformed data is what we call the principal components. It is another way of thinking, another way of representing the same data set, and the question is how to find those principal components while achieving the objective of maximum retained variation. LDA works the other way: it relates to classification — the same kind of problem as logistic regression, where the response is 0s and 1s. LDA also reduces dimension, but with the help of a line it classifies the two different classes, and there should be a clear separation between those classes. The mathematics of that separation is what LDA provides. In this session we focus on the conceptual understanding of PCA and its numerical illustration, and we keep the math light — just what is relevant and digestible.

PCA LDA
Goal capture maximum variation of the data separate classes as clearly as possible
Needs class labels? No Yes — the classes must be known
Output principal components (new dimensions) a discriminant direction (the separating line)
ML/AI name unsupervised learning supervised learning
Classification ability none — reduces dimension only yes — assigns points to classes

When to pick which: use PCA when the task is compression or visualization of unlabeled data; use LDA when the real task is separating labeled classes and you also want the dimension reduced.

Real-world: in machine learning and AI pipelines, PCA and LDA are the workhorses for shrinking huge feature sets before modeling, known there as unsupervised and supervised dimensionality reduction. In research practice, factor-style methods built on the same linear algebra are used to summarize dozens of survey questions into a few underlying dimensions.

12.8.4 A Bit of History: Hotelling, 1933

PCA is a simple data reduction technique with a long pedigree: way back in 1933, the famous scientist Hotelling pioneered the concept behind principal component analysis. A related test, the Hotelling statistic, is also available in the literature, so the name comes up in more than one place. When you meet "Hotelling" again in multivariate statistics, it is the same lineage: the statistic is named after the same Harold Hotelling whose 1933 paper introduced what we now call principal components.

12.8.5 The Two Perspectives of PCA

PCA is always discussed with two perspectives in view. The first is the lower dimension — the main objective we want to fulfill. The second is the orthogonality of the new dimensions — what we require of the new axes. Both perspectives must be maintained whenever we reduce from a higher dimension to a lower one. What orthogonality means exactly is developed later; for now the two perspectives frame the technique: PCA must (1) land in a lower-dimensional space and (2) do it with new axes that are perpendicular to each other, so that none of the new dimensions repeats information carried by another.

12.8.6 Student Questions and Answers

Q: In machine learning we call these unsupervised and supervised learning — is that the right way to think about PCA and LDA? A: Computer scientists use those labels, and those who work in ML and AI talk about unsupervised and supervised learning. From a mathematical standpoint these are simply mathematical techniques: anyone who knows a bit of linear algebra — eigenvalues and eigenvectors — finds the conceptual understanding of PCA and LDA easy. PCA and LDA are both dimensionality reduction techniques; the word itself indicates that PCA transforms your original data into principal components, while LDA additionally uses the classes to build a separating line.

A few traps to avoid while carrying the big idea forward:

Pitfalls:

  1. Thinking reduction means deleting columns. PCA does not throw away variables; it builds new ones (principal components) from all the originals, then keeps only the best of those.
  2. Equating all variation with signal. Noise is variation too; the techniques rank by amount of variation, and the smallest components are usually mostly noise.
  3. Expecting PCA to separate classes. PCA does not look at class labels at all — for separation you need a classification step, which is where LDA enters.
  4. Forgetting the orthogonality requirement. The new dimensions must be perpendicular; otherwise the second component would re-capture part of the first's information.

The big idea, wrapped up:

Recap: dimensionality reduction moves data from a higher to a lower dimension while retaining maximum variation — because variation, statistically, is information; PCA and LDA are the two headline techniques, with Hotelling's 1933 PCA the elder statesman. Bridge: the next section makes the idea concrete by rotating a two-variable scatter plot into new axes and .

12.9 Principal Component Analysis: The Geometric Idea

12.9.1 The Data Setup: n Observations on Two Variables

Hook: Two measurements per person — height and weight, say — plotted as a cloud of points. The cloud is shaped like a tilted football. Could we describe that cloud with just one number per person instead of two, losing almost nothing?

Consider a simple two-dimensional data plot: a data set with observations and two variables, or two input features. With 15 observations and two attributes we would write the first column as and the second as . The rows are the observations and the columns are called the attributes; the whole data set is an matrix, and a data set laid out in rows and columns is easily handled with matrix algebra — those who know a bit of matrices find this easy.

Plot the same observations as a scatter plot with on one axis and on the other, and inspect the points. The data shows a positive relationship; a strong linear relationship is visibly present among the two variables. To justify that numerically we build a correlation matrix.

Worked example: a small illustrative data set. The session's discussion works with a pattern like this — five customers, two attributes (for instance = annual spending in thousands and = number of store visits):

Customer
1 1 1
2 2 1
3 3 2
4 4 3
5 5 6

Step 1 — means: and .

Step 2 — sum of cross-products around the means:

Step 3 — the two sums of squares:

Step 4 — the correlation coefficient:

Conclusion: the correlation comes out about 0.92 — comfortably inside the "0.9 or 0.8" range anticipated from the plot, a strong positive linear relationship. Sense-check: the points climb from bottom-left to top-right with only mild scatter, so a correlation near 0.9 is exactly what the picture shows.

12.9.2 The Correlation Matrix

The correlation matrix for the two variables has 1s on the diagonal — the correlation of with itself and of with itself is always 1 — and the off-diagonal entries and hold the correlation between variable 1 and variable 2; since correlation between 1 and 2 is one and the same as correlation between 2 and 1, both positions carry the same value:

Correlation always lies between and . We do not know the actual observations here, but common sense from the pattern tells us must be very close to 1 — maybe 0.9 or 0.8. If we explicitly calculate the correlation coefficient we should anticipate a huge value: a strong linear relationship is present, and we can convince ourselves that is around 0.9 given the behavior we witness.

12.9.3 The Covariance Matrix

To capture the amount of variation along and the amount of variation along , we use the covariance matrix. For the two-variable case it looks like:

The diagonal entries are the variances: is the variation of and is the variation of . The off-diagonal entries are the covariance between and . If the population variance is unknown — the usual situation — we replace it with the sample variance , provided the sample is enough to generalize to the population.

Inspect the diagonals. and are not the same, but both capture a substantial amount of variation; we cannot ignore either or , because dropping either one would throw away a substantial share of the variation, and with it a share of the information, in the original data. In the original axes there is no such interesting observation yet — both variables matter roughly equally. (For the worked example above: , , and , so the matrix is symmetric and both diagonals are substantial.)

12.9.4 Rotating the Axes: New Dimensions Z1 and Z2

Now think about the same problem differently: rotate the -axis and the -axis rigidly, anticlockwise, by an angle . As we rotate, we form new axes and — the new dimensions for the data set. Those new dimensions are the transformed data, and they are what we call the principal components. The transformation involves the rotation angle; written for one of them:

The two rotation equations. The spoken description sketched only the first one; the pair is the standard anticlockwise rotation of the axes, and each observation gets a new pair of coordinates:

Every symbol: (theta) is the rotation angle in degrees or radians, and are its cosine and sine, and are the original coordinates of one observation, and are that observation's new coordinates. In words, the first new coordinate is the original weighted by the cosine of the rotation angle plus weighted by the sine of the rotation angle. The check that the new axes are perpendicular: the two rows of the rotation use and , and their dot product is

A dot product of 0 is exactly the perpendicular condition, so the rotated axes stay at right angles to each other for any — the orthogonality requirement of Section 12.8, already visible in the formulas. The equations are best trusted with numbers:

Worked example: rotating one point through 45 degrees. Take the rotation angle , where , and the observation .

So the point , which lies on the 45-degree diagonal, keeps all its length on the new axis and contributes nothing to . A point on the diagonal of the cloud — the direction in which the correlated data stretches — is exactly the point that becomes pure . Sense-check: rotating by 45 degrees lines the new axis up with the diagonal, so points near the diagonal must have near-zero coordinates, and that is what the formulas deliver.

Apply the same rotation to every observation of the worked example and the variation moves. The five points become and : the sample variance along is 6.4 and along is 0.4. In the original data the variation along and along was comparable (2.5 and 4.3). After rotation the variation along is much larger than the variation along — the cloud stretches along and squashes along . Along the direction there is much more information; along the direction there is little.

12.9.5 Reducing Two Dimensions to One

Because information is variation, the comparison of variances decides the reduction. The variation of is greater than or equal to the variation of , so we retain and ignore for further discussion. That is the whole conceptual understanding of the transformation: the same original data, expressed in rotated coordinates, concentrates its variation into the first new axis. For the two-dimensional problem, we compare the variation along with the variation along and conclude whether a single dimension suffices; if it does, that single dimension is the first principal component. In the worked example the single coordinate alone carries 6.4 of the total variation of 6.8 — about 94% — which is the quantitative meaning of "the reduction retains the meaningful properties".

12.9.6 The General Case: From P to M Dimensions

The same logic scales. If there are independent variables, or features, we try to reduce them to , and always . The components are ordered by captured variation: takes the maximum amount of variation from the original data, takes the next best share, the next, and so on. With 10 features, one component may capture most of the variation, and the question becomes whether 2 components are enough or whether more are needed, and how to decide. The mathematics behind all this — how to calculate these variances, how to decide which component contributes more — is handled with the covariance matrix and then eigenvalues and eigenvectors, which are the elementary linear algebra tools we need to strengthen this discussion. The full numerical procedure is worked next session.

Pitfalls:

  1. Mixing up the rotation equations. For an anticlockwise rotation of the axes, and ; swapping the minus sign changes the geometry completely.
  2. Believing is one of the original variables. The principal components are combinations of all variables, not selected columns.
  3. Comparing variation across differently scaled variables. The covariance matrix is measured in the original units; a variable measured in rupees can dwarf one measured in percentages, which is why correlation-based (standardized) versions are common.
  4. Expecting every angle to work. An arbitrary rotation concentrates some variation but leaves the components correlated; the angle that concentrates it fully is the one the eigenvalue computation finds next session.

12.9.7 The Ellipse Intuition: Correlated to Uncorrelated

There is a clean geometric way to see what PCA does. The original data is correlated data; the transformed data is uncorrelated. Think of the data cloud as an ellipse with a major axis and a minor axis. If the major and minor axes do not coincide with the and axes, the variables are correlated with each other. When the major and minor axes coincide with and , the data is uncorrelated. PCA rotates the coordinate system so that the new axes line up with the ellipse's own axes, which turns correlated variables into uncorrelated ones.

The picture to keep in mind. Draw the scatter plot with on the horizontal axis and on the vertical axis, and draw the smallest ellipse that encloses the cloud. When the ellipse is tilted (its major axis runs along the diagonal, say), the tilt means the variables move together — the correlation matrix shows . Draw the new axes and : along the ellipse's long direction, along its short direction, both through the center of the cloud. In the rotated view the ellipse is not tilted anymore — the long axis is horizontal, the short axis is vertical — and in that view the coordinates no longer move together. The rotation angle that achieves this alignment is the angle that makes the transformed data uncorrelated and pours the variation into .

One question is left hanging on purpose: why do we need uncorrelated data — what is the reason behind transforming a correlated data set into an uncorrelated one? Think about it; the reason is developed along with the mathematics next session.

12.9.8 Where the Mathematics Goes

The projections themselves are not worked in detail yet — the and transformations carry trigonometric terms because of the rotation by . The maximum contribution, or the maximum amount of information, and which direction is enough, are all computed with the help of the covariance matrix, eigenvalues, and eigenvectors. That is the math agenda for the next session.

Recap: with two variables, PCA rotates the axes anticlockwise by , producing new dimensions and ; the rotated cloud concentrates its variation into , so a single dimension suffices, and the ellipse picture says the rotation lines the axes up with the cloud's own major and minor axes. Bridge: the angle that achieves the perfect concentration comes from the covariance matrix's eigenvalues and eigenvectors — and the numerical procedure is the very next session. But first: what if the real task is classification? That is where LDA takes over.

12.10 Linear Discriminant Analysis: A First Look

12.10.1 When PCA Is Not Enough

Hook: You have a scatter plot of heights and weights with two kinds of points — buyers and non-buyers — that overlap each other. Compressing the plot to one dimension is easy. But that was never the real question; the real question is which point belongs to which group.

Consider a simple two-dimensional plot of height and weight: is height, is weight, with a few observations. The idea of PCA up to now gives us one motto: take the given two-dimensional plot and reduce it to a single-dimensional plot, projecting all the data points onto one dimension. With some knowledge of PCA we reduce the two-dimensional cloud into one dimension and project the observations onto it. Reducing the dimension is fine, but for this data set the real problem is a classification problem: how best to classify the different groups of points? Looked at closely, the data is not separable — there is no single line that separates the two classes distinctly. This exposes the boundary of PCA: PCA is not a classification technique. It reduces dimensions; it does not assign points to classes.

The picture to hold on to: a scatter plot with height on the horizontal axis and weight on the vertical axis, and two clouds of points (for example, customers who buy a product versus customers who do not). The two clouds overlap — a tall light person and a short heavy person can sit side by side — so no straight line cleanly cuts the plane into a buyers' side and a non-buyers' side. PCA would happily compress this plane into one axis, but the compressed axis mixes the two groups, because PCA never looked at the group labels in the first place.

Real-world: projecting data onto one or two principal components is common practice for visualizing and compressing large data sets, but classification requires a supervised step on top. This is why real pipelines pair a reduction step with a classifier rather than expecting the reduction to do the labeling.

12.10.2 LDA: The Line That Separates the Classes

To separate the two classes we introduce another interesting technique: linear discriminant analysis. The problem is the one anticipated above — the classes are not separable by an obvious line — and LDA is built exactly for it. With the help of a line, LDA classifies the two different classes; there should be a clear separation among them, and the question is which line best classifies the two classes, and what the mathematics behind that line is. LDA relates naturally to everything done so far: it is a classification problem with 0s and 1s, the same territory as logistic regression, but approached through dimension reduction and separation.

The shape of the LDA model. Like PCA, LDA builds a new coordinate from a linear combination of the original variables; unlike PCA, it uses the class labels to build it. The discriminant function has the same linear form as a regression equation,

where is the discriminant score of an observation, the 's are the predictor variables, and the 's are the discriminant coefficients. The coefficients are chosen so that the two classes' scores are pushed as far apart as possible — the separation between the groups is made large relative to the spread within each group. A new observation is then scored on the line and assigned to the class whose side of a cut-off it falls on. That is the "line" the session speaks of: the direction along which the two classes separate most cleanly. PCA also produces linear combinations, but its aim is maximum variation; LDA's aim is maximum separation, which is the whole difference between the two techniques.

A compact view of where each tool in this session belongs:

Logistic regression PCA LDA
Task classify 0/1 via a probability compress, keep variation compress AND classify 0/1
Uses class labels? yes no yes
Key output probability , odds ratio principal components discriminant line + cut-off
Dimension reduction? no yes yes

When to pick which: fit logistic regression when you want probabilities and odds ratios for a binary outcome; use PCA when you have unlabeled data and need fewer dimensions; call on LDA when the classes are labeled, the data is high-dimensional, and both separation and reduction are wanted.

Pitfalls:

  1. Expecting PCA to separate classes. PCA maximizes variation, not separation; two classes can be perfectly overlapping in the direction of maximum variation.
  2. Assuming any separating line will do. The professor's phrasing — "which line best classifies" — is the whole point: LDA is the procedure that picks the best line, not just any line.
  3. Forgetting the labels. LDA without class labels is not LDA; the labels are what steer the coefficients toward separation.
  4. Overpromising separation. "There should be a clear separation among them" is the ideal; with heavily overlapping classes, no linear technique separates perfectly — LDA then minimizes misclassification rather than eliminating it.

12.10.3 What Comes Next

Two things are coming up next session. First, a numerical illustration of PCA with a simple two-dimensional data plot, worked fully to get complete understanding — the same logic extends to huge-dimensional data in software, and you can reproduce the results in any software on your own problems. Second, the introduction of LDA itself. Both draw on a bit of linear algebra: matrix multiplication, how to calculate eigenvalues and their roots, and so on. The material is not in the regular text; it was assembled from different sources and will be shared.

Recap: PCA reduces dimension but never assigns classes, so when the two clouds of points overlap and the task is classification, LDA enters — it finds the line along which the labeled classes separate best, tying the session's arc together with logistic regression's 0/1 problem. Bridge: next session delivers the numerical illustration of PCA with eigenvalues and eigenvectors, and then the full introduction of LDA itself — the material has been assembled from several sources and will be shared with the class.

Exam Guidance Summary

The administrative and revision-relevant points from this session, gathered in one place:

  • Group assignment — 15 marks. Do not neglect or ignore that 15 marks. Submit a single report per team of about eight to nine pages, relevant to the case study, with all the ID numbers of the group members on the first page, submitted where instructed. One data set is provided per team. Adding interesting interpretations beyond the questions posed by the case study is advantageous — it helps you learn and is interesting for us to learn.
  • Assignment logistics. Detailed instructions and the data sets will be uploaded by the 24th. The data sets are simple and come from the text itself.
  • Quizzes. The quizzes carry 5 marks each — 5 for quiz 1 and 5 for quiz 2.
  • Practice problem. TXMA page 737 problem 46: write the logistic regression equation relating and , estimate it, compute the estimated logit, compute the estimated probability, find the odds ratio for , and conclude. The output is already given; go through it and build a working understanding of how to interpret these values and estimate the probabilities.
  • Resources. The Simon Store data and the bank data are shared for practice. The PCA/LDA material is not from the regular text; it will be shared from the sources used.
  • Next session. The numerical illustration of PCA and the introduction of LDA, with eigenvalues and eigenvectors, come in the next session (29th).

Q: Can you elaborate — can the assignment be done by a single member forming a group? A: The main purpose of making your own groups is to get some collaboration between different colleagues. There are 446 registered students in the course; if everyone went with a single member, we would need to provide around 440 different data sets. Only to control the number of groups and the sample size, we decided to go with groups. One data set for the entire team — discuss among yourselves, you can add any other things to the data set, and submit a single report.

Two more administrative questions came up about the report format and the marks:

Q: What is the title of the case study, and what goes on the first page of the report? A: Write the title of the case study and all the ID numbers of your group members on the first page of the report. That is what will be evaluated for the 15 marks — don't neglect or ignore that 15 marks.

And the marks breakdown was asked one more time:

Q: How many marks is the assignment worth, and what about the quizzes? A: The assignment carries 15 marks; the quizzes carry 5 marks each — 5 for quiz 1 and 5 for quiz 2.

Key Industry Applications

The applied side of everything covered in this session, at a glance:

  • Real-world: odds ratios are how logistic regression results are reported and read in applied work; Minitab prints them directly while R users compute from the coefficients column.
  • Real-world: the logit (log-odds) transformation is the standard practical trick for turning nonlinear relationships into linear ones before modeling.
  • Real-world: AIC and BIC are routine model-selection criteria in time series and other applied work — compare candidates, take the lowest.
  • Real-world: Fisher's scoring is the numerical algorithm behind the fitting of logistic-type models in statistical software; its iteration count is the convergence check for large data sets.
  • Real-world: PCA and LDA are the core dimensionality reduction tools in machine learning and AI, where they are known as unsupervised and supervised learning techniques; PCA dates back to Hotelling in 1933, whose name also survives in the Hotelling statistic.
  • Real-world: projecting high-dimensional data onto its first principal components is standard practice for visualization and for feeding downstream classifiers, with classification itself left to techniques like LDA.

ASM Lecture 12 notes · Logistic Regression Recap, Odds Ratios, and Principal Component Analysis

Advanced Statistical Methods· postgraduate· 2026-08-11

Sections Breakdown

112.1 The Logistic Regression Equation and Why It Is Used

The logistic regression equation in its two equivalent exponential forms, why the S-shaped curve is the right model for a 0/1 response, and how the coefficients are read from software output.

212.2 Odds and the Odds Ratio

Odds as success over failure, the odds ratio as e to the power of the coefficient from the output column, and where the numbers live in Minitab versus R output.

312.3 Worked Example: Simon Store with Two Predictors

Full worked drill on the Simon Store two-predictor model: fitted probabilities to odds, the odds ratio of about 3, and the invariance of the ratio to the level the other variable is held at.

412.4 Worked Example: Simon Store with One Predictor

The one-predictor Simon Store model: the estimated equation from the R output, the single odds ratio e to the power 1.0245 equals 2.78, and how the two fitted models compare.

512.5 The G Statistic and Model Significance

The G statistic as null deviance minus residual deviance, the chi-square decision rule with degrees of freedom equal to the number of predictors, and a complete worked significance test.

612.6 The Logit Function: When the Log of Odds Is Linear

Deriving the odds from the logistic equation, the logit as a linear function of the predictor, and recovering estimated probabilities by inverting the logit through the S-curve.

712.7 Reading the R Output: AIC, Fisher's Scoring, and Significance Stars

The rest of the R output: AIC for comparing competing models, Fisher's scoring as the convergence report of the fitting algorithm, and significance stars as p-value size.

812.8 Dimensionality Reduction: The Big Idea

The big idea of dimensionality reduction: variation is information, retaining maximum variation is the objective, and PCA versus LDA as the two headline techniques.

912.9 Principal Component Analysis: The Geometric Idea

PCA's geometric idea: correlation and covariance matrices, rotating the axes into the new dimensions Z1 and Z2, and how a single rotated dimension captures most of the variation.

1012.10 Linear Discriminant Analysis: A First Look

Where PCA stops: overlapping classes need classification, LDA builds the line that separates the labeled classes, and what the next session delivers.

Postgraduate students in Advanced Statistical Methods

Exam Revision Notes

Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.

12.1 The Logistic Regression Equation and Why It Is Used

Must-know: For a 0/1 response, use the logistic S-curve; its two forms e^(b0+b1x)/(1+e^(b0+b1x)) and 1/(1+e^-(b0+b1x)) are identical, and coefficients are read from the output column, never interpreted as linear slopes.

Top pitfall: Reading beta_1 as a one-unit change in the outcome: the whole expected value is a probability squeezed between 0 and 1, so the effect depends on where you are on the curve.

Self-check: What is the probability when the exponent beta_0 + beta_1 x equals 0, and why?

Connects to: 12.2.

12.2 Odds and the Odds Ratio

Must-know: Odds = p/(1-p); the odds ratio for X_k is e^beta_k read from the coefficient column, meaning the factor by which odds multiply for a one-unit increase. Minitab prints the odds ratio; in R you compute e^beta yourself.

Top pitfall: Confusing odds with probability or odds ratio with odds; an odds ratio of 2 means the odds double, not the probability.

Self-check: What are the odds when p = 0.75, and what does the odds ratio e^beta = 1 mean for the predictor?

Connects to: 12.3, 12.6.

12.3 Worked Example: Simon Store with Two Predictors

Must-know: Estimated equation from the coefficient column, e^(-2.14 + 0.34x1 + 1.09x2)/(1 + e^(-2.14 + 0.34x1 + 1.09x2)); odds = p/(1-p); odds ratio = odds(x2=1)/odds(x2=0) = 0.6956/0.2318 ≈ 3, matching e^beta2; the ratio is invariant to the value other variables are held at.

Top pitfall: Reporting the odds ratio as a probability ratio, or forgetting the holding-constant clause; the ratio is about 3 in odds, not in probability.

Self-check: Why does the odds ratio for x2 stay 3.00 when the computation is repeated at x1 = 3 instead of x1 = 2?

Connects to: 12.2, 12.4, 12.6.

12.4 Worked Example: Simon Store with One Predictor

Must-know: One-predictor equation: p-hat = e^(-0.94 + 1.02x)/(1 + e^(-0.94 + 1.02x)) with x the card indicator; write (symbolic beta form) before estimate (numbers from the output); odds ratio = e^b1 = e^1.0245 = 2.78.

Top pitfall: Saying the probability is 2.78 times greater; only the odds are multiplied by the odds ratio.

Self-check: What is the odds ratio and its interpretation when spending is dropped from the Simon Store model?

Connects to: 12.3, 12.6, 12.1.

12.5 The G Statistic and Model Significance

Must-know: G = null deviance - residual deviance = 134.60 - 128.53 = 6.07 with 1 degree of freedom; it tests the model as a whole (like R-squared in linear regression). Compare the chi-square value or p-value with alpha: reject the null when p < alpha.

Top pitfall: Using the wrong degrees of freedom or comparing G with a t-table; df equals the number of predictors and the critical value comes from the chi-square table.

Self-check: At alpha = 0.05 with 1 degree of freedom, do we reject the null when G = 6.07, and why?

Connects to: 12.4, 12.6.

12.6 The Logit Function: When the Log of Odds Is Linear

Must-know: The logit g(x) = ln(p/(1-p)) = beta0 + beta1 x is linear in x; estimated probabilities come from the chain coefficient column -> estimated logit -> y_hat = e^g_hat/(1+e^g_hat): about 0.28 without the card and 0.52 with it.

Top pitfall: Using base-10 log instead of natural log, or reporting the logit itself as a probability; the logit lives on the whole real line, the probability only in (0,1).

Self-check: For the one-predictor Simon Store model, what is the estimated probability of using the coupon for a customer without the card and for a customer with it?

Connects to: 12.2, 12.4, 12.3.

12.7 Reading the R Output: AIC, Fisher's Scoring, and Significance Stars

Must-know: A single AIC value is neither good nor bad; AIC is useful only for comparing models fitted to the same data, and the lowest AIC is the best fit. Fisher's scoring iteration count reports convergence; stars reflect p-value size.

Top pitfall: Judging one AIC value in isolation, or reading significance stars as the size of the effect; stars only encode how small the p-value is.

Self-check: When is a single AIC value meaningful, and what does 'Fisher scoring iterations: 6' tell us?

Connects to: 12.5, 12.1.

12.8 Dimensionality Reduction: The Big Idea

Must-know: Dimensionality reduction = transformation from higher to lower dimensional space retaining meaningful properties; variation is information, so keep maximum variation. PCA (Hotelling, 1933) maximizes retained variation with orthogonal new axes; LDA uses classes to find a separating line.

Top pitfall: Thinking reduction means deleting columns, or expecting PCA to separate classes; PCA ignores class labels entirely.

Self-check: Why is 'variation is information' the yardstick for judging any dimensionality reduction?

Connects to: 12.9, 12.10.

12.9 Principal Component Analysis: The Geometric Idea

Must-know: PCA rotation: Z1 = x1 cos theta + x2 sin theta and Z2 = -x1 sin theta + x2 cos theta; variation concentrates into Z1 (6.4 vs 0.4 in the worked example), so keep Z1; correlation matrix has 1s on the diagonal, covariance matrix S11/S22 are variances; eigenvalue computation comes next session.

Top pitfall: Mixing up the signs in the rotation equations, or expecting an arbitrary rotation angle to fully remove correlation; only the eigenvalue angle aligns the axes with the ellipse.

Self-check: Why does the variation of Z1 exceed that of Z2 after rotating a positively correlated cloud, and what does that decide?

Connects to: 12.8, 12.10.

12.10 Linear Discriminant Analysis: A First Look

Must-know: PCA is not a classification technique; for separating overlapping labeled classes, LDA finds the line (discriminant function Y = b0 + b1X1 + ... + bKXK) that best separates the classes, then assigns points by a cut-off. Next session: numerical PCA and the full introduction of LDA.

Top pitfall: Expecting PCA to separate classes, or thinking any separating line works; LDA picks the best line using the class labels.

Self-check: Why does PCA fail at the classification task, and what does LDA add over PCA?

Connects to: 12.8, 12.9, 12.1.

Exam Guidance Summary

Must-know: Group assignment = 15 marks (one report per team, about eight to nine pages, all group ID numbers on the first page); quizzes = 5 marks each; practice TXMA page 737 problem 46 (write, estimate, logit, probability, odds ratio, conclusion); next session = numerical PCA and introduction of LDA.

Top pitfall: Neglecting the 15-mark group assignment or missing the ID numbers on the first page of the report.

Self-check: How many marks does the group assignment carry, and what goes on the first page of the report?

Connects to: 12.4, 12.6, 12.9, 12.10.

Key Industry Applications

Must-know: Odds ratios and e^beta from the coefficient column are how logistic results are read in practice; the logit turns nonlinear relationships linear; AIC/BIC rank candidate models (lowest wins); PCA and LDA are the workhorses of dimensionality reduction in ML/AI.

Top pitfall: Expecting a single AIC value or a single odds ratio to carry meaning without the right comparison context.

Self-check: How are PCA and LDA referred to in machine learning and AI, and where does the Hotelling name appear?

Connects to: 12.2, 12.7, 12.8.

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.