Logistic Regression
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
- Multiple linear regression — covered in Lecture 9 (multiple linear regression and the multiple coefficient of determination)
- Significance testing of a regression — covered in Lecture 9 (the t-test and F-test for the regression) and Lecture 10 (tests of overall and individual significance)
- Dummy variables for categorical predictors — covered in Lecture 9 (categorical independent variables and dummy variables)
- The logistic regression equation and the 0-to-1 dependent variable — covered in Lecture 10 (logistic regression when the dependent variable is dichotomous)
- The Simmons Stores coupon example and fitting in R — covered in Lecture 10 (the Simon's coupon example)
11.1 From Linear Regression to Logistic Regression
Hook: How do you predict a yes/no answer — will this customer use the coupon, will the bank approve this loan — when the answer can only be 1 or 0? The straight-line models that served us so well for continuous data cannot do it, because a straight line refuses to stay inside the 0-to-1 range.
In the last session we met a new technique for exactly this situation: logistic regression, LR for short. The whole discussion in this session continues that topic. Before we see the new machinery, we first rebuild the regression family we already know, so that the departure point is clear.
11.1.1 The Regression Models We Already Know
Intuition: Think of a linear regression model as a long, straight ruler laid across a scatter plot. The ruler extends forever in both directions. That is fine while the thing we are measuring can take any value on the number line. The moment the outcome becomes a yes/no switch, an infinitely long ruler is the wrong tool — we will see why in a moment.
In a standard regression setup we have one dependent variable (the outcome we want to explain), written , and a set of independent variables (the inputs we use to explain it), say . In ordinary linear regression and multiple linear regression, the dependent variable and all the independent variables are continuous in nature: each can take any value inside an interval. For a problem with one dependent and two independent variables, the model we built has the form
with the error term ignored for the modeling discussion (we treat the disturbance, the part of the model cannot explain, as zero). Writing the same idea for the expected value of :
Every symbol has a job. Here:
- is the dependent variable, the outcome to be predicted;
- are the independent variables, the predictors we feed in;
- (beta-zero) is the intercept — the expected value of when both and are 0;
- are the regression coefficients, often called weights — they tell us how strongly each predictor moves the outcome;
- is the expected value, the long-run average of given the 's.
The interpretation is direct: a one-unit increase in changes by , a one-unit increase in changes by , and so on. If , then raising by one unit raises by 2 units. This straight, constant "change per unit" reading is exactly what we lose in logistic regression.
One variation we discussed earlier concerns the independent variables. When an independent variable is categorical — say a repair problem where a variable is coded with numerical values such as 0 and 1 — the model equation looks the same, but we have to take extra care in the interpretation. With a 0/1 input, a coefficient no longer means "one whole unit of the variable" but "the difference between the two categories." So the family so far covers:
- continuous dependent variables with continuous independent variables;
- continuous dependent variables with categorical independent variables (dummy coding).
In both cases itself stays continuous, and the straight-line logic holds.
11.1.2 A New Problem: a Dependent Variable That Takes Only 0 and 1
Now we flip the situation. Many practical, real-time problems have factors in which the dependent variable itself is categorical. We can decode with either 1 or 0 — think of 1 as "happy" and 0 as "sad", or 1 as "yes, the customer used the coupon" and 0 as "no, they did not". Once the dependent variable is categorical, the whole discussion changes. The way we estimated for linear regression — through the principle of least squares and the derivatives that follow from it — no longer carries over as-is.
Real-world: this setting is called a binary classification problem (you can also call it just a classification problem). It is one of the most common decision problems in business and industry: approve or reject, buy or skip, default or pay, use or not use. For the time being we concentrate only on the binary case, where takes exactly two values, 1 and 0.
When is 1 or 0 with several independent variables, you cannot blindly apply basic linear regression. Two things need care. First, the expression we write for the expected value of must be chosen to suit this kind of data — the formula itself has to respect what can be. Second, we need a model that produces answers inside the only range that makes sense for a probability: between 0 and 1.
11.1.3 Why a Linear Model Breaks Down
Picture the data. If we plot against the independent variables, all the observed values sit on two horizontal lines: the line for customers who used the coupon and the line for those who did not. If we fit any linear regression model to such a plot, there is every possibility that the fitted line will exceed on one side or drop below on the other. That is not acceptable for this problem: the estimate must be captured between 0 and 1, because the answer we are producing is a probability-like quantity that must lie in the interval .
The visual takeaway: on a chart with the independent variable on the horizontal axis and on the vertical axis scaled from 0 to 1, the data appear as two rows of dots — a lower row hugging 0 and an upper row hugging 1. A straight line drawn through that cloud will cut through both rows, but outside the cloud it keeps climbing past 1 or keeps sinking below 0. The curve we need instead starts near 0, rises smoothly, and flattens near 1: the S-shaped curve.
Worked illustration: the straight line stepping out of bounds. To see the failure in numbers, take a tiny artificial linear model with intercept and slope , so
- At : . The model predicts an "expected value" of 2.1 — a so-called probability above 1, which is impossible.
- At : . The model predicts a negative probability, which is equally impossible.
A probability can never be 2.1 and can never be . The linear form does not know this, and nothing in its formula stops it from producing such nonsense. Sense-check: every value of must lie in ; the straight line produced values outside that interval, so the straight line is the wrong shape for binary data.
So the first thing to understand is: what type of model can predict within this range — either exactly 0, exactly 1, or something in between? Ordinary regression cannot do it. We need an S-shaped curve — the function we call the sigmoid function or logistic function — which will be the mathematical expression that takes care of this situation. The logistic function predicts between 0 and 1 no matter what the inputs are.
Scope: The multiple linear regression model applies when the dependent variable is continuous. Its assumptions — an error term centered at 0, constant variance, and (for inference) roughly normal errors — all describe a continuous outcome. When takes only the values 1 and 0:
- the error term cannot be normal, because has only two possible values;
- the variance is not constant — it changes with the probability, shrinking near 0 and 1 and largest in the middle;
- the fitted line crosses the boundaries and .
None of these problems makes the numbers "wrong" in a mechanical sense; the problem is that the output stops meaning a probability. What goes wrong in practice: you report that a customer's chance of using the coupon is 130%, and a decision rule built on that number sends catalogs to the wrong people. This is why logistic regression exists: the model itself must enforce the bounds.
The contrast with linear regression is worth making explicit. The two models serve two different kinds of outcome:
| Dimension | Multiple linear regression | Logistic regression |
|---|---|---|
| Dependent variable | Continuous (any value) | Binary (1 or 0) |
| Form of | Straight line: | S-shaped curve: |
| Range of predictions | to | Always between 0 and 1 |
| What means | Long-run average of | Probability that |
| Estimation | Least squares (closed-form formulas) | Software output (derivation beyond the course scope) |
| Coefficient interpretation | Direct: one unit of changes by | Indirect: through the odds ratio |
When to pick which: use linear regression when the outcome is continuous and unbounded; use logistic regression the moment the outcome is a yes/no variable. The choice is driven by the dependent variable, not by convenience.
Q: Why can't we just run ordinary linear regression when only takes the values 1 and 0? The line will still go through the points. A: Because the fitted line can go above 1 or below 0. A linear model can predict values outside the range that is allowed to have — above 1 or below 0 makes no sense for the probability we are trying to estimate. The sigmoid function keeps the estimate between 0 and 1, which is exactly the constraint this problem demands. In short: the line fits the points mechanically, but it answers the wrong question.
Pitfalls:
- Reading a linear prediction on binary data as a probability. A fitted value of 2.1 is not "210% chance" — it is a sign that the model shape is wrong. Check every prediction against the range.
- Believing "the line goes through the points, so it is fine." The line does pass through the cloud of 0s and 1s — but the constraint that the answer must be a probability between 0 and 1 is part of the problem statement, and the straight line violates it.
- Carrying over least-squares estimation to the nonlinear model. The closed-form derivative formulas for exist only because the linear model is linear in the parameters. The logistic model is nonlinear, and its coefficients come from software, not from those formulas.
- Treating for binary as an ordinary mean. For a 0/1 outcome, the expected value is a probability. We will nail down this vocabulary in the next section, because it drives everything after it.
Recap: A linear model can overshoot the 0-to-1 range, so binary outcomes need a model that is locked between 0 and 1 — the S-shaped sigmoid (logistic) curve. Next we meet the sigmoid in full: its equation, its two equivalent forms, and the all-important reading of as the probability of success.
Real-world: this is not a textbook-only concern. Banks use the exact same setup to predict whether a credit card request is approved () or rejected (); insurers predict whether a claim is fraudulent; telecom operators predict which customers will cancel (churn); email services classify a message as spam (1) or not (0). In every one of these domains the output must be a probability inside , and the decision — approve, investigate, retain, block — comes from acting on that probability. That is the setting logistic regression was built for, and the rest of this lecture develops it on one running example.
11.2 The Logistic Regression Model
Hook: Why does the logistic regression formula contain an exponential term, , at all? Where does that expression come from, and what job is it doing? Once you see what the exponential buys you — a guaranteed 0-to-1 answer — the whole formula becomes easy to remember.
11.2.1 The S-Shaped Curve
The logistic regression model rests on one function: the sigmoid, also called the logistic function. Its graph is an S-shaped curve. The curve starts near 0 for small inputs, rises through a smooth bend, and flattens out near 1 for large inputs. This is exactly the shape we need: the model output can get arbitrarily close to 0 and arbitrarily close to 1, but never steps outside the interval.
Intuition: Picture a heavy door on a hinge. The door's opening angle can never be negative (it cannot be pulled through the wall) and can never pass fully open. However hard you push — and the exponential term is the "push" here — the door gets closer to fully open but never swings past it. In the same way, no matter what values the independent variables take, the logistic expression delivers a number between 0 and 1. The push grows without limit; the door stops at the stop.
Visualize the curve itself: on a chart with the linear combination on the horizontal axis and on the vertical axis (scaled from 0 to 1), the curve begins hugging the 0 line on the left, bends upward through the point — where the input combination is exactly 0, the curve sits exactly at the halfway mark — and flattens against the 1 line on the right. The takeaway from the picture: the curve never leaves the band between 0 and 1, no matter how extreme the inputs are. It approaches 0 and 1 as asymptotes but never touches them.
The framing from the lecture: a normal regression will not work here, so we introduce a mathematical expression that takes care of this situation. Later in the course we come back to the math of why this particular expression is used — what the exponential term is doing and why people decided this is the best-suited model. For now the key point is that this one expression captures the nonlinear S-shaped behavior between and the independent variables.
11.2.2 The Model Equation and Its Two Equivalent Forms
Formalize. For a problem with one dependent and two independent variables, the logistic regression model is written as
where:
- is the base of the natural logarithm, about 2.71828 — the same from growth and decay problems;
- is the intercept;
- and are the regression coefficients (weights);
- are the independent variables;
- the exponent is a single number, call it , built by the familiar linear combination — only then it is fed through the exponential.
Write as a shorthand. Then the model is the compact ratio
Because is always positive (any positive number raised to any power stays positive) and the denominator is always larger than the numerator, the ratio always lands between 0 and 1. That is the whole trick in one line.
Many books write an equivalent form:
Both expressions are the same. To go from the first form to the second, multiply top and bottom by :
Each move is plain algebra: in the numerator; in the denominator the distributes over the two terms, and again. Substituting back in gives the second form exactly. This is the expression we call the logistic regression model (LRM): the relationship between the dependent variable and the set of independent variables, and the model people settled on among many candidate expressions because of the way it handles the 0-to-1 constraint and how well it supports interpretation.
Worked spot-check: the ratio really stays between 0 and 1. Test the compact form at three easy inputs, using :
- At : . A neutral input combination maps to a 50% probability — the midpoint of the S-curve.
- At : .
- At : use the second form: .
Sense-check: the three answers are — all strictly inside . Notice the symmetry: , because the curve at and at sits at mirror-image heights around the midpoint. No matter how large or small the input gets, the output stays in the interval.
Q: Why does the expression have an exponential term in it? Why this particular expression? A: The exponential term is what produces the S-shape. The ratio maps any real input into the interval between 0 and 1. There were many such expressions people considered, but this logistic form is the one that was decided to be best suited — it captures the nonlinear behavior of the data and still lends itself to interpretation. The exponential is the "push": it stretches the middle of the curve so the model can move smoothly from "very unlikely" to "very likely" without ever leaving the legal range.
Scope: The logistic equation applies when the dependent variable is binary (0/1) and we want a probability for the event . The formula itself is unconditional — any real values of the inputs and any real coefficients produce a valid output in . What the formula does not do: it does not decide which independent variables are relevant (that comes from significance testing, section 11.7), and it does not tell us the coefficients (those come from software, section 11.5). For valid inference the observations are assumed to be a random sample, so that the 100 customers are representative of the wider population of catalog recipients — if the sample is biased, the probability estimates inherit that bias.
11.2.3 Interpreting E(y) as the Probability of Success
Here is a point that must be remembered for the entire topic. In multiple linear regression we talk about the expected value of , and can take any value. In logistic regression the main objective — the way we interpret the expected value — is in terms of probability. For that reason we do not simply write ; precisely, we write
the probability that equals 1 given the particular values of the independent variables. And whenever we talk about this expected value, the probability of interest is always the success — the happening. We always represent the event of interest as . This is a fundamental rule of logistic regression: the event of interest is always given a particular set of independent variables, and the whole problem is developed in that context.
Q: Is here just an expected value, like a mean, the way it is in linear regression? A: In logistic regression we do not treat as a generic mean. We read it precisely as the probability of success — given the set of independent variables). The event of interest is always , the happening. That is why we say the expected value is interpreted as probability, and why the probability of interest is always the success.
Exam note: Remember the vocabulary: the event of interest in logistic regression is always , and is interpreted as the probability of that event. Expect this exact wording — "the expected value is interpreted as the probability of success" — to be tested, because it is the single most important reading of the model.
Pitfalls:
- Forgetting the minus sign in the second form. The form has a minus sign in the exponent. Losing it turns the S-curve upside down and explodes the output. Test with : only the correct sign gives 0.269.
- Thinking "exponential" means unbounded growth. In this ratio the exponential appears in both the numerator and the denominator, so the growth is tamed; the output is bounded by 1. The exponential is a push, not an explosion.
- Reading as an average score. For a 0/1 outcome the expected value is a probability of — a number to be compared against thresholds, not averaged like a grade.
- Writing when interpreting the model. The model is built for the success event; the failure probability is its complement , which we meet again when we compute odds.
Recap: The logistic regression model feeds the linear combination through , locking the answer into , and we read that answer as . Next we watch the model behave on a single-variable example with real numbers, where the bounds become visible.
Real-world: this bounded-probability form is why logistic regression is the default model for response and risk scoring across industry. Credit bureaus score the probability that an applicant defaults; banks score the probability of card approval; marketing teams score the probability that a customer responds to a campaign; hospitals score the probability of readmission. In every case the score is a number between 0 and 1 that a decision rule converts into an action, and in every case the S-shape does the same job it does here.
11.3 Behavior of the Model: A Single-Variable Example
Hook: What does a single input change do to a probability? Take a model with only one independent variable and two made-up coefficients, and watch one concrete substitution — — become the number 0.27. The point of the exercise is to feel, not just memorize, how the logistic expression moves.
11.3.1 The Example Model
To see how the model behaves, shrink it to one dependent and one independent variable. Write the dependent variable as and the single independent variable as . Then the expected value of — the probability that equals 1 given — is
where is the intercept and is the regression coefficient (the weight on ), exactly as in the two-variable model but with the second term removed.
Formalize. To make this concrete, replace the coefficients with numerical values: and . The model becomes
Read the two numbers before computing anything. The intercept is strongly negative, so when is small the exponent is a large negative number. A large negative exponent makes tiny, which pushes the whole ratio close to 0. The slope is positive, so every one-unit increase in adds 3 to the exponent — and adding to the exponent multiplies by . That is why the curve rises steeply once grows: the push inside the exponential compounds.
11.3.2 Substituting x = 2
Worked example: probability at . Take and evaluate step by step.
Step 1 — build the exponent. Substitute into :
Step 2 — write the ratio with the computed exponent. The model becomes
Step 3 — evaluate with . Here , so
Step 4 — round and report. The model predicts an expected value (probability) of about 0.27 when .
Sense-check: the answer 0.269 is inside , as it must be; and it sits below the halfway mark 0.5, which makes sense because the exponent is negative () — a negative exponent pushes the probability below 50%.
The walkthrough covers exactly this substitution — first replacing by 2 in the exponent, simplifying to , and then evaluating the ratio to get 0.27.
11.3.3 The Bounds: Output Always Stays Between 0 and 1
Now watch what happens at the extremes. If is close to 0, the exponent is a strongly negative number, the numerator becomes very small, and the expected value is very close to 0. On the other side, as increases, the expected value rises and approaches 1 — but it can never go beyond 1. Take any possible value of in between, and you get an expected value inside the interval .
To see the whole journey in one picture, evaluate the same model across a range of values:
| Exponent | ||
|---|---|---|
| 0 | ||
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 |
Read the column from top to bottom: the probability crawls near 0, accelerates through the middle (from 0.269 at to 0.881 at ), and then flattens near 1. The output is always between 0 and 1, no matter which row you look at.
Scope: this example is an illustration, not a fitted model. The coefficients and were chosen by hand to make the S-shape visible; in real work the coefficients come from data via software (section 11.5). The behavior shown here — output locked in , steep rise through the middle, asymptotes at both ends — holds for any values of the coefficients, because it comes from the structure of the formula itself. What changes with the coefficients is only the position and steepness of the curve: a larger makes the transition from 0 to 1 sharper; a more negative shifts the rise to the right.
This is the beauty of the expression, and the point about how the model captures probability: the more increases, the more the whole function moves toward 1 while always staying between 0 and 1. The model itself enforces the bounds; we never have to patch the answer after the fact.
Visualize the full curve once more, now with numbers: horizontal axis from 0 to 5, vertical axis from 0 to 1. The curve is flat at the bottom near 0 for , climbs through the point , crosses the steepest part between and (the transition from 0.269 to 0.881), and then flattens toward 1. The midpoint of the rise sits near , where the exponent and the probability equals 0.5. The takeaway: the S-curve spends most of its length hugging 0 and 1, and concentrates all its change in a short middle stretch.
Pitfalls:
- Expecting a constant "change per unit" of . From to the probability moves by ; from to it moves by . The change is not constant, because the curve is nonlinear — this is the first taste of why coefficients in logistic regression are not read directly (full treatment in 11.9).
- Reading a value near 1 as "certainty". At the probability is 0.9997 — very high, but still not 1, and never exactly 1. The model never hands out a definite 0 or 1, only very lopsided odds.
- Thinking a negative exponent means a negative probability. is a positive number; the minus sign is inside the exponent, not in front of the whole expression.
Recap: In the single-variable model with and , gives , and every input maps to a value strictly between 0 and 1 — rising toward 1 as grows and falling toward 0 as shrinks. The formula carries its own guardrails. Next we leave the toy model for the real problem: Simmons Stores, where these probabilities decide who receives an expensive catalog.
Real-world: this "S-curve between 0 and 1" behavior is exactly what risk-score models rely on in insurance and lending. A credit scorecard maps features (income, history, balances) through a logistic curve to a default probability; the scorecard is tuned so that the curve is steep in the region where decisions matter most — the middle — and flat where the answer is already clear. Watching the single-variable curve rise through 0.27 → 0.88 is watching that mechanism at its smallest scale.
11.4 The Simmons Stores Example: Problem Setup
Hook: You are a store owner with 5,000 expensive catalogs to send out. Each one costs real money, so you want them to land only in the hands of people who will actually use the coupon inside. How do you decide who deserves one — without guessing?
The whole discussion of logistic regression is carried on a single example, taken from the textbook (the detailed problem description appears around page 727 of the text; the audio rendering of the store name comes through as "Simon", and the textbook example is Simmons Stores).
11.4.1 The Business Problem
The owner of Simmons Stores runs a national chain of women's apparel stores. He has 5,000 expensive copies of a catalog printed; each catalog includes a coupon that provides a 50-dollar discount on purchases of 200 dollars or more. Because the catalogs are expensive, he wants to send them only to customers who have a high probability of actually using the coupon in the catalog.
The core idea: instead of guessing, model the probability. What is the likelihood that a given customer uses the coupon? If we can estimate that probability, we can generalize the decision — which customers are worth the cost of a catalog.
Management believes that two variables might be helpful in predicting whether a customer who receives the catalog will use the coupon: annual spending at Simmons Stores, and whether the customer has a Simmons credit card.
Intuition: Think of the catalog budget as a bucket of seeds, and each customer as a patch of ground. The owner cannot afford to throw seeds everywhere; he wants to plant only where the chance of growth is high. The two clues he uses — how much a customer already spends and whether they carry the store's card — are observable before the catalog is sent. The whole example is about converting those two clues into a probability, and then drawing a line under that probability that says "send" or "don't send".
11.4.2 The Variables
To carry out the study, Simmons conducted a pilot study: a random sample of 100 customers — 50 credit-card customers and 50 customers who do not have a Simmons credit card. Each of the 100 selected customers received the catalog, and at the end of the test period Simmons noted whether the customer used the coupon.
The three variables. The study involves one dependent variable and two independent variables:
- , the dependent variable — whether the customer used the coupon. Coded if the customer used the coupon and if the customer did not use it.
- , annual spending at Simmons Stores — measured in thousands of dollars. A customer who spends 2,000 dollars a year has . This is a continuous variable.
- , the credit-card indicator — whether the customer has a Simmons credit card. Coded if the customer has the card and if not. This is a categorical variable.
Our interest is to predict the possibility of using the coupon — — from the two independent variables and .
Note the mix of variable types: is continuous, is a 0/1 dummy, and — the critical change from everything before — is a 0/1 dependent variable. The unit of measurement of (thousands of dollars) matters for every calculation to come: when a customer "spends 2,000 dollars", the number that enters the model is 2, not 2,000.
11.4.3 The Data Set
The data set has 100 observations of these three columns: spending (), card (), and coupon (). The first ten rows of the pilot study data look like this (annual spending in thousands of dollars):
| Customer | Annual Spending (thousands of dollars) | Simmons Card | Coupon |
|---|---|---|---|
| 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 |
Each row is one customer: how much they spent last year, whether they hold the store card, and whether they used the coupon in the test mailing. Notice that the coupon column contains only 0s and 1s — there is no middle value. The full hundred observations are available to work on from your end, so you can reproduce every output in this lecture yourself.
Scope: this is a pilot study, not the full customer base. The 100 customers were drawn at random with a deliberate balance — 50 card holders and 50 non-card holders — so that both groups are well represented. Any probability or recommendation we build from the model is a statement about this kind of sampled customer; extending it to all 5,000 catalog recipients assumes the sample represents the population of interest. The model estimates the probability of using the coupon; it does not estimate how many catalogs to print or the profit per catalog, which would need cost data on top of the probabilities.
The key point about this data: the dependent variable is categorical in nature, so no ordinary linear or multiple linear regression will work here, and logistic regression is the tool to rely on. The 0/1 coupon column is exactly the kind of the S-curve was built to serve.
Pitfalls:
- Entering spending in dollars instead of thousands. If a 2,000-dollar spender is entered as 2,000 instead of 2, the fitted equation produces nonsense numbers. The variable is defined in thousands of dollars; the substitution goes with 2,000 dollars.
- Swapping the coding of . The event of interest is always (used the coupon). Coding 1 as "did not use" flips every probability into its complement and destroys the interpretation of the model.
- Reading the 50/50 split as the population's real ratio. Half the sample holds the card because the study was designed that way — it is a sampling choice, not an estimate of card ownership in the customer base.
Recap: Simmons Stores has a 100-customer pilot data set with three columns — coupon (, 0/1), spending (, thousands of dollars), card (, 0/1) — and the goal is a probability of using the coupon for each type of customer. Since is categorical, the tool is logistic regression. Next: how the coefficients of the model are found — from software, not calculus.
Real-world: this is direct-mail and catalog targeting, a classic marketing use of logistic regression: spend limited promotional money only on customers whose predicted response probability clears a bar. The same mechanics run modern advertising — email senders, mobile push campaigns, and coupon apps all score each customer's probability of responding and spend their message budgets only on the high-probability segment. The "5,000 expensive catalogs" is simply the budget that forces the targeting decision.
11.5 Estimating the Coefficients with Software
Hook: In linear regression you could compute and by hand with least-squares formulas. For logistic regression, nobody computes the coefficients by hand — you read them off software output. The entire estimation exercise is one short R session plus careful reading of one column.
11.5.1 Why Software, Not Calculus
Purpose. For simple and multiple linear regression, we estimated and with the principle of least squares — taking derivatives and finding closed-form formulas for the coefficients, all because the model is linear in nature. When the model is nonlinear, as in logistic regression, getting the values of is not that straightforward, and the derivation is beyond the scope of the book. We are not going to talk about how those expressions are derived — no partial differential equations, no calculus of the likelihood. The problem this section solves is purely practical: how to get the three numbers that turn the logistic equation into a working probability calculator.
Why is the estimation harder here? In linear regression, minimizing the sum of squared errors leads to linear equations in the coefficients, and those equations have closed-form solutions. In logistic regression, the standard fitting approach (maximum likelihood) leads to nonlinear equations that have no such closed-form solution — software must search for the best values numerically. That is why the textbook and the lecture both route through software output: the search is the software's job, and reading the output is ours.
The important thing to note: the same approach was used even for multiple regression — the tool does the heavy lifting, and we read off the possible values of the coefficients. There is no need for extra effort in extracting them. Software is the tool, not the derivation.
11.5.2 The R Walkthrough: glm() with Family = Binomial
The example is worked in R (open-source software); the textbook shows the Minitab output — either way the numbers are the same, and there is no restriction on which tool you use. R was used here simply because it is open source and shareable.
Inputs and outputs. What goes into the fitting procedure:
- the data set — 100 rows with three columns: (coupon: 1/0), (spending, thousands of dollars), (card: 1/0);
- the model formula — dependent variable explained by and ;
- the family argument —
binomial, because the event is dichotomous in nature: having or not having the event (using or not using the coupon).
What comes out of the fitting procedure:
- the three fitted coefficients — the intercept , and the weights ;
- supporting inference information — deviances, p-values, and (in some outputs) odds ratios, which we use in sections 11.7 and 11.8.
The steps of the walkthrough:
- Prepare the data. Take the Simmons data set, with columns for the customers: (coupon), (spending) and (card).
- Convert the format. Convert the Excel data set into a CSV file, which is the general practice when working in R.
- Read the data into R. Use
read.csvwith thefile.choose()dialog, with the header argument set to true:
LR <- read.csv(file.choose(), header = TRUE)
The loaded data set is called LR.
- Fit the model with the glm function.
glmstands for generalized linear model — the wider family that logistic regression belongs to. The dependent variable is coupon (), the independent variables are spending () and card ():
fit <- glm(y ~ x1 + x2, data = LR, family = binomial)
The family is binomial because of the dichotomous nature of the event — having or not having the event (using or not using the coupon).
- Display the results. Run
summary(fit)to print the full model output.
Trace: what the session looks like. Running the three commands in an R console produces a session like this:
LR <- read.csv(file.choose(), header = TRUE) # pick the CSV file
fit <- glm(y ~ x1 + x2, data = LR, family = binomial)
summary(fit)
The summary(fit) output is a table of coefficients. The rows of the table are the intercept, x1 and x2; the first column of that table is labeled Estimate. Reading down that column gives the three weights — for the Simmons data these come out as −2.14 for the intercept, 0.34 for spending, and 1.09 for card.
Sense-check: the estimates have the right signs and scale for the story. The intercept is negative, so a low-spending, cardless customer starts with a low probability; the positive weights mean more spending and holding the card both raise the probability — matching what the data table already hinted.
There was a small debugging moment in the session: an early version of the command left out the data reference, and that was caught and corrected.
Q: Your glm fit is missing the data argument — the model has no idea where y, x1 and x2 live. A: You are correct, I made a mistake. The call should include the data reference, data = LR, so that y, x1 and x2 are found in the data set. Once the data argument is in place, summary(fit) produces the full output. The lesson carries over to any software: a formula alone is incomplete — the program needs to be told where the variables are stored.
11.5.3 Reading the Estimates: the Estimate Column
Reading the output. The output we need centers on the Estimate column of the coefficients table. That column gives us , and : the first row is the intercept , the row for (spending) is , and the row for (card) is . For this problem the estimates are
The numbers are truncated for space; the full-precision estimates used in the odds-ratio calculations below are −2.146 for the intercept, 0.3416 for spending, and about 1.0987 for card. With these values, the fitted logistic regression equation is
This is how you represent your logistic regression model once you have the weights: the same S-shaped structure as before, with the estimated numbers plugged in for the 's. The only thing addressed at this stage is how to write down the expected value of — that is, the probability that given the two independent variables. There is much more information in the output, and we use the relevant parts for inference: the significance information (section 11.7) and the odds ratio (section 11.8).
Exam note: coefficient estimation by calculus is out of scope. Expect to read directly from the Estimate column of the software output (here −2.14, 0.34, 1.09) and to write the fitted logistic equation — never to derive the estimates. No partial differential equations appear on the exam.
Pitfalls:
- Forgetting the
data = LRargument. Without it, R cannot find the variables and the fit fails or uses the wrong objects. Always tell the software where the variables live. - Reading the wrong column. The coefficients are in the
Estimatecolumn, not the standard-error column or the p-value column. The rows map in order: intercept, , . - Confusing truncated and full precision. The fitted equation is usually written with rounded values (−2.14, 0.34, 1.09), but odds-ratio work uses the full-precision estimates (0.3416, 1.0987). Rounding too early changes the answers downstream.
- Trying to hand-compute the estimates. The nonlinear fitting equations have no closed-form solution; the values come from software. Spending exam time deriving them wastes time and goes beyond the syllabus.
Recap: The coefficients of the logistic model come from software — in R, glm(y ~ x1 + x2, data = LR, family = binomial) followed by summary(fit) — and are read from the Estimate column: −2.14, 0.34, 1.09. Next: plug customer values into the fitted equation to estimate probabilities.
Real-world: glm() with family = binomial in R, and its equivalents in Minitab, SPSS and SAS, are the standard tools for fitting logistic regression in practice. Any of them is fine — and on the exam, any software output is acceptable, as we will see again in section 11.7. In industry, the same commands run inside credit-risk engines, marketing response models, and medical prediction tools; the analyst's job is rarely to fit the model from scratch, but to read the output correctly and explain it — exactly what this section trains.
11.6 Estimating Probabilities from the Model
Hook: The fitted equation is ready — . Time to make it answer the business question: what is the probability that a given type of customer uses the coupon?
We use the fitted equation to estimate the probability of using the coupon for a particular type of customer. The whole exercise is substitution: wherever appears, put the customer's spending in thousands; wherever appears, put their card status. Then simplify the exponent, evaluate the exponential, and read off a probability between 0 and 1.
11.6.1 A 2,000-Dollar Spender Without a Simmons Card
Suppose the customer spends 2,000 dollars annually and does not have a Simmons credit card. In terms of the variables: (spending in thousands) and (no card).
Worked example: probability for .
Step 1 — write the substitution. Replace by 2 and by 0 wherever they appear in the fitted equation:
Step 2 — simplify the exponent.
Step 3 — evaluate the exponential and the ratio. With :
Step 4 — report in words. The estimated value, the of this problem, is about 0.1881 (the same value is stated once in the discussion as 0.1882 — a rounding difference in reading, since the underlying ratio is 0.2318/1.2318).
Sense-check: the answer lies between 0 and 1, and it is well below 0.5 — reasonable for a customer with modest spending and no card, whose starting probability is pulled down by the negative intercept.
In probability terms: about 18% of customers of this type — 2,000 dollars annual spending, no Simmons card — are estimated to use the coupon.
11.6.2 A 2,000-Dollar Spender With a Simmons Card
Now the same customer but holding the card: and . The only difference from the previous calculation is that the card term now contributes instead of .
Worked example: probability for .
Step 1 — write the substitution.
Step 2 — simplify the exponent.
Step 3 — evaluate the exponential and the ratio. With :
Step 4 — report in words. The estimated probability is about 0.4102.
Sense-check: the answer is again inside , and it sits below 0.5 but close to it — the card term visibly lifted the probability, exactly the effect we expect from a positive coefficient.
About 41% of customers who spend 2,000 dollars annually and hold the Simmons credit card are estimated to use the coupon.
11.6.3 Reading the Two Estimates Together
Comparing the two numbers already gives a first inference: the probability of using the coupon is much higher — roughly double — when the customer uses the Simmons credit card. So with the possible combinations with and , we already get a feel for how to comment on the probability of using the coupon.
This can be extended. Since only takes 1 or 0, the interesting variation is annual spending. If spending moves from one level to another, how do the probabilities move? The full tabulated exercise spreads over 1, 2, 3, 4, 5, 6 and 7 (thousands of dollars) for both and :
| Annual spending | 1,000 | 2,000 | 3,000 | 4,000 | 5,000 | 6,000 | 7,000 |
|---|---|---|---|---|---|---|---|
| With card () | 0.3307 | 0.4102 | 0.4948 | 0.5796 | 0.6599 | 0.7320 | 0.7936 |
| Without card () | 0.1414 | 0.1881 | 0.2460 | 0.3148 | 0.3927 | 0.4765 | 0.5617 |
Reading the table: every row rises as spending grows, and the with-card row sits above the without-card row at every spending level. At the lowest end (1,000 dollars, no card) the probability is about 14%; at the highest end (7,000 dollars, with card) it is about 79%. The probabilities spread widely across that range, which is the information a manager needs to decide who gets a catalog.
At this initial level the expression itself guarantees that every lies between 0 and 1 — you cannot get more than that — which is the first big payoff of the logistic form. Compare the two columns at any single spending level and the card effect is visible; trace any row across spending levels and the spending effect is visible. The table is the model doing its job across the whole range of customers.
Scope: these are estimated probabilities for a given profile, valid under the fitted model and the pilot data. Two limits apply. First, the numbers inherit the data: with only 100 customers, each probability is an estimate with sampling error around it — treat 0.1881 as "about 18%", not as exact. Second, the model assumes the effect of spending is the same shape for both card groups (a single for everyone); if card holders and non-holders responded to spending very differently, this one-slope model would misplace some probabilities. Extrapolating beyond the observed spending range (say to 20,000 dollars) is not covered by the data and can be misleading, since the curve flattens near 1 anyway.
Visualize the table as two rising curves on one chart: horizontal axis annual spending (thousands of dollars), vertical axis estimated probability from 0 to 1. The with-card curve starts higher (0.33 at 1,000) and runs above the without-card curve (0.14 at 1,000) at every point; both rise smoothly and gradually steepen across the middle spending range. The vertical gap between the two curves is roughly the same width across the whole range — a hint of the constant card effect that the odds ratio will measure precisely in section 11.8.
Pitfalls:
- Substituting dollars instead of thousands. 2,000 dollars must enter as . Using 2000 changes the exponent by about 680 units and makes the exponential overflow or collapse.
- Forgetting to replace every occurrence. Both the numerator and the denominator contain the same exponent. Substituting into only one of them breaks the ratio and gives a value outside .
- Quoting the odds number as the probability. In the first example the intermediate ratio is not the probability; the probability is . The exponential alone is the odds-like quantity, not the final answer.
- Rounding too early. Using −2.14, 0.34, 1.09 for the fitted equation is fine, but the full-precision estimates (0.3416, 1.0987) are used for the odds-ratio shortcuts later; carry more decimals in your own computations and round at the end.
Recap: Substituting customer profiles into the fitted equation gives probabilities — about 0.1881 (18%) for a 2,000-dollar spender without the card and about 0.4102 (41%) for the same spender with the card — and every output stays between 0 and 1. The probabilities are the raw material for decisions; before relying on them, we must check the model itself for significance. That is the next step.
Real-world: this substitution exercise is the day-to-day job of a response-model analyst. Given a fitted model, a marketing team scores each customer in the database — plug in their spending and card status, read off the probability, rank the list, and mail only the top segment. The same pattern runs in credit: plug in an applicant's features, read off a default probability, and route the application. The probability table above is the scorecard of a small direct-mail campaign.
11.7 Significance Testing in Logistic Regression
Hook: The model gives us probabilities — 18% here, 41% there. But are those differences real, or just noise in 100 customers? Before recommending the model, we need the same validity check we ran for multiple linear regression: overall significance, then individual significance.
11.7.1 Overall Significance: The Chi-Square Test
Before making generalized conclusions, we need the same validity check we did for multiple linear regression: the overall significance of the model, and the individual significance of each independent variable. In multiple linear regression, overall significance used the F distribution and individual significance used the t distribution. In logistic regression the logic is the same, but the statistic changes.
Formalize the overall test. The null statement for overall significance: there is no significant relationship between the two independent variables and the dependent variable. The alternative: there is a significant relationship. Written with the model parameters:
To test this, we rely on a chi-square statistic. If the null hypothesis is true, the sampling distribution of this statistic follows a chi-square distribution with degrees of freedom equal to the number of independent variables in the model — here . The Minitab output gives the chi-square table value directly: the chi-square statistic for this model is 13.63, with a p-value of 0.001. (In the lecture the p-value is stated as "less than 0.05"; the exact output value is 0.001, which is well below the 5% level — the conclusion is the same either way.)
Because the p-value is below the significance level, we reject the null hypothesis and conclude that the overall model is significant: there exists a significant relationship between the two independent variables (jointly) and the dependent variable. That is the first check cleared: the regression model suggested for the Simmons Stores example is fine.
11.7.2 Getting the Chi-Square from R Output
The Minitab output prints the chi-square directly, but the simple R output does not make it quite as straightforward. In the R output, the chi-square value is the difference between the null deviance and the residual deviance:
Worked example: computing the chi-square statistic from R output.
Step 1 — locate the two deviances. R's summary(fit) prints two lines: "Null deviance: 134.60" (the deviance of a model with only an intercept — no predictors) and "Residual deviance: 120.97" (the deviance of the fitted model with and ).
Step 2 — subtract.
Step 3 — compare with the Minitab value. The result is close to — in fact the same as — the chi-square value from the Minitab output (13.63).
Sense-check: the residual deviance is smaller than the null deviance, which is what we want: adding the two predictors must reduce the model's lack of fit, and the size of the drop (13.63) is what the test judges against the chi-square distribution with 2 degrees of freedom. The drop is large enough that the p-value is 0.001.
A small difference separates the two output styles: with the R output you find the chi-square yourself by subtracting the two deviances; with Minitab it is printed for you. The p-value in the R output is also given, and both outputs lead to the same conclusion — the overall model is significant.
11.7.3 Individual Significance of Each Variable
The second check: is spending significant? Is card significant? For that, we refer to the p-values of the individual coefficients, the same p-value approach we introduced earlier for these tests. For each independent variable , the hypotheses are
In the standard output, each coefficient carries its own test statistic and p-value; the textbook's deviance table shows the test for each coefficient as a chi-square value with 1 degree of freedom — equivalent to the normal-based z test the p-value approach relies on. For the Simmons Stores example:
- spending (): chi-square value 7.56, p-value 0.006 — significant at the 0.05 level, so ;
- card (): chi-square value 6.41, p-value 0.011 — significant at the 0.05 level, so .
Both independent variables are statistically significant — both contribute to the model. So before making any further conclusions we have a clear picture: overall significance is established, and both individual variables pass the significance check as well.
Q: Can we use whichever software we like to get the output — even our own outputs rather than the book's? A: Yes, use your own choice. R, Minitab, SPSS, SAS — any tool you are comfortable with. The outputs you used in the exam are fine too; for any of these things you can make use of any such information. What matters is reading the same numbers — estimates, deviances, p-values — correctly from whatever output you have in front of you.
Exam note: the significance story of logistic regression parallels the multiple-regression story — overall significance plus individual significance — but the overall test statistic is the chi-square (13.63 here, p < 0.05, with 2 degrees of freedom), and in R you compute it as null deviance minus residual deviance (134.60 − 120.97). Also remember: any software output is acceptable on the exam — R, Minitab, SPSS, SAS.
A small related story from the grading side: a mistake committed while grading a quiz was described in hypothesis-testing language. Rejecting the null hypothesis when the null hypothesis is true is a type I error — here, giving zero marks for answers that were correct even though the question itself was fine. The reverse mistake — the question is wrong but marks are still given — is a type II error, from the other side. Both are being rectified before the marks are finalized. The story is worth keeping because it maps the formal definitions onto a concrete situation: a type I error is a false alarm (declaring something wrong when it is right), and a type II error is a missed signal (declaring something fine when it is not).
Pitfalls:
- Using the F test for overall significance. In multiple linear regression the overall test used the F distribution; in logistic regression the overall test uses the chi-square statistic. Carrying the F test over is wrong.
- Expecting R to print the chi-square directly. It does not. Compute it as null deviance minus residual deviance; only Minitab-style outputs print it for you.
- Subtracting in the wrong order. The formula is null deviance minus residual deviance (134.60 − 120.97 = 13.63). The reverse order gives a negative number, which cannot be a chi-square value.
- Confusing the two significance checks. The overall test asks whether the variables jointly matter; the individual p-values ask whether each variable matters on its own. Both must pass before recommending the model.
Recap: The model is validated like a multiple regression — overall chi-square test (13.63, p = 0.001, significant) and individual p-values (both significant) — with the chi-square computed in R as null deviance minus residual deviance. The model is now safe to use. Next: the odds ratio, the measure that makes the coefficients interpretable.
Real-world: this two-stage significance check is standard practice in applied modeling. Before a bank deploys a credit scorecard or a hospital publishes a prediction model, the same questions are asked: does the model as a whole beat the intercept-only baseline, and does each feature earn its place? Regulators and audit teams expect exactly this evidence — the chi-square test statistic and per-variable p-values — as part of a model's validation documentation.
11.8 Odds and the Odds Ratio
Hook: The probability table in section 11.6 was a wall of numbers. Wouldn't it be nice if one small number could say the whole story — "card holders are three times as likely, in the odds sense"? That number exists: the odds ratio.
The odds ratio is the key measure for interpreting logistic regression, and it is a core exam concept. To define it, we first need the odds in favor of an event.
11.8.1 Odds in Favor of an Event
Formalize. The odds in favor of an event — a term used in any fundamental book — is the ratio of the chance the event happens to the chance it does not happen:
In simple words: the probability of success divided by the probability of failure. Here denotes the probability of the event, and is the probability of its complement — the event failing to occur. Because the two probabilities exhaust all possibilities, , so the denominator is fixed as soon as the numerator is known.
Check the range of the odds before moving on. If , the odds are — a fair bet, the event and its failure are equally likely. If , the odds are — success is nine times as likely as failure. If is close to 0, the odds are a tiny positive number; if is close to 1, the odds grow without bound. So the odds is a number from 0 to infinity — is never negative and has no upper bound.
Because the event of interest is always in logistic regression, the odds we want are the odds in favor of :
Remember this formula: our interest is the odds in favor of , because that event is what the whole model talks about. That is the logic used for interpreting logistic regression.
11.8.2 Computing the Odds for Both Customer Types
Take the two customer types from the probability estimates. For the customer who spends 2,000 dollars and has the Simmons card (), the estimated probability is 0.4102.
Worked example: odds for the card-holding customer, odds(2, 1).
Step 1 — write the definition with the estimated probability. With :
Step 2 — compute the denominator.
Step 3 — divide.
Sense-check: the odds are less than 1, which is right — with probability 0.4102 below 0.5, failure is still more likely than success, so the odds land below 1.
For the customer who spends 2,000 dollars and does not have the card (), the estimated probability is 0.1881.
Worked example: odds for the cardless customer, odds(2, 0).
Step 1 — write the definition. With :
Step 2 — compute the denominator.
Step 3 — divide.
Sense-check: with probability 0.1881 well below 0.5, the odds are well below 1 — consistent with the cardless customer being much less likely to use the coupon.
Each step is a direct substitution: the probability in the numerator, one minus that probability in the denominator, and the division carried out. The odds for the card-holding customer (0.6956) are much larger than the odds for the customer without the card (0.2318).
11.8.3 The Odds Ratio and What It Means
The odds ratio is simply the ratio of the two odds:
The output gives this as 3.004. The interpretation is the standard one: the estimated odds in favor of using the coupon for a customer who spent 2,000 dollars last year and has a Simmons credit card are about three times greater than the estimated odds in favor of the coupon for a customer who spent 2,000 dollars and does not have a Simmons credit card.
Notice what this buys us. Earlier we sensed from the probabilities that card holders are more likely to use the coupon. Instead of running through the whole probability table, one small number — the odds ratio of about 3 — states the whole observation. This is the very interesting thing: the odds ratio measures the impact of one independent variable on the dependent variable, and it does it with a single digestible number.
Q: Does an odds ratio of 3 mean the probability of using the coupon is three times higher for card holders? A: No. It is the odds — the ratio — that are three times greater, not the probability itself. With probability 0.4102 the odds are 0.6956; multiplying the odds by three does not multiply the probability by three. Check it directly: the cardless customer's probability is 0.1881, and three times 0.1881 is 0.5643 — but the card-holding customer's probability is 0.4102, not 0.5643. The odds ratio multiplies the odds, and that is what is three times greater.
11.8.4 A Shortcut: e to the Power of the Coefficient
A shortcut avoids the whole odds-computation exercise. The estimated odds ratio for a variable is just raised to that variable's coefficient:
Why does this identity hold? It falls straight out of the model, so we can derive it instead of taking it on faith. Write . The odds in favor of are
The second line follows because . So the odds equal the exponential of the linear combination. Now increase by one unit, holding everything else fixed: becomes , and the odds become . The odds ratio is the new odds divided by the old odds:
That is the shortcut, derived: a one-unit increase in a variable multiplies the odds by to the power of that variable's coefficient. For a change of units in one variable, the same argument gives .
Worked example: the shortcut in numbers.
For spending (), the full-precision coefficient is 0.3416, so
For card (), the full-precision coefficient is 1.0987 — the value consistent with the output odds ratio 3.004 and with the 1.09 coefficient stated in the fitted equation. (In the lecture audio the coefficient briefly comes across as "0.1987", a transcription slip: , which does not match the output odds ratio of 3.00. The coefficient attached to card everywhere else in the session is 1.09, whose full precision is 1.0987.) The correct computation is
which reproduces the odds ratio straight from the coefficient.
Sense-check: the two routes agree — the full managerial computation gave 0.6956/0.2318 ≈ 3.00 for card, and the shortcut gives . The spending coefficient gives 1.40: each extra 1,000 dollars of annual spending multiplies the odds of coupon use by about 1.40.
So there are two routes to the same answer: the full managerial table of probabilities and odds (one approach), or the very small shortcut of raising to the regression coefficient. The numbers agree, and the interpretation is the part that matters.
Exam note: the odds ratio is a core exam concept: the definition , the shortcut to the power of the coefficient, and the interpretation — the odds in favor of the event are about three times greater (3.004 for the card variable), not the probability itself.
11.8.5 Properties: Range and Invariance to the Other Variable
Two properties worth noting. First, the odds ratio inherits its range from the odds itself: since odds is divided by , it runs from 0 to infinity. Second, and this is the deep reason the odds ratio is so clean: the ratio is the same no matter which value of the other variable you start from. The odds ratio focuses on a one-unit increase in only one independent variable, keeping the others constant. If you change from 2,000 to 3,000, or 3,000 to 4,000, or 4,000 to 5,000 — the ratio for is still about 3.
Check the invariance with numbers from the table in section 11.6. At : the with-card probability is 0.4948, so the odds are ; the without-card probability is 0.2460, so the odds are . The ratio — the same 3.00 we found at the 2,000-dollar baseline. The invariance is exact, not a coincidence: it follows directly from the shortcut, because the baseline value cancels in the ratio and only the coefficient difference survives.
Q: If we compare customers at a different spending level, say 3,000 dollars instead of 2,000, does the odds ratio change? A: No. The odds ratio takes care of only one independent variable at a time — a one-unit increase in that variable with the other held constant. Because the ratio of odds at two spending levels cancels the spending effect, you get the same odds ratio (about 3) at any baseline level of spending. Compute it for all the other possible values and you anticipate the same odds ratio each time.
Scope: the odds ratio describes a one-unit change in one variable with all other variables held constant. It stays the same at any baseline of the other variables — that is its strength. It does not, on its own, answer questions about multi-unit changes in a continuous variable: for a change of units in , the odds ratio is , not . For the Simmons data, comparing 5,000 dollars against 2,000 dollars of spending (a change of units, i.e. three thousand dollars) gives — the odds for a 5,000-dollar spender are about 2.79 times the odds for a 2,000-dollar spender. The interpretation of the odds ratio also assumes the fitted model is sound: significance checks (section 11.7) must pass before the numbers are quoted.
Visualize the invariance as two parallel odds curves on one chart: horizontal axis annual spending, vertical axis odds of coupon use. The with-card curve ( with the card term included) is a constant vertical multiple of the without-card curve ( without it) — the gap between the curves is exactly the factor at every spending level. One number, one constant gap: that is the whole picture.
Pitfalls:
- Saying "probability is three times higher". The odds ratio multiplies the odds , not the probability . When asked what an odds ratio of 3 means, say "the odds are three times greater" — never "the probability is three times greater".
- Believing the odds ratio changes with the other variable's baseline. It does not. A student who recomputes the card odds ratio at a different spending level and gets 3.00 again has not made an error — that invariance is the point.
- Using the rounded coefficient for the shortcut. and are close but not equal to the output values 1.4073 and 3.004. Use the full-precision coefficients (0.3416, 1.0987) to reproduce the output exactly.
- Treating odds equal to probability. For a probability of 0.5 the odds are 1 — the two scales agree only at that single point. Elsewhere they differ, and the gap grows as the probability moves away from 0.5.
Recap: The odds run from 0 to infinity; the odds ratio compares odds across two customer types and came out at about 3.00 (output 3.004) for the card variable, with the shortcut (1.40 for spending, 3.00 for card) reproducing the same numbers — and the ratio is the same at any baseline of the other variable. The odds ratio is the interpretable face of logistic regression: one digestible number per variable.
Real-world: because of this invariance, odds ratios are how logistic regression results are reported and compared in practice — one number per variable, with a confidence interval. Most packages print a 95% confidence interval next to each odds ratio; for the Simmons model the interval for spending is about 1.09 to 1.81 and for card about 1.26 to 7.17 — neither interval contains 1, which backs up the significance conclusion of section 11.7. In medical studies, odds ratios are the standard currency of reporting treatment effects ("patients on the drug had 2.1 times the odds of recovery"); in marketing, they quantify how much each customer attribute shifts the response odds. Confidence intervals also help when interpreting the odds ratio: an interval straddling 1 signals a variable that might have no real effect.
11.9 Managerial Decision Making with the Model
Hook: A probability of 0.4102 and a probability of 0.1881 — so what? The owner does not want probabilities; he wants a mailing list. The bridge from numbers to decisions is a simple rule: set a probability bar, and send catalogs to everyone who clears it.
11.9.1 Setting a Probability Threshold
The probability estimates are not just numbers — they feed decisions. Suppose management decides, based on experience, that a customer is worth a catalog if the estimated probability of using the coupon is 0.4 or more. That is a benchmark you set yourself: send the catalogs only to those customers whose probability of using the coupon is at least 0.4, regardless of whether they have a credit card.
The decision rule. The rule has three pieces:
- a threshold (the benchmark probability) — here 0.4, chosen by management from experience;
- a scoring step — each customer's profile is substituted into the fitted equation (section 11.6) to get their estimated probability;
- an action step — if the estimated probability is 0.4 or more, send the catalog; if it is below 0.4, do not send it.
The threshold is a business choice, not a statistical one: a lower threshold sends more catalogs (more cost, possibly more revenue); a higher threshold saves money but risks losing coupon users. The model does not choose the threshold — the manager does, and the model's job is to supply the probabilities the rule acts on.
Intuition: the professor's way of framing it: set a benchmark probability like 0.4, then read off which customer types cross the bar — instead of trial and error. Think of a height bar at a fair ride: the rule is "taller than this mark, you ride". The manager posts the bar at 0.4, and the probability table tells him instantly which customer types clear it and which fall short. No guessing, no testing every combination by hand.
With such a rule in place, the question becomes: which types of customers cross the bar?
11.9.2 The Two Recommendations
Reading the probability table (section 11.6) against the threshold 0.4, two recommendations fall out.
Worked decision: applying the 0.4 threshold to the probability table.
Step 1 — write the rule. Send the catalog if and only if the estimated probability of using the coupon is 0.4 or more.
Step 2 — scan the with-card column. At (2,000 dollars spent), the with-card probability is 0.4102 — already above 0.4 — and every higher spending level is larger still (0.4948 at 3,000 dollars, 0.5796 at 4,000 dollars, and so on). So every card holder who spends 2,000 dollars or more clears the bar.
Step 3 — scan the without-card column. At (5,000 dollars), the without-card probability is 0.3927 — just below 0.4. At (6,000 dollars), it is 0.4765 — above 0.4. So for customers without the card, only those spending 6,000 dollars or more clear the bar.
Step 4 — state the two recommendations.
- Recommendation 1: send the catalog to customers who spend 2,000 dollars or more annually and have the Simmons credit card;
- Recommendation 2: for customers without the Simmons card, send the catalog only to those with annual spending of 6,000 dollars and above.
Sense-check: both recommendations are consistent with the rule — every recommended group has an estimated probability of at least 0.4, and every excluded group falls below it. The cardless 5,000-dollar customer (0.3927) misses the bar by less than one percentage point — a borderline case management might revisit, but by the stated rule the catalog does not go out.
Real-world note on the borderline case: the textbook adds that the cardless 5,000-dollar customer sits at 0.3927 — so close to 0.4 that the firm may choose to revise the strategy and include 5,000-dollar-and-above cardless customers anyway. Thresholds are managerial dials, not laws of nature; the model makes the trade-off visible instead of hidden.
This is how the model becomes a targeting policy. Instead of trial and error over every combination of customer attributes, the fitted logistic equation plus a probability threshold produces a clean rule: who gets the catalog and who does not. The odds ratio then serves as the supporting evidence — the single-number justification behind the rule.
11.9.3 Why Interpretation Is Not Direct
Throughout the topic, one contrast recurs: in a simple linear regression, a one-unit increase in maps straight to a change in the dependent variable — you can interpret the coefficient directly. In logistic regression that is not true. The expression is nonlinear because of the exponential term, so you cannot straight away say what a one-unit increase in does to or to the probability. The interpretation is not as direct as the way we assumed in the linear case. That is precisely why the odds ratio exists: it is the simple measure we rely on to talk about the relationship between an independent variable and the dependent variable in this nonlinear model.
Q: Can we interpret the coefficients of logistic regression directly, like in linear regression — one unit increase in raises the expected value by ? A: No — that is the key difference. With the exponential term in the model, the change in the probability from a one-unit increase is not direct; it depends on where you start. The same one-unit increase moves the probability differently at low spending than at high spending (section 11.3 showed the change from 0.018 to 0.269 between and , but from 0.269 to 0.881 between and ). That is why we do not interpret the coefficients directly in logistic regression. We use the odds ratio, to the power of the coefficient, as the measure of the impact of the variable on the outcome: it is the one number that describes the effect cleanly.
Exam note: managerial reasoning with a probability threshold: with the benchmark at 0.4, the recommendations are to send catalogs to customers spending 2,000 dollars or more with the card, or 6,000 dollars and above without it. Be ready to set a threshold, read the probability table, and justify which customer types receive the catalog.
Pitfalls:
- Interpreting a logistic coefficient as a direct change in probability. A coefficient of 0.34 on spending does not mean "one extra thousand dollars raises the coupon probability by 0.34". The effect on the probability depends on the starting point; the odds ratio is the clean statement.
- Forgetting that the threshold is a choice. There is no "correct" threshold in the model. 0.4 was management's benchmark; a different firm could rationally pick 0.3 or 0.5. Always state the threshold along with the recommendation.
- Applying the rule to the wrong group. The two recommendations are group-specific: 2,000 dollars applies only to card holders, 6,000 dollars only to non-holders. Mixing them up sends catalogs to low-probability customers.
- Ignoring the significance check before making decisions. The recommendations in this section rest on the model, and the model was only trusted after the chi-square and individual p-values passed (section 11.7). Quoting decisions from an untested model is bad practice.
11.9.4 Next Steps
The discussion of logistic regression will be concluded in a short span next time, with one or two more worked examples — a new example apart from Simmons Stores — and then some remaining output concepts such as the AIC value. After that, the course moves to dimension-reduction techniques: principal component analysis (PCA) and linear discriminant analysis (LDA). The plan is a conceptual understanding first, then a numerical example to justify and conclude.
A note for preparation: those who already know some linear algebra can anticipate a better understanding of PCA and LDA — behind the fascinating names there is mathematics, and some idea of the math really helps in understanding these techniques in a better way. These are algorithms you have been using as part of machine learning and artificial intelligence courses.
Recap: Probabilities become decisions through a manager-chosen threshold: at 0.4, card holders spending 2,000 dollars or more and non-holders spending 6,000 dollars or more receive the catalog; and because the coefficients cannot be read directly in this nonlinear model, the odds ratio carries the interpretation. The lecture closes with a preview: two more logistic examples and AIC next, then PCA and LDA.
Real-world: this threshold logic is how logistic models run in production across industry. A bank sets a cut-off on its default-probability score and approves above it, denies below it; an insurance company prices or declines policies by a probability cut-off; an online retailer scores every visitor's purchase probability and decides who gets a discount code. The pattern is always the same: model the probability, set the bar by business judgment, act on the crossing — exactly the Simmons Stores exercise at the scale of millions of customers.
Exam Guidance Summary
- Software outputs: on the exam, any software output is acceptable — R, Minitab, SPSS, SAS — whatever you are comfortable with. The outputs you used in the exam yourself are fine; you can use any such information. There is no restriction on which tool's output you read the coefficients from.
- Coefficient estimation by calculus is out of scope. You are expected to read from the Estimate column of the output (here −2.14, 0.34, 1.09) and write the fitted logistic equation, not to derive the estimates. No partial differential equations, no maximum-likelihood algebra.
- Be ready to substitute values into the fitted equation and read off probabilities — e.g., and gives about 0.1881, and gives about 0.4102 — and to convert probabilities into odds with .
- Overall significance in logistic regression uses the chi-square statistic (13.63 here, p < 0.05, with 2 degrees of freedom). In R, compute it as null deviance minus residual deviance (134.60 − 120.97). Individual significance uses the p-values of the coefficients.
- The odds ratio is a core exam concept: definition , the shortcut to the power of the coefficient, and the interpretation — the odds in favor of the event are about three times greater (3.004), not the probability itself. The odds ratio is the same at any baseline of the other variable.
- Managerial reasoning: setting a probability threshold (e.g., 0.4) and deriving recommendations — send catalogs to customers spending 2,000 dollars or more with the card, or 6,000 dollars and above without the card.
- Remember the vocabulary: the event of interest in logistic regression is always — the success, the happening — and is interpreted as the probability of that event.
- Mid-semester exams (regular and makeup) are under evaluation. A quiz marks issue is being corrected: zero marks given for correct answers (a type I error — rejecting the null when the null is true) and the opposite grading mistake (a type II error) are both being fixed before the marks are finalized.
- Next time: two more logistic regression examples and the AIC value, then PCA and LDA — a conceptual understanding followed by a numerical example. Some linear algebra background will help.
Key Industry Applications
- Catalog and direct-mail targeting (Simmons Stores): model the probability that a customer uses a coupon, set a probability threshold, and spend expensive promotional resources only on customers who clear the bar. The manager's rule from the example: catalogs go to customers spending 2,000 dollars or more with the credit card, or 6,000 dollars and above without it.
- Logistic regression as a binary classification tool: problems with a 1/0 dependent variable are framed as classification problems, which is the same modeling idea used across industry for decision and prediction tasks with two outcomes — approve or reject a credit card, flag a transaction as fraud or not, classify an email as spam or not.
- Standard software tooling:
glm()withfamily = binomialin R (open-source), and the equivalent procedures in Minitab, SPSS and SAS, are the everyday tools for fitting logistic regression in practice. R computes the estimates, deviances and p-values; Minitab prints the chi-square and the odds ratio directly. - Odds ratios as the reporting currency: because the odds ratio for a one-unit change in one variable is the same at any value of the other variables, it is the number companies quote when communicating the impact of a predictor — in marketing (how much a feature shifts response odds), in insurance and lending (risk factors), and in medical reporting (treatment effects). Confidence intervals around the odds ratio show whether the effect is credible.
- Dimension reduction (PCA and LDA) is previewed as the next industrial technique: principal component analysis and linear discriminant analysis are algorithms already used in machine learning and artificial intelligence courses, and linear algebra knowledge is the key to understanding them.
ASM Lecture 11 notes · Logistic Regression
Sections Breakdown
Recaps linear and multiple linear regression, and shows why a straight-line model cannot serve a 0/1 dependent variable.
Introduces the sigmoid function and the model E(y) = e^z/(1 + e^z), with E(y) read as the probability of success.
Walks through a single-variable logistic model with real numbers, showing the output always stays between 0 and 1.
Sets up the catalog-targeting case: 100 pilot customers, coupon usage, annual spending, and credit-card status.
Reads the fitted coefficients from software output (glm in R), since the calculus derivation is out of scope.
Substitutes customer profiles into the fitted equation to estimate coupon-use probabilities.
Checks overall significance with the chi-square statistic and individual significance with coefficient p-values.
Defines odds p/(1 - p), derives the odds ratio and the e^beta shortcut, and explains its invariance.
Turns probabilities into decisions with a probability threshold, and explains why coefficients are not read directly.
The exam strategy for logistic regression: software outputs, reading estimates, and the core concepts to master.
Real-world uses of logistic regression: catalog targeting, classification, software tooling, and odds ratios as reporting currency.
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.
From Linear Regression to Logistic Regression
Must-know: A linear model on 0/1 data can predict above 1 or below 0, so binary outcomes need the S-shaped sigmoid function that locks predictions between 0 and 1.
Top pitfall: Reading a straight-line prediction on binary data as a probability (e.g. 2.1 is impossible).
Self-check: Why can't ordinary linear regression be used when y takes only the values 1 and 0?
Connects to: 11.2, 11.9, 9.7
The Logistic Regression Model
Must-know: E(y) in logistic regression is read as the probability of success P(y = 1 | x1, x2); the event of interest is always y = 1, and the model output is always between 0 and 1.
Top pitfall: Forgetting the minus sign in the equivalent form 1/(1+e^-z), or reading E(y) as an ordinary mean instead of a probability.
Self-check: Show algebraically that e^z/(1+e^z) equals 1/(1+e^-z) for z = beta_0 + beta_1 x1 + beta_2 x2.
Connects to: 11.1, 11.3, 11.8
Behavior of the Model: A Single-Variable Example
Must-know: With beta_0 = -7 and beta_1 = 3, substituting x = 2 gives exponent -1, so E(y) = e^-1/(1+e^-1) ≈ 0.27; the logistic output always stays between 0 and 1.
Top pitfall: Expecting a constant change in probability per unit of x — the curve is nonlinear, so the change differs along x.
Self-check: Evaluate E(y) = e^(-7+3x)/(1+e^(-7+3x)) at x = 2 and state the probability.
Connects to: 11.2, 11.5, 11.9
The Simmons Stores Example: Problem Setup
Must-know: Simmons Stores: Y = coupon used (1/0), X1 = annual spending in thousands of dollars, X2 = Simmons card (1/0); a random sample of 100 customers (50 with card, 50 without); Y categorical so logistic regression applies.
Top pitfall: Entering spending in dollars instead of thousands (2,000 dollars must be x1 = 2).
Self-check: What are the three variables of the Simmons Stores study and how is each coded?
Connects to: 11.5, 11.9, 11.2
Estimating the Coefficients with Software
Must-know: Coefficients are read from the Estimate column of software output: beta_0 = -2.14, beta_1 = 0.34 (spending), beta_2 = 1.09 (card); the R call is glm(y ~ x1 + x2, data = LR, family = binomial).
Top pitfall: Forgetting the data = LR argument in glm, or reading coefficients from the wrong column of the output.
Self-check: Which R command fits a logistic regression to the Simmons data, and where in the output are beta_0, beta_1, beta_2 found?
Connects to: 11.6, 11.7, 11.8
Estimating Probabilities from the Model
Must-know: Substitution into the fitted equation: x1 = 2, x2 = 0 gives exponent -1.46 and probability about 0.1881; x1 = 2, x2 = 1 gives exponent -0.37 and probability about 0.4102.
Top pitfall: Substituting dollars instead of thousands, or quoting the intermediate exponential ratio as the final probability.
Self-check: What is the estimated probability of coupon use for a customer spending $2,000 with a Simmons card?
Connects to: 11.5, 11.7, 11.8
Significance Testing in Logistic Regression
Must-know: Overall significance: chi-square = null deviance - residual deviance = 134.60 - 120.97 = 13.63, df = 2, p-value 0.001 (stated in the lecture as less than 0.05); individual significance uses coefficient p-values.
Top pitfall: Using the F test for overall significance or subtracting deviances in the wrong order.
Self-check: How do you obtain the chi-square statistic from simple R output, and what is its value for the Simmons model?
Connects to: 11.5, 11.6, 9.3
Odds and the Odds Ratio
Must-know: Odds = p/(1-p) ranges 0 to infinity; odds ratio for the card variable is 0.6956/0.2318 ≈ 3.00 (output 3.004) — the odds are about three times greater, NOT the probability; shortcut odds ratio = e^(beta_i).
Top pitfall: Stating that an odds ratio of 3 means the probability is three times higher; the odds p/(1-p) are three times greater, not the probability.
Self-check: For a probability of 0.4102, what are the odds, and what is the odds ratio when the comparison probability is 0.1881?
Connects to: 11.6, 11.7, 11.9, 11.2
Managerial Decision Making with the Model
Must-know: With a 0.4 probability threshold, recommendations are: send catalogs to card holders spending $2,000 or more, and to non-holders spending $6,000 or more; logistic coefficients are interpreted via the odds ratio, never directly.
Top pitfall: Reading a logistic coefficient as a direct change in probability, or applying the $2,000 rule to customers without the card.
Self-check: Using a 0.4 threshold, which two customer types receive the catalog in the Simmons example?
Connects to: 11.6, 11.8, 11.7
Exam Guidance Summary
Must-know: Read coefficients from the Estimate column; substitute into the fitted equation for probabilities; overall significance via chi-square (13.63, p < 0.05); odds ratio 3.004 with shortcut e^(beta); threshold 0.4 rule for catalogs.
Top pitfall: Reading fitted probabilities outside 0-1 or interpreting coefficients directly; the odds are three times greater, not the probability.
Self-check: What is the overall significance statistic in R output, and how is it computed?
Connects to: 11.5, 11.6, 11.7, 11.8, 11.9
Key Industry Applications
Must-know: Logistic regression powers targeting, credit decisions, fraud detection and spam classification; odds ratios are the reporting currency; PCA and LDA preview the next topic.
Self-check: Why are odds ratios the standard reporting currency in industry?
Connects to: 11.4, 11.8, 11.9
Was this lecture useful?
BitsNotes AI Assistant
Subject Notes AssistantConfigure AI Chat
Choose how to access the chatbotSigned in as
Powered by BitsNotes — 20 messages per day. No API key needed. Want unlimited access? Use "Bring Your Own Key" mode.
Sign in to use AI Chat
Get 20 free AI messages per day to ask questions about your lecture notes. Sign in with Google or GitHub — it takes 5 seconds.
Sign In to BitsNotesSwitch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.