Lawfare Academy · Complete Regression Analysis for Business edition 3
Diagnostics, covariance and a reproducible uncertainty calculation
The retained diagnostic companion already supplies the full original eight-row classical, HC 1 and deliberately inadequate two-cluster calculations, leverage and large-account sensitivity. Preserve those numbers and their qualifications. This studio develops the diagnostic workflow and covariance mechanics alongside a separate Willow four-row example. No formula or software option is a substitute for a design argument.
Diagnose distinct problems separately
A residual is observed minus fitted response. Plot residuals against fitted values, each important predictor, group and observation time. Curvature can suggest a missing mean term; changing spread can suggest conditional variance differences; runs over time can suggest dependence. None identifies its cause uniquely. An incorrect unit, an omitted interaction and a selected sample can produce patterns requiring different responses. Inspect definitions and substantive mechanisms before mechanically adding a term.
Leverage concerns location in predictor space. In a full-rank least-squares design, the projection matrix is H=X(X'X)⁻¹X', and its diagonal entries sum to the number of fitted coefficients. A high-leverage row can pull a fit strongly even with a small residual. Influence measures how the fitted relationship changes under a specified perturbation, such as leaving one row out; it combines design position and residual departure. A threshold is a screening aid, not permission to delete valid data.
Standardized or studentized residuals compare departures on a variance scale, sometimes adjusting for leverage. Cook-style influence measures and deletion diagnostics summarize sensitivity under their definitions. They do not determine whether an observation is erroneous or whether the population should exclude it. Report documented corrections separately from analyses with and without legitimate observations. If a small change reverses a consequential recommendation, investigate model form and support rather than conceal the reversal.
Multicollinearity concerns relationships among design columns. Exact dependence prevents a unique unrestricted coefficient vector; near dependence can amplify variance and sensitivity. It does not automatically bias an otherwise appropriate OLS estimand. Centering can improve a reference interpretation but cannot create missing independent information. Residual orthogonality is a projection identity and does not verify exogeneity, normality or the conditional mean.
Covariance follows the observation process
Let A=(X'X)⁻¹ for a full-rank design, p count all fitted coefficients including the intercept, and e the residual vector. The classical estimated covariance is [SSE/(n−p)]A under the stipulated constant-variance conditional-error model. Its exact finite-sample t interpretation requires additional assumptions. Homoskedasticity describes equal conditional variance, not equal fitted values or equal observed residuals.
With conditionally heteroskedastic but suitably independent observations, the HC 0 sandwich is A[sum(xi xi' ei²)]A. HC 1 multiplies this matrix by n/(n−p). Other HC definitions adjust residuals and leverage differently. The official statsmodels HC 1 reference was consulted for this specific correction; the word robust does not identify one universal estimator. Changing covariance retains the OLS point estimates and fitted values. It does not remove omitted-variable confounding, a wrong mean, leakage or selection.
For genuine clusters, form each cluster score sg=sum(xi ei)within that cluster, then use A[sum(sg sg')]A with the stated finite-sample correction if one is used. This retains within-cluster cross-products omitted by row-level HC calculations. The grouping must reflect dependence or assignment rather than a preferred p-value. HAC methods instead target specified time dependence using lagged score covariances and a chosen weighting/bandwidth convention. Neither is automatically appropriate merely because rows have dates or group labels.
Routine cluster asymptotics rely on sufficient independent cluster information and other regularity conditions. Two clusters do not become many when each acquires thousands of rows. Unequal cluster size, leverage or few treated clusters can further weaken an approximation. Corrections, appropriate cluster resampling and design-based alternatives have assumptions and limitations of their own; an arbitrary bootstrap or a tcritical with G−1 degrees of freedom is not a universal repair. State a narrower claim or seek more independent information when a defensible uncertainty procedure is unavailable.
The introduction, basic covariance discussion and opening few-cluster discussion in Cameron and Miller's 2015 paper were consulted for the dependence and finite-cluster limitations. Historical software commands, numerical simulations and a universal cluster-count cutoff are not adopted here. The original companion's two-cluster result remains an algebra illustration, explicitly without routine nominal-coverage approval.
Independent Willow covariance reconstruction
For the separate rows(0,1),(1,2),(2,2),(3,5), the line is 0.7+1.2 xwith residuals 0.3,0.1,−1.1,0.7 and Sxx 5. Leverage equals 1/4+(x−1.5)²/5, giving 0.7,0.3,0.3,0.7; the sum is 2, matching the intercept and slope. Do not transplant the original eight-row leverage values into this independent fit.
The classical slope variance is[SSE/(4−2)]/Sxx=0.9/5=0.18. The HC 0 slope variance in this simple intercept case is sum[(x−xbar)²e²]/Sxx². The numerator is 0.2025+0.0025+0.3025+1.1025=1.61, giving 0.0644. HC 1 doubles it to 0.1288. Its SE is approximately 0.358887, smaller than the classical SEapproximately 0.424264. A robust SE need not be larger. Four constructed rows do not establish that either interval procedure has reliable coverage in an actual population.
For any linear fitted contrast c'b, use c'Vcand the reference distribution justified by the design. A prediction interval needs the additional variation of the future outcome and a relevant forecast-error model. A coefficient interval cannot simply be relabeled a business outcome range. The original companions explicitly retain those distinctions, including covariance for their combined x andDcontrast.
A diagnostic decision record
Record the issue, evidence, interpretation, proposed response and unresolved assumption. For a unit error, correct with an audit trail. For unsupported extrapolation, restrict the claim or obtain relevant support. For a plausible missing interaction, compare a substantively justified model and validate its consequences. For dependence, justify a covariance or inference method using the actual observation process. For a valid influential customer, show sensitivity and reconsider the target rather than optimize the result by deleting the record.
Optional complete models
Model 1 — A smaller HC 1 standard error is called an error
Willow's classical slope variance is 0.18, while HC 0 is 0.0644 and HC 1 is 0.1288. Their direction differs because the covariance formulas weight the residual pattern differently. Changed fact: residual spread or design leverage changes. Recompute the full relevant sandwich; do not force the robust value to exceed the classical one. Neither arithmetic comparison alone validates a coverage claim in a tiny constructed sample.
Model 2 — Rows are counted instead of independent clusters
The original companion's two-cluster illustration does not justify routine many-cluster inference. Changed fact: each group now contains 5,000 rows but the same shared cluster shocks. G remains 2. A larger row count cannot establish the missing asymptotic justification. Report what is supported and seek an actual design or defensible finite-sample method rather than manufacture a confidence label.
Model 3 — A valid influential observation is removed for its sign
The original large-account sensitivity changes the indicator from 5 to−205/33. First verify units, definition, timing and target population. Changed fact: the extra account was recorded in cents while all others use dollars. Correct the documented measurement inconsistency and refit, preserving the audit trail. That is a different action from deleting a valid account solely because it reverses a conclusion.
Optional rubric 20 points: separate diagnostic mechanisms 4; complete classical/HC/cluster construction 4; actual design and finite-sample limits 4; prediction and contrast uncertainty 4; complete changed-fact response 4. No learner records or real customer data are used. Human subject review and observed learner testing remain separate pending tasks.