Lawfare Academy · Complete Regression Analysis for Business edition 3

Contrasts, coding, correlation tests and transformed targets

Preserve the actual original interaction 8.5+3 x+12 D−2 xD, its centered 20.5+3 z+4 D−2 zDform, support limits and log-mean example. The new Willow function below is a separate teaching relationship, not a refit of the original eight rows. This studio supplies additional testing and interpretation preparation alongside that full companion.

A code is a claim about comparisons

A categorical variable with kcategories commonly uses an intercept and k−1 indicators with one reference category in a full-rank design. Including every category indicator and an intercept creates an exact redundancy. The omitted category is a reference, not a discarded population. Coefficients compare modeled outcomes under the chosen coding and other included conditions. Change the reference consistently and fitted values should remain unchanged, though individual coefficient labels and their tests can change.

An interaction allows the contrast for one variable to depend on another. A group-specific slope is a sum of relevant coefficients, and a group difference can vary with x. A quadratic term creates a local slope depending on x even while the model remains linear in unknown coefficients. Keep the meaningful lower-order terms when making an equivalent recoding; omitting one changes the fitted family rather than merely changing labels.

Use independent Willow yhat=4+2 x+3 D+xD. At D 0 the slope is 2 and at D 1 it is 3. The group contrast at xis 3+x. Center at x 2 with z=x−2: the same function is 8+2 z+5 D+zD. At x 2, predictions are 8 and 13 and contrast 5. If the indicator is reversed to E=1−D, the function becomes 7+3 x−3 E−xE. Verify predictions by substituting, not by calling the new negative indicator a reversal of the underlying data relationship.

If the observations contain only D 0 at small x andD 1 at large x, a same-xgroup contrast may be extrapolated even when the formula is easily evaluated. Centering does not supply missing overlap. Standard errors for combined coefficients require covariance. For a linear contrast c'b, its variance is c'Vc, where V must match the actual inferential design. A coefficient's standalone SE does not answer every contrast question.

A test addresses a specified hypothesis and design

For a simple correlation coefficient from independent pairs under the matching bivariate-normal null model, t=r sqrt((n−2)/(1−r²))with n−2 degrees of freedom tests zero population correlation. Define the direction of the alternative in advance. It does not test all possible nonlinear dependence, and dependence or a selected population can invalidate its ordinary interpretation. The formula does not apply at r=±1 without handling the degenerate boundary.

In the separate four-row Willow regression from the prior studio, r²=0.8 and n 4 produce t²=8 against zero. That is algebra under stipulated assumptions, not a claim that four constructed rows validate a real test. In a multiple-regression context a slope or joint contrast test requires the corresponding coefficient covariance, restrictions and error model. Squaring the simple correlation statistic does not test every multivariable hypothesis.

An overall Fcomparison in the classical linear model can test specified nested restrictions by comparing restricted and unrestricted residual sums of squares with their parameter and residual degrees of freedom. The models must use the same compatible outcome and observations, and the exact classical reference distribution needs its assumptions. Heteroskedasticity-robust Wald procedures use a different covariance construction and often an asymptotic justification. Neither label creates causal identification, adequate clusters or correct functional form.

Interpret transformations in their actual units

In a level-level equation, a coefficient's units are outcome units per predictor unit under its specified contrast. In a log-log function, the coefficient is a model elasticity; in a log-level function, a finite change in a predictor generally implies exp(beta×change)−1 as the proportional fitted-level factor under the matching interpretation. A small-change percentage approximation is useful only when its approximation error is acceptable and its conditions are stated.

For independent Willow log Q=a−0.8 log P, a 25 percentpriceincrease gives exact ratio 1.25^(−0.8), approximately 0.836512, or 16.3488 percentlower. The local approximation−0.8×25 percent=−20 percentis not exact for that finite move. This assumed demand response is not a causal estimate for a real product. A varying-elasticity model would require its own fitted contrast, not this constant-power formula.

For a log outcome, exponentiating a fitted conditional log mean generally differs from the conditional arithmetic mean in levels. The original companion's 50/200 outcomes demonstrate this completely. Retransformation needs an appropriate residual-distribution or conditional-mean argument; changing residual variation across groups can defeat a common multiplier. Adding one to handle zeros changes the model and units. Missing, censored, count or nonpositive outcomes may need a different specification or a narrower target.

Optional complete models

Model 1 — Reversing the indicator is called a reversed effect

Willow's original Dcontrast is 3+x. With E=1−D, the equivalent function 7+3 x−3 E−xEhas the opposite reference comparison. At x 2 the same two fitted outcomes remain 8 and 13. Changed fact: the analyst drops the xEterm. That is no longer equivalent coding, so changed predictions are a changed model rather than evidence that reference selection changed the underlying observations.

Model 2 — A simple correlation test is used for a different design

The separate Willow four-row simple fit gives r²0.8 and t²8 with two residual degrees of freedom under its hypothetical independent normal setup. Changed fact: the four rows are repeated records from one dependent account. The ordinary independent-pair reference distribution is unsupported. The same sample rcan still be described, but a nominal test or interval requires the actual dependence model and independent information.

Model 3 — A finite log change is replaced by its tangent

For Willow elasticity−0.8 andprice factor 1.25, compute the power 1.25^(−0.8)rather than treating−20 percentas exact. Changed fact: the price move becomes onepercent. The power 1.01^(−0.8)can be compared with the closer local approximation−0.8 percent, but the approximation remains distinct. Neither calculation proves an actual intervention response or expected revenue in levels.

Optional rubric 20 points: complete coding/interaction contrasts 4; covariance and hypothesis definition 4; simple versus multiple/design-specific tests 4; finite transformation/target interpretation 4; changed-fact revision 4. Critical-value consultation and any software execution will be recorded only when actually performed. Human subject review and observed learner testing remain separate pending tasks.