Unit 3

Regression Analysis

Regression Analysis · Data, Models, and AI-Empowered Decision Making
3.1 Four-Step Regression and the Toy-Sales Case 3.2 Interpreting Output and Significance 3.3 Dummy Variables and Collinearity 3.4 Variable Transformations and Log Models 3.5 AI-Assisted Regression 3.6 Summary and Assignment 5 interactive demonstrations · 5 classroom exercises
How to use this e-textbook. Orange panels are interactive demonstrations where changing price, advertising and promotion recalculates the regression and forecasts immediately. Green panels are classroom exercises; complete them and select “Check” for feedback and reference values. The regressions on this page are not hard-coded:every coefficient, t value, p-value and R-squared is calculated from embedded raw data when the page opens, so you can change the data or model specification and the conclusion will change with them.

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.
Y = β₀ + β₁X₁ + β₂X₂ + … + εY is the dependent variable to predict; X₁ and X₂ are independent variables used as explanations; β₀, β₁ and β₂ are regression coefficients estimated from data; ε is the error term.

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?

VariableMeaningUnitObserved range
Unit SalesMonthly sales (dependent variable)units69,003 to 80,364
PriceUnit priceUSD7.25 to 8.99
Adexpadvertising spendingUSD thousand48.0 to 54.0
Promexppromotion spendingUSD thousand58.0 to 61.1

Data file:Toy-Sales.xlsx, containing 24 months of sales and three independent variables.

The Four Steps of Regression

  1. Model formulation write the relationship between the dependent and independent variables, and decide which variables belong in the model.
  2. Estimation use software, such as Excel’s Regression tool, to estimate the coefficients.
  3. Inference assess whether the estimates are credible: are the coefficients significant, and are their signs sensible?
  4. Prediction produce forecasts for the scenarios of interest and state the applicable range.

Steps One and Two: Specify the Model, Then Estimate It

Sales = β₀ + β₁Price + β₂Adexp + β₃Promexp + εStep 1: write the model and decide which variables enter; Step 2: give the 24 monthly observations to software to estimate the coefficients

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

VariableCoefficientStandard errort valuep-value
Intercept−25,096.8324,859.61−1.010.3246
Price−5,055.27526.40−9.60< 0.0001
Advertising spend648.61209.003.100.0056
Promotion spend1,802.61392.854.590.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.

Interactive Demonstration 1

Toy-Sales Forecasting Workbench

Drag the three sliders to change the scenario and recalculate the forecast in real time. You may also change the model specification and see how much explanatory power is lost when a variable is omitted. The chart plots actual against predicted sales; points closer to the diagonal fit better.

Model:
Predicted sales
Model R²
Adjusted R²
Sample size

Prediction: Sales under Three Scenarios

ScenarioPriceAdvertisingPromotionPredicted sales
19.1052,00061,00072,587.31
27.1048,00057,00072,892.96
38.1050,00060,00074,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.

Classroom Exercise 1

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.

Classroom Exercise 2

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.
Price Sales Residual Regression line (fitted model)
The residual is the vertical distance from a data point to the regression line. Smaller, less systematic errors make the model more credible.

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 variationSum of squaresShare
Total variation (SST)230,308,045100.0%
Explained by regression (SSR)142,558,43061.9%
Unexplained residual variation (SSE)87,749,61538.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.

Interactive Demonstration 2

R-Squared Decomposition: Where Does 61.9% Come From?

Change the model and compare explained and unexplained variation. Values are calculated from the 24 real monthly observations.

Model specification:
Total variation SST
Explained SSR
Unexplained SSE
R²

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:

t = β ÷ SE(β)Null hypothesis H₀: β = 0 (the variable has no effect on Y); alternative H₁: β ≠ 0

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.

Coefficientt valuep-valueSignificant at the 5% level?
Intercept−1.010.3246Not significant
Price−9.60< 0.0001Significant
Advertising spend3.100.0056Significant
Promotion spend4.590.0002Significant

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.

Minutes = β₀ + β₁Parcels + β₂TruckAge + β₃REGA + εRegion B is the reference category: its level is absorbed into the intercept, and β₃ is the extra time required for Region A relative to Region B

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.

Minutes = β₀ + β₁Parcels + β₂TruckAge + β₃REGA + β₄REGB + εRule: number of dummies = number of categories − 1; dummy values must be 0 or 1

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

VariableCoefficientt valuep-valueInterpretation
Parcels9.9224.72< 0.0001Each additional parcel adds 9.9 minutes
TruckAge3.684.85< 0.0001Each additional year of truck age adds 3.7 minutes
REGA (Region A)107.7113.33< 0.0001Takes 107.7 minutes longer than Region C
REGB (Region B)1.210.160.8768Not significantly different from Region C

Sample: 47 deliveries; R² = 0.9513; reference category: Region C.

Interactive Demonstration 3

Dummy-Variable Workbench: What Happens When the Reference Category Changes?

The reference category is chosen, not determined by the data. Change it and coefficients change, but the conclusion about which region is slower does not.

Reference category:

Application: Drivers of Refrigerator Price (37 Models)

VariableCoefficientt valuep-value
Opcost (operating cost)−6.96−3.060.0046
CoolSize (refrigeration capacity)76.503.940.0004
FreezeSize (freezer capacity)213.885.98< 0.0001
Shelves37.943.840.0006
Features23.765.27< 0.0001

R² = 0.8379. Note:a different model specification can produce a different conclusion:

Specificationindependent variableCapacity coefficientp-valueR²
Model 1Separate refrigeration and freezer capacityRefrigeration 76.50; freezer 213.88Both significant0.8379
Model 2Use total capacity RefSizeTotal capacity 35.600.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

Modelindependent variableCoefficientt valuep-valueR²
Model ADisplacement and cylinders−0.018, −2.341−0.85, −1.970.402, 0.0570.6559
Model BDisplacement only−0.0579−7.63< 0.00010.6179
Model CCylinders only−3.290−8.16< 0.00010.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.

Interactive Demonstration 4

Collinearity Workbench: Fuel-Economy Models for 38 Cars

Switch among three models and observe coefficients, p-values and R². Overall fit remains reasonable under every model; what breaks is the interpretation of which variable matters more.

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.
Classroom Exercise 3

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.
LN(A) + LN(B) = LN(A × B) LN(A) − LN(B) = LN(A ÷ B)LN(1) = 0; LN(0) and LN(negative values) are undefined

Interpreting Coefficients in Log Models

Model formRegression equationCoefficient interpretation
LinearY on XA one-unit increase in X changes Y by β units
Semi-loglnY on XA one-unit increase in X changes Y by about 100β%
log-loglnY on lnXA 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:

ln(Demand) = β₀ + β₁ ln(Price) + β₂ ln(Income) + β₃ Year + εFirst estimate the model yourself with Cocoa.xlsx, then compare the coefficients below

Run this regression in Excel, record the three coefficients and their interpretations, then compare with the results below.

VariableCoefficientt valuep-valueInterpretation
LnPrice−0.222−6.58< 0.0001price elasticity −0.22
LnPcinc (income per capita)−0.572−1.620.1127Not significant
Year0.03614.400.0001growth 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.

Interactive Demonstration 5

Log-Transformation Workbench: Change the Specification, Change the Interpretation

Using the same 49 years of cocoa data, switch among three model specifications and observe how R² and coefficient interpretations change. The forecast below uses the log-log model; enter next year’s price and income per capita.

R²
Price coefficient
Income coefficient
Year coefficient
Forecast next year’s demand: priceUSD/pound; income per capita USD

Classroom Exercise 4

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
AI activity

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 typeSymptomHow to verify
Treating R-squared as hit rateSaying the model predicts 86% of sales accuratelyR-squared measures explained variation, not forecast accuracy
Matching coefficients to the wrong variableAttributing one variable’s coefficient to anotherCompare line by line with the coefficient table
Ignoring p-valuesPresenting a non-significant coefficient as a conclusionCheck whether p < 0.05
Confusing correlation with causationSaying that increasing advertising will increase salesAsk whether an experiment or adequate controls support the claim
Ignoring the sample rangeExtrapolating two years of data five years into the futureInspect the observed range of the independent variables
Classroom Exercise 5

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.
Post-class assignment. Exercise 1: use Toy-Sales.xlsx to recompute the three coefficients and interpret their signs. Exercise 2: use Home_Prices.xlsx to run a four-variable regression. Exercise 3: compare collinearity symptoms in the car and refrigerator cases. Exercise 4: use Cocoa.xlsx to interpret elasticity and growth rate. There is also an AI-correction assignment: identify and correct the errors in the sample interpretation and submit an AI-use statement.

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

LocationTypeContent
3.1DemonstrationToy-sales workbench: three-variable model and price-only model
3.2DemonstrationR-squared decomposition: where 61.9% and 85.9% come from
3.3DemonstrationDummy-variable workbench: changing the reference category
3.3DemonstrationCollinearity workbench: three models for 38 cars
3.4DemonstrationLog-transformation workbench: cocoa-demand elasticity and trend
3.1ExerciseReplicate the Toy-Sales Regression
3.1ExerciseMake Two Predictions with the Model
3.3ExerciseThree Judgements about Collinearity
3.4ExerciseTranslate Log Coefficients into Plain Language
3.5ExerciseFive 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-squaredR 平方 / 决定系数
Collinearity共线性
Dummy variable虚拟变量
Elasticity弹性
Log-linear model对数线性模型