Lawfare Group → Knowledge Institute → Lawfare Academy

← Course syllabus · Related lesson

Diagnose the mean and choose uncertainty for the observation process

Current complete on-site native edition3

All required original teaching, complete derivations and optional practice models are on LawfareGroup.com. External references are optional provenance or further reading. Florida is the state-law default; federal, historical and comparative contexts remain distinct. Independent human subject review and observed learner testing remain pending. Synthetic economic models establish no actual market response, legal clearance or professional competence.

Preserved and additional cumulative dossiers

Original extended teaching; see the linked current course-content review for its development status. Practice is optional; independent academic review and learner testing remain pending.

Learning objectives

Inspect the fitted relationship before selecting a standard error

Use the eight-row dataset from unit two. The additive fit is yhat=10+2x+5D, with residuals −1.5, −.5, .5, 1.5 in the first group and 1.5, .5, −.5, −1.5 in the second. The total residual sum and each design-column residual cross-product are zero. That orthogonality is an algebraic consequence of least squares, not evidence that the mean specification is adequate. Within-group residual patterns show opposite slopes. Plot residuals against x with group labels; the interaction model in unit three explains those patterns exactly in this deliberately constructed sample.

A residual plot can suggest a missing term, scale dependence or a recording error, but it does not uniquely identify a cause. Compare a defensible alternative mean specification, substantive process knowledge and out-of-sample behavior. Adding enough terms can fit a small sample perfectly while making prediction unstable. A perfectly fitted teaching dataset does not mean future observations have zero noise. State which changes were exploratory and what further evidence would evaluate them.

Leverage concerns a row's position in the design, while a residual concerns its vertical departure from the fitted response. Influence combines these features and depends on the fitted model. For the additive example, leverage is .475, .275, .275, .475 in each group and sums to the three fitted parameters. The sum is a projection identity; it does not make .475 an automatic deletion threshold. Check a flagged observation against the underlying definition and measurement process, then report sensitivity rather than silently remove a valid large customer.

Three covariance calculations answer different conditional questions

For a full-rank design X, OLS b=(X′X)⁻¹X′y. Under the classical conditional homoskedastic model, estimated covariance is s²(X′X)⁻¹, where s²=SSE/(n−p) and p includes the intercept. Our sample has SSE=10, n=8 and p=3, so s²=2. The x-slope variance is .2 and its standard error is about .4472. A finite-sample t interpretation adds distributional assumptions; the matrix formula alone does not establish coverage.

HC0 replaces the constant-variance middle term with the sum of x_i x_i′ e_i². HC1 multiplies that sandwich by n/(n−p). The official statsmodels reference specifies this particular correction; robust software options with other names need not be identical. In this constructed sample HC1's x-slope variance is 41/125=.328, giving standard error about .5727. Both procedures retain the same OLS coefficient 2. Changing covariance does not change the fitted mean or make its omitted interaction disappear. With eight observations, asymptotic justification is especially limited; these values illustrate formulas rather than validate a real population interval.

When errors can depend within a genuine independent sampling or assignment cluster, cluster scores sum x_i e_i within each cluster before the sandwich is formed. That retains within-cluster covariance terms that row-level HC methods omit. The cluster definition must follow how information or shocks are shared, not whichever grouping makes a result favorable. Cameron and Miller explain the many-independent-cluster conditions and complications from few clusters. More rows in two groups do not create many independent clusters.

Refuse unsupported precision and report sensitivity

For illustration only, group these eight rows by D. A common CR1 factor is [G/(G−1)]×[(n−1)/(n−p)]=14/5 for G=2. The resulting slope variance is 7/5 and standard error about 1.1832. Two clusters are intentionally inadequate for routine many-cluster inference. Do not attach a nominal confidence claim to that calculation or conclude that switching to a cluster label solves the design. A real analysis needs defensible dependence assumptions, enough independent information and an appropriate finite-sample strategy or a narrower claim.

Now add a valid large observation x=20, D=1, y=100. The additive coefficients become approximately 5.6061, 4.9293 and −6.2121. The indicator coefficient changes sign. First investigate whether the row uses the same unit, timing and outcome definition; if valid, the larger support and its weight may materially change the target relationship. Compare model fit, interaction or nonlinear alternatives and the intended prediction population. Report estimates with and without the row as sensitivity, with reasons, rather than present the favorable estimate alone.

A useful diagnostic memo separates recording mistakes, support limitations, mean misspecification, dependence and sensitivity to influential observations. State a response to each: correction with an audit trail, restricted extrapolation, a justified alternative model, design-appropriate uncertainty or additional independent data. None of these operations by itself identifies a causal effect. Do not trade a precise unsupported claim for a vague statement that everything is uncertain; specify what the data do support and which decision remains unresolved.

Worked example: Reconcile covariance without changing the estimate

The slope is 2 under the classical and HC1 calculations. Classical variance is .2; HC1 variance .328. Their square roots are approximately .4472 and .5727. The larger HC1 value does not establish that HC1 is correct in this tiny misspecified sample. Show the residual interaction pattern separately and distinguish the mean-model problem from the variance-model calculation.

Worked example: A large valid account changes the fitted question

Adding x=20, D=1, y=100 yields b0=185/33, bx=488/99 and bD=−205/33. The indicator becomes negative even though its earlier estimate was 5. Inspect support, functional form and the account definition. Deleting the account solely to recover a positive indicator selects the result rather than repairs evidence. A population including large accounts may require a materially different model or weighting target.

Progressive optional practice

Attempt each problem before opening its model. Then revise the reasoning under the changed conditions.

Compute

Calculate the classical slope SE from variance .2 and HC1 SE from .328. What does their difference establish?

Compare the model reasoning

The values are approximately .4472 and .5727. They show different estimated covariance assumptions, not proof of correct coverage, causality or a correct mean.

Changed conditions

The residuals also have opposite group slopes.

Compare the revised analysis

Investigate the mean specification separately. Robust covariance cannot remove that systematic pattern.

Diagnose

An analyst reports a 95% cluster-robust interval from the example’s two groups. Is that supported by the routine many-cluster argument?

Compare the model reasoning

No. Two independent clusters do not support that asymptotic argument. Report the algebra as an illustration and seek a defensible design or narrower claim.

Changed conditions

There are now 10,000 rows but still only two independent clusters.

Compare the revised analysis

The number of independent clusters remains two; a large row count does not remove the problem.

Transfer

A large valid customer reverses an indicator coefficient. Should the analyst remove it?

Compare the model reasoning

Not merely because it changes the result. Verify measurement, define the target population, investigate model form and report sensitivity transparently.

Changed conditions

The customer’s revenue was recorded in cents while others use dollars.

Compare the revised analysis

That is a documented measurement inconsistency. Correct units with an audit trail and refit; this is different from deleting a valid inconvenient observation.

Current development backlog and remaining course work · Course content review

Source readings and scope

Introductory Business Statistics 2e — 13.6 Predicting with a Regression Equation — Optional preserved methodological provenance. Complete current on-site studios and preserved full original applications supply all required teaching. Data and estimates are synthetic; they do not describe actual customers or learner records. Statistical relationships do not establish causal, legal or professional approval. Florida is the state-law default; federal rules remain federal and historical other-state examples are comparative. No source affiliation or independent review of this course is claimed.

statsmodels official reference — HC1 standard errors — Optional preserved methodological provenance. Complete current on-site studios and preserved full original applications supply all required teaching. Data and estimates are synthetic; they do not describe actual customers or learner records. Statistical relationships do not establish causal, legal or professional approval. Florida is the state-law default; federal rules remain federal and historical other-state examples are comparative. No source affiliation or independent review of this course is claimed.

Cameron and Miller — A Practitioner’s Guide to Cluster-Robust Inference — Optional introduction and clustering/few-cluster provenance; complete on-site explanations, covariance constructions and limitations are supplied. The course’s two-cluster calculation illustrates the formula and explicitly does not claim reliable nominal coverage.

NIST/SEMATECH — Linear Least Squares Regression — Optional preserved methodological provenance. Complete current on-site studios and preserved full original applications supply all required teaching. Data and estimates are synthetic; they do not describe actual customers or learner records. Statistical relationships do not establish causal, legal or professional approval. Florida is the state-law default; federal rules remain federal and historical other-state examples are comparative. No source affiliation or independent review of this course is claimed.

Reproduce the worked examples in Python 3. Standard library only; synthetic data; no production records or network access.