Academy › Topic library › Going Deeper: Multiple Regression, Logistic Regression and General Linear Models
Q-BOT ACADEMY · FREE VIDEO LESSON · 13 MIN
Going Deeper: Multiple Regression, Logistic Regression and General Linear Models
Real processes have more than one input. Study one input at a time, and the others hide in the noise, or worse, inside the one you're looking at. A model with every important input answers the real question: what happens when I change this input and hold the others still?
In short
Multiple regression gives each input's effect with the others held still: check adjusted R squared, t and V I F. Logistic regression models a yes or no result through the log odds, and e to the slope is the odds ratio. Nonlinear models are fit by iteration. General linear models mix categories and numbers in one model. And MANOVA, factor analysis and discriminant analysis handle several outputs at once.
Check yourself
Two inputs in a regression model have a correlation of point nine with each other, and they are the only inputs. What is the variance inflation factor for each? A: one point two three. B: five point two six. C: ten. Or D: point one nine.
Show the answer
The answer is B. With only two inputs, the R squared of one on the other is the correlation squared: point eight one. V I F equals one over one minus point eight one, that's one over point one nine: five point two six. That's above five, so be careful with those slopes! A divided by R squared instead of one minus R squared, C forgot to square the correlation, and D stopped at one minus R squared. That's multiple regression, logistic regression and general linear models. Questions? Ask Q-Bot right here in the Academy. And one for the road: why did the two inputs get kicked out of the model? They kept finishing each other's sentences!
Where this topic is taught
This lesson is part of every free Academy course whose Body of Knowledge covers it. Each course puts it in context, with exercises and checks.
Full lesson transcript
The narration from the video, by chapter. Brindlewood Outdoor Furniture and its people are a fictional company used in every Q-Bot Academy lesson.
Intro
Brindlewood, Monday. Rosa wants the coating line to run faster for the spring rush, from twelve feet a minute to fourteen. Dwayne has a year of line records and a scatter plot. Look, he says, line speed doesn't change the coating thickness at all! The line is flat. Marcus looks at the same records and frowns. Flat, he says, because something else moved at the same time.
Hey there, I'm Q-Bot. Welcome to the Q-Bot Academy. Today we're going deeper: multiple regression, logistic regression and general linear models! If regression is new to you, start with the Math of Correlation and Linear Regression video. Today: several inputs, yes or no results, true curves, categories mixed with numbers, and tools for several outputs at once.
Why the math matters
Why does the math matter? Real processes have more than one input. Study one input at a time, and the others hide in the noise, or worse, inside the one you're looking at. A model with every important input answers the real question: what happens when I change this input and hold the others still?
Multiple regression
First, multiple regression. The model is y equals b zero, plus b one times x one, plus b two times x two, and so on, plus error. Each b is a partial slope: how much y changes for one unit of that x, with every other x in the model held constant. Bad: reading each slope as if it were the simple slope from a scatter plot. Good: every slope is read as holding the others still!
How good is the model? R squared is the share of the variation in y the model explains. But R squared never goes down when you add an input, even a useless one. So use adjusted R squared, which charges a penalty for every term. The overall F test asks: does any input help at all? Then a t test for each slope asks: does this input help, given the others are already in? Each t has n minus p minus one degrees of freedom, with p inputs.
Now, the trap. When two inputs move together, the model struggles to tell them apart. That's multicollinearity. Measure it with the variance inflation factor, V I F. For one input, regress it on all the other inputs and take that R squared. V I F equals one over one minus that R squared. One means no overlap. Above five, be careful. Above ten, the slopes are shaky: their standard errors swell, and signs can even flip!
Worked example: the coating line
Worked example one. Marcus pulls twelve coating runs from the records: line speed, gun distance and average thickness. First, the simple regression Dwayne made, thickness on speed alone. The slope is minus point oh one eight mils per foot a minute, with a p-value of point seven two. Fail to reject: on its own, speed looks like it doesn't matter.
Here's why. The correlation between speed and gun distance is minus point seven six. When the operators sped the line up, they moved the guns in closer to keep the coat thick! Now the multiple regression: thickness equals eight point two two, minus point one nine one times speed, minus point two seven zero times distance. R squared is point nine one, adjusted point eight nine, and s is point oh seven seven mils.
Test each slope. Speed: t is minus seven point nine. Distance: t is minus nine point four. With nine degrees of freedom, the t table, or T dot INV dot two T in Excel, gives a critical value of two point two six two. Both are far beyond it, so both inputs matter! Holding distance still, each extra foot a minute takes off about point one nine mils. And the V I F? One over one minus point seven six squared: about two point three five. Some overlap, but the slopes hold up.
Now the decision. At fourteen feet a minute and today's ten inch notch, the model predicts two point eight four mils. Thin! Solve for three point oh at fourteen feet a minute: gun distance about nine point four inches. The ninety five percent prediction interval for a single run there is two point eight one to three point two oh mils, inside the two point five to four point oh spec. One caution! These are records, not an experiment. So Lou and Priya run a short pilot at the new setting before it goes in the work instruction.
Logistic regression
Next, logistic regression. Sometimes the result is yes or no: the slat warps or it doesn't, the weld passes or it fails. A straight line can predict a probability of minus twenty percent, or a hundred and thirty. So we model the log of the odds instead. The odds are p over one minus p. The model: the natural log of the odds equals b zero plus b one times x. Turn it back: p equals one over one plus e to the minus that.
How do you read it? Each slope is a change in log odds. Raise e to the slope and you get the odds ratio: how many times the odds multiply for one unit of x. It's fit by maximum likelihood, each slope gets a z test, and the deviance checks the fit. Bad: an odds ratio of two means twice the probability. Good: it means twice the odds! When p is small, the two are close. When p is big, they're not.
Worked example: warped slats
Worked example two. Ellen pulls records from before the slat supplier started kiln drying every lot: two hundred eighty slats, forty at each moisture level from nine to fifteen percent, and whether each one warped. Eighty warped. The fit: log odds equals minus ten point four zero, plus point seven five four times the moisture percent. The z for the slope is seven point five, so moisture clearly matters. And the deviance is point seven one on five degrees of freedom: a good fit.
Now the numbers that matter. The odds ratio is e to the point seven five four: about two point one three. Every extra point of moisture roughly doubles the odds of a warp! At twelve percent, Brindlewood's limit, the log odds are minus one point three five, the odds are point two six, and the probability is about twenty percent. At ten percent, about five percent. So Ellen and the supplier set the kiln target at ten percent, and twelve stays the reject line.
Nonlinear models
Next, models that are nonlinear in their parameters. A curve isn't the problem. A quadratic, b zero plus b one x plus b two x squared, is still linear regression, because it's linear in the b's. The hard ones put a parameter inside an exponent or a ratio. Those are fit by iteration: nonlinear least squares, or Solver in Excel. You give starting values, the software walks to the best fit, and you check that the answer makes sense.
Here's one at Brindlewood. Lou logs the cure oven warming up on a cold Monday. The physics says the temperature climbs toward a final value and slows as it gets close: T equals T final, minus T final minus T start, times e to the minus k t. The fit: T final about three sixty two degrees Fahrenheit, T start about fifty three, and k is point oh six five per minute. That's a time constant of about fifteen minutes. The residuals are small, about one point four degrees, with no pattern.
So when is the oven within five degrees of the three sixty setting, at three fifty five? Solve the model: about fifty nine minutes. Now watch the shortcuts fail. A straight line through the same data says five hundred forty four degrees at ninety minutes. A quadratic says one hundred twenty! The physics model says it levels off at about three sixty two. The right shape matters most when you predict past your data!
General linear models
Next, general linear models, or G L M. One model that holds numbers and categories together. A category, like which powder supplier, goes in as an indicator: zero for powder A, one for powder B. Its coefficient is the shift between the groups, holding the numeric inputs still. ANOVA and regression are both special cases. Watch the name! The generalized linear model is a wider family, and logistic regression is one of them.
Marcus runs twelve test frames, six with each powder, at gun distances from eight to thirteen inches. A plain two sample t test on thickness: powder B is point three mils thicker, but the p-value is point two seven. The distance spread drowns it out. The general linear model: thickness equals five point two nine, minus point two three seven times distance, plus point three oh for powder B. That point three now has a t of eight point seven five! An interaction term has a p-value of point four three, so the slopes look parallel.
Several outputs at once
One more family, for when you have several outputs at once. MANOVA, multiple analysis of variance, tests several responses together, like thickness, gloss and adhesion by powder, instead of three separate tests. Factor analysis finds a few hidden factors behind many related measures, like twelve survey questions. And discriminant analysis builds a rule that sorts items into groups from their measurements: good lot or bad lot.
Reading the result
How do you read the result and decide? First, check the residuals: no pattern against each input or the fitted values, roughly normal, constant spread, and independent. Then ask if each term earns its place. Keep the model simple. Predict only inside the range you studied. And a model built on records shows association: to prove cause, run an experiment or a pilot.
Common mistakes
Common mistakes. One: reading a partial slope as a simple slope. Two: chasing R squared by adding terms, instead of watching adjusted R squared. Three: ignoring a high V I F and trusting shaky slopes. Four: treating an odds ratio as a probability ratio. Five: forcing a straight line, or a polynomial, where the physics is a curve. And six: extrapolating!
Recap
Let's recap. Multiple regression gives each input's effect with the others held still: check adjusted R squared, t and V I F. Logistic regression models a yes or no result through the log odds, and e to the slope is the odds ratio. Nonlinear models are fit by iteration. General linear models mix categories and numbers in one model. And MANOVA, factor analysis and discriminant analysis handle several outputs at once.
Check yourself
Now, check yourself. Two inputs in a regression model have a correlation of point nine with each other, and they are the only inputs. What is the variance inflation factor for each? A: one point two three. B: five point two six. C: ten. Or D: point one nine. Pause the video if you want to think about it.
The answer is B. With only two inputs, the R squared of one on the other is the correlation squared: point eight one. V I F equals one over one minus point eight one, that's one over point one nine: five point two six. That's above five, so be careful with those slopes! A divided by R squared instead of one minus R squared, C forgot to square the correlation, and D stopped at one minus R squared.
That's multiple regression, logistic regression and general linear models. Questions? Ask Q-Bot right here in the Academy. And one for the road: why did the two inputs get kicked out of the model? They kept finishing each other's sentences!
Independent study material; not affiliated with or endorsed by ASQ. Body of Knowledge codes identify where the topic appears in each certification's published outline.