Regression Analysis
3.1 Regression Foundations: From Problem to Model
Regression answers who affects the outcome, by how much, and whether the relationship can be used for prediction. This section applies the four steps to a toy retailer.
What Linear Regression Is
- Linear regression fits a linear relationship between a variable of interest and a set of potentially related variables.
- The variable to predict is the dependent variable, denoted Y; the variable used to explain it is the independent variable, denoted X.
- The fitting objective is to make the gap between predicted and actual values as small as possible.
- A coefficient should be read as “all else equal, the marginal effect of all else equal a one-unit change in one variable”—this phrase cannot be omitted.
Case: A Toy Retailer’s Forecasting Problem
A sales manager at a toy retailer must forecast monthly sales for a product over the next six months. She previously relied on experience and intuition; now she wants a more disciplined process. Monthly sales may depend on unit price,advertising spending and promotion spending. The question is: given values of these three variables, what will sales be?
| Variable | Meaning | Unit | Observed range |
|---|---|---|---|
| Unit Sales | Monthly sales (dependent variable) | units | 69,003 to 80,364 |
| Price | Unit price | USD | 7.25 to 8.99 |
| Adexp | advertising spending | USD thousand | 48.0 to 54.0 |
| Promexp | promotion spending | USD thousand | 58.0 to 61.1 |
Data file:Toy-Sales.xlsx, containing 24 months of sales and three independent variables.
The Four Steps of Regression
- Model formulation write the relationship between the dependent and independent variables, and decide which variables belong in the model.
- Estimation use software, such as Excel’s Regression tool, to estimate the coefficients.
- Inference assess whether the estimates are credible: are the coefficients significant, and are their signs sensible?
- Prediction produce forecasts for the scenarios of interest and state the applicable range.
Steps One and Two: Specify the Model, Then Estimate It
In Excel, use “Data ▸ Data Analysis ▸ Regression,” selecting Unit Sales as the dependent variable and all three independent variables. The software finds the β values that minimise the sum of squared residuals and reports coefficients, standard errors, t values, p-values and R².This step produces only numbers; whether they are credible and usable is addressed in the next two steps.
Estimation: Reading Excel Regression Output
| Variable | Coefficient | Standard error | t value | p-value |
|---|---|---|---|---|
| Intercept | −25,096.83 | 24,859.61 | −1.01 | 0.3246 |
| Price | −5,055.27 | 526.40 | −9.60 | < 0.0001 |
| Advertising spend | 648.61 | 209.00 | 3.10 | 0.0056 |
| Promotion spend | 1,802.61 | 392.85 | 4.59 | 0.0002 |
The model explains R² = 0.8588 of the variation; adjusted R² = 0.8377, with 24 monthly observations.The p-values of all three independent variables are below 0.05, so all are significant; the intercept is not significant, but this usually does not prevent using the three slopes.
Prediction: Sales under Three Scenarios
| Scenario | Price | Advertising | Promotion | Predicted sales |
|---|---|---|---|---|
| 1 | 9.10 | 52,000 | 61,000 | 72,587.31 |
| 2 | 7.10 | 48,000 | 57,000 | 72,892.96 |
| 3 | 8.10 | 50,000 | 60,000 | 74,542.75 |
The main difference among the three scenarios is promotion spending: Scenario 3 is about 1,955 units above Scenario 1. Note that all scenario inputs lie within the range of the historical data—extrapolating beyond that range is at your own risk.
Replicate the Toy-Sales Regression
Open Toy-Sales.xlsx and run a three-variable regression with Excel’s Regression tool. Enter the results below; the correct order of magnitude counts as correct.
Make Two Predictions with the Model
Using the same three-variable model, calculate predicted sales for Scenarios 1 and 3.
3.2 Error and Significance: Is the Model Credible?
Error in Regression
- Regression always contains error; a forecast will not exactly equal the actual value:residual = actual value − predicted value.
- The vertical distance between a data point and the regression line is the residual; large residuals indicate a poor fit and small residuals a good fit.
- The key question is not whether error exists, but how large it is and whether it is random.
R-Squared: A Measure of Goodness of Fit
R-squared is the proportion of variation in the dependent variable explained by the model. It ranges from 0 to 1, with values closer to 1 indicating a better fit. It answers “how much does the model explain,” not “how accurate is the forecast,” and there is no universal threshold for “good enough.”
| Source of variation | Sum of squares | Share |
|---|---|---|
| Total variation (SST) | 230,308,045 | 100.0% |
| Explained by regression (SSR) | 142,558,430 | 61.9% |
| Unexplained residual variation (SSE) | 87,749,615 | 38.1% |
The table above is Price only the price-only model: it explains 61.9% of the variation in sales. Adding advertising and promotion increases explanatory power to 85.9%. A high R-squared does not by itself make a model useful; coefficients must also be significant and directionally sensible.
Where Error Comes From and the Four Assumptions for the Error Term
Four sources of error
- an important independent variable is omitted
- the relationship between Y and X is not linear
- the variables are measured with error
- regression theory itself assumes random error
Four assumptions for the error term
- The mean error is zero
- The standard deviation of errors is constant across values of X
- Errors are independent of one another
- Errors are normally distributed
These four assumptions determine whether t tests and confidence intervals are reliable. Plotting residuals before interpreting a regression is the cheapest diagnostic step.
Coefficients Also Have Error: t Values and p-Values
Coefficients are estimated from a sample and have their own standard errors. A smaller standard error indicates a more precise estimate; degrees of freedom = observations − number of independent variables − 1. Testing whether a coefficient is zero uses the following t statistic:
Reading the p-value: If the true coefficient were zero, the p-value is the probability of observing a t value this large or larger. A small p-value makes the “no effect” hypothesis difficult to reconcile with the observed data, so retain the variable; a large p-value provides no evidence of an effect in this sample and should not be treated as a conclusion.
| Coefficient | t value | p-value | Significant at the 5% level? |
|---|---|---|---|
| Intercept | −1.01 | 0.3246 | Not significant |
| Price | −9.60 | < 0.0001 | Significant |
| Advertising spend | 3.10 | 0.0056 | Significant |
| Promotion spend | 4.59 | 0.0002 | Significant |
The null states that the variable’s effect is zero; reject it when p < 0.05.Not significant ≠ no effect; it only means this sample does not reveal an effect.
3.3 Categorical Variables and Collinearity
Question 1: Only Regions A and B
A parcel-delivery company operates in two regions, A and B. Trucks depart from the same central depot, and the data record parcels per trip, truck age and total delivery time. The question is:how much longer does delivery to Region A take than to Region B?
Region is a categorical variable whose values are labels and cannot simply be coded 1 and 2—“A is one more than B” has no meaning. Introduce a dummy variable REGA: code 1 for trips to Region A and 0 for Region B, so both regions can enter one equation.
Data file:deliveries1.xlsx, based on 30 two-region deliveries.
Question 2: A Third Region C Is Added
New data now include Region C. Three categories cannot be represented by one dummy variable; you need two dummy variables: REGA and REGB. A delivery to Region C is coded (0, 0) and serves as the reference category—every regional coefficient is read relative to it.
Data file:deliveries2.xlsx, with 47 deliveries. First estimate the model yourself using the same method, then compare with the results below.
Results: Estimates from 47 Deliveries
| Variable | Coefficient | t value | p-value | Interpretation |
|---|---|---|---|---|
| Parcels | 9.92 | 24.72 | < 0.0001 | Each additional parcel adds 9.9 minutes |
| TruckAge | 3.68 | 4.85 | < 0.0001 | Each additional year of truck age adds 3.7 minutes |
| REGA (Region A) | 107.71 | 13.33 | < 0.0001 | Takes 107.7 minutes longer than Region C |
| REGB (Region B) | 1.21 | 0.16 | 0.8768 | Not significantly different from Region C |
Sample: 47 deliveries; R² = 0.9513; reference category: Region C.
Application: Drivers of Refrigerator Price (37 Models)
| Variable | Coefficient | t value | p-value |
|---|---|---|---|
| Opcost (operating cost) | −6.96 | −3.06 | 0.0046 |
| CoolSize (refrigeration capacity) | 76.50 | 3.94 | 0.0004 |
| FreezeSize (freezer capacity) | 213.88 | 5.98 | < 0.0001 |
| Shelves | 37.94 | 3.84 | 0.0006 |
| Features | 23.76 | 5.27 | < 0.0001 |
R² = 0.8379. Note:a different model specification can produce a different conclusion:
| Specification | independent variable | Capacity coefficient | p-value | R² |
|---|---|---|---|---|
| Model 1 | Separate refrigeration and freezer capacity | Refrigeration 76.50; freezer 213.88 | Both significant | 0.8379 |
| Model 2 | Use total capacity RefSize | Total capacity 35.60 | 0.1756 (not significant) | 0.6631 |
Total capacity is not significant in Model 2 because its coefficient compares equal increases in freezer capacity with equal decreases in refrigeration capacity. That is a property of the specification, not evidence that capacity is unimportant.
Car Fuel-Economy Case: Neither Variable Is Significant
| Model | independent variable | Coefficient | t value | p-value | R² |
|---|---|---|---|---|---|
| Model A | Displacement and cylinders | −0.018, −2.341 | −0.85, −1.97 | 0.402, 0.057 | 0.6559 |
| Model B | Displacement only | −0.0579 | −7.63 | < 0.0001 | 0.6179 |
| Model C | Cylinders only | −3.290 | −8.16 | < 0.0001 | 0.6488 |
Displacement and cylinders are each highly significant on their own, yet neither is significant when both enter the model—their correlation is 0.9403. This is multicollinearity.
Collinearity: Identification and Treatment
- Occurs when two or more independent variables are highly correlated, so the variation in Y cannot be assigned reliably among them.
- The model’s fit and forecasts can remain acceptable, but interpretations of “which variable has a larger effect” are no longer reliable.
- Detection: inspect the correlation matrix among independent variables and flag high correlations; some software also reports VIF.
- Treatment: usually unnecessary for prediction; when coefficient interpretation matters, a common approach is to remove one of the highly correlated variables.
Three Judgements about Collinearity
Using the car and refrigerator cases, evaluate the following three statements.
3.4 Variable Transformations and Elasticity
Why Transform Variables?
- The regression model is linear in its parameters, but the relationship between Y and X need not be linear.
- Transformations can turn a curved relationship into a linear one and improve the fit.
- Transformations can also give coefficients the interpretation of elasticity or growth rate, making them easier to explain to management.
- Common transformations: add a squared term(X², allowing the marginal effect to vary with X), add an interaction term(X₁X₂, representing a joint effect), use reciprocals, powers or roots, take natural logarithms, or transform Y and X separately.
Interpreting Coefficients in Log Models
| Model form | Regression equation | Coefficient interpretation |
|---|---|---|
| Linear | Y on X | A one-unit increase in X changes Y by β units |
| Semi-log | lnY on X | A one-unit increase in X changes Y by about 100β% |
| log-log | lnY on lnX | A 1% increase in X changes Y by β%, the elasticity |
Case: Elasticity and Trend in Cocoa Demand
The data contain annual global cocoa demand, cocoa price and income per capita over several years. Demand is proportional to price and income, and it also changes gradually over time, so the model logs price and income and represents trend with year:
Run this regression in Excel, record the three coefficients and their interpretations, then compare with the results below.
| Variable | Coefficient | t value | p-value | Interpretation |
|---|---|---|---|---|
| LnPrice | −0.222 | −6.58 | < 0.0001 | price elasticity −0.22 |
| LnPcinc (income per capita) | −0.572 | −1.62 | 0.1127 | Not significant |
| Year | 0.0361 | 4.40 | 0.0001 | growth of about 3.6% per year |
Sample: 49 years (1960–2008); R² = 0.9573.price elasticity −0.22 Interpretation: a 1% price increase reduces demand by about 0.22% on average; because its absolute value is below 1, cocoa demand is inelastic. The income elasticity is −0.572 with p = 0.1127,not significant and not suitable as a conclusion.
Translate Log Coefficients into Plain Language
Using the log-log cocoa model, complete the three values.
3.5 AI-Assisted Regression Interpretation
AI is good at translating regression output into managerial language and equally good at attaching a coefficient to the wrong variable. The point is not “using AI to run regression,” but “drafting with AI and verifying as the human.”
What AI Can and Cannot Do in Regression
Can delegate to AI
- Explain output: translate coefficients, R-squared and p-values into management language
- Flag omissions: identify omitted independent variables and assumptions
- Draft conclusions: write a conclusion that you will revise
Must decide yourself
- Whether coefficient signs make business sense
- Whether the Excel calculations are correct
- Whether conclusions can be extrapolated beyond the sample
Three steps for the live demonstration
① Paste the entire toy-sales regression output into AI and ask for an explanation of the three coefficients in language managers understand.
② Ask “which conclusions cannot be drawn from this model?” then ask the same question again and compare the answers.
③ Verify each item: do AI’s coefficients match Excel, are the signs correct, and are p-values ignored?
| Error type | Symptom | How to verify |
|---|---|---|
| Treating R-squared as hit rate | Saying the model predicts 86% of sales accurately | R-squared measures explained variation, not forecast accuracy |
| Matching coefficients to the wrong variable | Attributing one variable’s coefficient to another | Compare line by line with the coefficient table |
| Ignoring p-values | Presenting a non-significant coefficient as a conclusion | Check whether p < 0.05 |
| Confusing correlation with causation | Saying that increasing advertising will increase sales | Ask whether an experiment or adequate controls support the claim |
| Ignoring the sample range | Extrapolating two years of data five years into the future | Inspect the observed range of the independent variables |
Find Five Errors in This AI Interpretation
Below is a simulated AI-style regression interpretation for 24 simulated coffee-chain stores. Select a sentence to mark it as “problematic,” then select Check. The text contains five errors.
Verification method: ask three questions of every sentence—which variable does this number belong to, is that variable significant, and what assumptions does the conclusion require?
3.6 Summary and Assignment
- Regression answers who affects the outcome and by how much; the four steps are model formulation, estimation, inference and prediction.
- R-squared assesses fit; p-values assess significance; neither replaces the other.
- Dummy variables bring categories into a model,the reference category is chosen by the analyst, and coefficients are interpreted relative to it.
- Collinearity can undermine coefficient interpretation but usually does not prevent prediction.
- Log transforms provide elasticity and growth-rate interpretations; coefficient interpretation must follow the model form.
The next class begins Unit 4: Time Series and Text Data.Unit 4 treats this unit’s regression as a causal forecasting tool, so review how regression coefficients are interpreted.
Appendix: Interactive Demonstrations and Classroom Exercises
| Location | Type | Content |
|---|---|---|
| 3.1 | Demonstration | Toy-sales workbench: three-variable model and price-only model |
| 3.2 | Demonstration | R-squared decomposition: where 61.9% and 85.9% come from |
| 3.3 | Demonstration | Dummy-variable workbench: changing the reference category |
| 3.3 | Demonstration | Collinearity workbench: three models for 38 cars |
| 3.4 | Demonstration | Log-transformation workbench: cocoa-demand elasticity and trend |
| 3.1 | Exercise | Replicate the Toy-Sales Regression |
| 3.1 | Exercise | Make Two Predictions with the Model |
| 3.3 | Exercise | Three Judgements about Collinearity |
| 3.4 | Exercise | Translate Log Coefficients into Plain Language |
| 3.5 | Exercise | Five errors in an AI interpretation |
Data sources: Toy-Sales.xlsx (24 months), Home_Prices.xlsx (90 cities), Cars.xlsx (38 cars), Cocoa.xlsx (49 years), Refrigerators.xlsx (37 models), and deliveries2.xlsx (47 deliveries). Every coefficient, standard error, t value, p-value and R-squared on the page is calculated from these original data and can be checked against Excel.
Unit Glossary (English–Chinese)
| English | 中文 |
|---|---|
| Dependent variable | 因变量 |
| Independent variable | 自变量 |
| Regression coefficient | 回归系数 |
| Residual | 残差 |
| R-squared | R 平方 / 决定系数 |
| Collinearity | 共线性 |
| Dummy variable | 虚拟变量 |
| Elasticity | 弹性 |
| Log-linear model | 对数线性模型 |