Lawfare Academy ยท Complete Regression and Business Forecasting edition 6
From paired measurements to a conditional business model
The measurement contract precedes the coefficient
The outcome and predictor must be paired at the same observation unit. If advertising is recorded by branch-month and sales by individual invoice, copying a branch's advertising total onto every invoice creates repeated exposures rather than independent branch experiments. Define the observation, eligible population, period, currency or physical units, missing-value policy and availability date. Preserve a zero outcome when it is a genuine zero; distinguish an unrecorded sale from no sale. A completed-job sample also omits rejected and canceled work. Its relation need not describe all quoted jobs.
A scatterplot places each paired predictor x and outcome y at a point. Inspect direction, curvature, spread, clusters and support before summarizing. The axes carry substantive meaning. An empty region is missing support, not evidence that the relationship continues smoothly through it. Connecting points in collection order can invent a trajectory when the observations are unrelated businesses; time order instead deserves a separate plot when dependence matters.
For n paired observations, compute xbar and ybar, then Sxx=sum((x-xbar)^2), Syy=sum((y-ybar)^2) and Sxy=sum((x-xbar)(y-ybar)). Pearson's sample correlation is r=Sxy/sqrt(Sxx*Syy) when both sums of squares are positive. Centering removes the arbitrary zero points; dividing by the two scales makes r dimensionless. Positive r indicates an increasing linear association and negative r a decreasing one. Its magnitude summarizes linear alignment, not every possible relation. A symmetric U-shaped relationship can have correlation zero while remaining strongly predictable through a quadratic mean.
The bound -1<=r<=1 follows because the squared length of any centered residual vector cannot be negative: minimize sum((y-ybar)-b(x-xbar))^2 over b to obtain Syy-Sxy^2/Sxx>=0. Thus Sxy^2<=Sxx*Syy. Equality means the centered observations lie exactly on a line in this sample. It supplies no guarantee of future fit. If a variable is constant, correlation is undefined; reporting zero would incorrectly assert a measured absence of association.
Worked record: the same correlation supports different questions
Use four independent synthetic branch records x=(1,2,3,4), y=(2,4,5,7), with x measured in thousands of advertising dollars and y in thousands of sales dollars. The means are 2.5 and 4.5. Centered sums are Sxx=5, Syy=13 and Sxy=8. Hence r=8/sqrt(65), approximately 0.992277877. The least-squares line is yhat=0.5+1.6 x. Correlation has no currency units, whereas the slope means 1.6 thousand fitted sales dollars per thousand advertising dollars under this model.
At x=3 the fitted outcome is 5.3, while the observed value is 5, giving residual -0.3. The fitted values are 2.1,3.7,5.3,6.9 and SSE=0.2. With an intercept, R-squared=1-SSE/Syy=1-0.2/13=0.984615385, equal to r-squared in this simple one-predictor fit. It is a fraction of observed centered outcome variation accounted for by this fitted line. It is not a percentage accuracy score, a causal share of sales or an expected return on spending.
The descriptive question is how these branches differ. A predictive question asks whether a model fitted on an admissible history predicts genuinely later branches or periods. A causal question asks what would happen if spending were changed under a specified intervention. Branch size, expected demand or management quality could affect both recorded spending and sales. Neither high r nor small residuals resolves those pathways. Preserve the existing Academy season-adjustment and training-composition cases: they demonstrate precisely why a pooled slope and a justified intervention effect are different objects.
Transformations and contrasts that preserve meaning
Adding 100 to every sales value leaves Syy, Sxy, r, slope, residuals and R-squared unchanged; the intercept rises to 100.5. Multiplying sales by 1,000 changes the outcome unit, multiplying slope, intercept and residuals by 1,000 and both SSE and Syy by 1,000,000. Correlation and R-squared remain unchanged. Reversing the sign of exactly one measurement reverses correlation; it is not a new business mechanism. Swapping x and y leaves correlation unchanged but changes the prediction task: regressing advertising on sales is generally not the algebraic inverse of the sales-on-advertising regression.
Here the reverse slope is Sxy/Syy=8/13 and reverse intercept=2.5-(8/13)*4.5=-7/26. Solving the original fitted equation for x instead gives slope 1/1.6=0.625 and intercept -0.3125. The reverse fitted slope is approximately 0.615384615, so these are distinct lines. Each least-squares problem minimizes vertical errors in a different outcome. Choose the outcome according to the decision and measurement process; do not reverse a fitted equation merely because today's missing quantity is different.
A significance calculation has a model boundary
For independent observations from the conventional bivariate-normal zero-correlation null model, t=r*sqrt((n-2)/(1-r^2)) has n-2 degrees of freedom under the null. In this four-record example, t=sqrt(128), approximately 11.3137085, with two degrees of freedom. This is also the simple-regression zero-slope test under its corresponding classical assumptions. The exact small-sample reference is a model-based claim. Clustered branch records, selective outcome reporting, dependence or model search invalidate treating the printed reference as automatic.
A p-value measures a tail probability under the specified null and procedure. It does not give the probability that advertising causes sales, the probability that a null hypothesis is true or the chance that a commercial decision will succeed. Report the observed effect, units, sample size, support and design alongside any inferential calculation. Repeatedly testing many outcomes and retaining the smallest p-value changes the selection procedure. Four artificial observations illustrate arithmetic; they are not an empirical campaign evaluation.
Optional practice with complete model reasoning
Guided: changed outcome units
Convert sales from thousands of dollars to dollars. Give the line and correlation. Model: yhat_dollars=500+1600 x; r stays 8/sqrt(65). Residual at x=3 becomes -300 dollars. Changed fact: advertising is also converted to dollars. Revised model: yhat_dollars=500+1.6*x_dollars. Changing both units preserves the numerical slope here, while changing only the outcome does not. Always state the units rather than inferring them from coefficient size.
Independent: prediction versus reverse fitting
A colleague estimates missing advertising by solving the original line at sales y=5. Model: the solved original line gives x=(5-0.5)/1.6=2.8125. The separately fitted advertising-on-sales line gives x=-7/26+(8/13)*5=73/26, approximately 2.807692308. Neither estimate is a validated missing-data procedure. Changed fact: all observations lie exactly on an increasing straight line with nonzero predictor variation. Then r=1 and the reverse least-squares line coincides with the algebraic inverse, but out-of-sample and causal limitations still remain.
Transfer: apparently perfect evidence
A report gives r=0 for x=(-2,-1,0,1,2) and y=(4,1,0,1,4) and concludes size has no relationship with cost. Model: xbar=0 and Sxy=0 by symmetry, so the correlation is zero; nevertheless y=x^2 exactly in these five constructed records. Plot and assess a substantively justified curved model instead of declaring independence. Changed fact: every x equals 2. Correlation and the simple-regression slope are undefined because Sxx=0. Obtain predictor variation or restrict the question to estimating an outcome level at that fixed x; software cannot recover an unsupported slope.
Integrated decision and rubric: 20 points
Write a one-page recommendation for using the four-branch record to set next quarter's advertising budget. Award four points each for (1) observation/measurement/availability contract; (2) reproducible centered sums, r and line; (3) correct dimensional and R-squared interpretation; (4) explicit separation of description, prospective prediction and causal intervention; (5) changed-fact response and an admissible next evidence collection.
Complete model: state the branch unit and fictional scale; show 5,13,8 and r approximately .992278 with fitted line .5+1.6 x. Treat the 98.46 percent R-squared as in-sample explained variation only. Decline to call 1.6 a return on an extra advertising dollar. Preserve possible size/season/selection explanations, avoid extrapolation beyond x=1 through 4 and specify a later prediction evaluation using only then-available inputs. For a budget intervention, define the eligible branches, assignment mechanism, outcome horizon, spillovers and business cost before seeking causal evidence. A new randomized budget study may improve identification; it does not automatically establish transportability or remove outcome-measurement and compliance problems. No learner must submit this exercise to read the course.
Optional source summary: NIST linear least squares was read for linearity in parameters and model limitations. The paired data, correlation derivation and complete practice here are original Academy teaching. Required learning is entirely on site.