Lawfare Academy

Regression Analysis for Business · Chapter 1 of 8

Define an estimand, preserve raw data and freeze the analysis plan

Return to the linked course unit →

DEVELOPED COURSE TEXT

Define an estimand, preserve raw data and freeze the analysis plan

One enterprise record and two different questions

The fictional company Harbor records 32 consecutive months of sales, posted price, advertising and a promotion indicator. Price is in dollars, advertising in thousands of dollars and sales in hundreds of units. Months 1–24 are development data; months 25–32 are a locked future holdout. A decision made before each sales month knows the planned price, advertising and promotion plus the calendar index, but not that month's sales. These timing assumptions make the later prediction exercise well-defined. A forecast using realized future spending unavailable at the decision time would answer a different question.
Harbor asks both how well it can predict sales and how much a deliberate price change would alter sales. A predictive regression and a causal price response are distinct estimands. A coefficient can help predict within an observed operating regime while being biased for an intervention because managers choose prices when they anticipate stronger demand. The raw record therefore includes a teaching-only latent-demand column: it reveals the simulation mechanism for later identification analysis but is not available to the deployment model.

Document how the fictional observations were generated

The supplied generator uses NumPy's default random generator with seed 614. It draws latent demand z, then price approximately 20+.12×month+1.4z plus independent price noise. Advertising varies across a five-month pattern with additional noise; promotion occurs every fourth month. Sales are generated as 120-3×price+2×advertising+8×promotion+.8×month+4z+u. The error u follows a recursive process with coefficient .45 and innovations whose scale increases with month. Observed price, advertising and sales are rounded to three decimals; z is rounded to six decimals before use.
This is deliberately not an IID homoscedastic textbook sample. It supports comparing estimation, uncertainty and prediction procedures under known but imperfect assumptions. The finite realization will not reproduce population coefficients exactly, and adding the latent variable does not force its estimate to equal four. A seed ensures reproducibility of this record; it does not make the fitted associations causal or make the sample representative of a real business.

Specify the candidate model before inspecting the holdout

The baseline design matrix contains an intercept, price, advertising, promotion and month. The prespecified alternative adds price times promotion. Fit both using months 1–24. Compare one-step rolling-origin errors within the development interval using origins after months 16–23; every fit uses only observations already available at that origin. The fictional prespecified selection rule retains the simpler baseline unless the interaction reduces development rolling RMSE by at least 5 percent. Freeze that choice before evaluating once on the locked eight-month holdout. The oracle model adding z is a teaching contrast, not a deployable candidate.
Keep a specification ledger: model name, columns, estimation window, transformation, uncertainty procedure and reason for revision. A residual-driven change is allowed during development, but it must be recorded. Repeatedly checking months 25–32 and then claiming they remained an untouched test set would invalidate the evaluation design. A final model can later be refitted on more data for deployment, but its honest performance estimate must come from an evaluation that did not train on those outcomes.

Preserve records, units and reproduction details

Before fitting, check that every month occurs once, promotion is zero or one, numeric values are finite and no outcome has been accidentally included as a predictor. The intercept is an explicit column of ones. The supplied Python analysis saves the CSV record and a JSON output record, solves least squares with a rank-revealing routine and computes covariance and influence formulas transparently. The raw table below contains all observations, so the numerical example can be reproduced independently without access to a hidden dataset.
A reproducible report also identifies which variables are known at the prediction origin and which are available only for teaching. Latent demand must not leak into the deployable forecast. A missing future price plan would require a scenario forecast or a separate price model. Data provenance, timing and the target population are part of the statistical specification, not administrative decoration. The later chapters keep this same record so that model revision can be evaluated against an explicit baseline.

Worked records

Record 1

Original fictional data. Development months 1–24; holdout months 25–32. The latent column is unavailable to deployable forecasts.

MonthPriceAdvertisingPromotionSalesLatent demand (teaching only)
118.1238.856078.974-1.425622
219.09310.457081.465-0.73106
318.51411.251086.553-0.642607
420.68612.137193.1790.045735
520.6398.448078.4140.024838
623.5818.944076.9871.348988
718.50810.051081.927-1.782163
821.30910.834186.795-0.162799
923.46612.147084.4891.965785
1024.3827.855074.1181.861637
1121.1089.539083.9320.664559
1221.66410.07195.9120.68905
1322.57810.656090.5260.821221
1419.9312.382094.656-0.96925
1520.1198.06082.959-1.855033
1620.5869.021197.878-0.591352
1724.5949.471081.0131.295498
1822.09910.76090.745-0.081415
1923.66512.155094.9060.946011
2023.3228.437191.6790.392935
2122.0828.905089.146-0.122266
2221.53610.2850100.215-0.874577
2322.8310.483094.095-0.139341
2421.43312.371107.48-0.711875
2523.6348.074084.0240.332694
2625.6159.238089.6631.775892
2723.09810.24097.393-0.292198
2825.47411.8391106.2721.85641
2923.412.024098.106-0.212071
3025.3888.551082.7571.41569
3123.3639.104081.779-0.822503
3224.5239.533193.4590.75361

Develop the reasoning

The baseline has n=24 rows and k=5 coefficients, leaving 19 residual degrees of freedom. The interaction model has k=6 and 18 degrees of freedom. Both designs have full column rank in this record. The holdout has eight rows and is not used to estimate either candidate. The generator and raw records are saved alongside this course as mba614-analysis.py, mba614-data.csv and mba614-outputs.json.

Progressive practice — optional

1. Foundation

Identify the outcome, units and deployable predictors.

Compare the worked reasoning

Outcome is sales in hundreds; predictors are planned price, advertising, promotion and known calendar month. The latent column is teaching-only.

Change the record

Advertising becomes known only after sales close.

Compare the changed-record reasoning

It is unavailable at the stated origin. Replace it with a genuinely known plan, forecast it separately or redefine the prediction time; do not use the realized value silently.

2. Application

Calculate residual degrees of freedom for the baseline and interaction models.

Compare the worked reasoning

24-5=19 and 24-6=18, assuming full rank.

Change the record

A duplicate intercept column is added.

Compare the changed-record reasoning

The nominal column count rises, but rank does not. The design is rank deficient and individual duplicate-intercept coefficients are not identified; use rank, not a naive column count.

3. Transfer

Can adding the latent variable prove deployment performance?

Compare the worked reasoning

No. It is unavailable when decisions are made and changes the information set.

Change the record

An independently measured demand index becomes available before each month.

Compare the changed-record reasoning

That creates a new deployable predictor, but its measurement quality and availability must be documented and a new out-of-time evaluation conducted; the oracle result is not automatically its performance.

Sources and scope