Learn OLS regression with 26 solved exercises, clear formulas, confidence intervals, correlation, and corrected numerical examples.

OLS Regression: 26 Solved Exercises and Formulas

OLS Regression: 26 Solved Exercises and Formulas
ECONOMETRICS · COMPLETE WORKED GUIDE

From the least-squares derivation to hypothesis tests, rank correlation, and a carefully audited economic example.

OLS regression turns paired observations into a fitted relationship that you can estimate, test, and interpret. However, a convincing analysis requires more than a slope and a high R². This guide solves 26 exercises, numbered 6.5 through 6.30 in the supplied material, while explaining the assumptions and calculations behind every major result.

Along the way, you will calculate a consumption equation, test its coefficients, build confidence intervals, and analyze income across 15 Latin American countries. In addition, you will see how rounding, tied ranks, and a single inconsistent data entry can change an answer. Every numerical table below uses calculations from the supplied observations unless its caption explicitly says otherwise.

Source and scope: The exercise numbering and datasets come from the uploaded chapter pages, headed “Simple Regression Analysis.” The images do not establish the book’s complete bibliographic details, so this guide does not invent an author or edition. Explanations and solutions use original wording, and the external links support the statistical methods. Only fragments of exercises 6.31 and 6.32 appear; their complete questions are unavailable, so the solved sequence ends at 6.30.

OLS regression notation and assumptions

A simple regression relates one outcome, Y, to one explanatory variable, X. For example, Y might represent consumption, while X represents disposable income. The model separates a systematic relationship from an unobserved disturbance.

Yi = β0 + β1Xi + ui
Ŷi = b0 + b1Xi
ei = Yi − Ŷi

Here, β denotes a population parameter, while b denotes its sample estimate. The photographed chapter uses hats on estimated b coefficients; this article uses β and b to make the distinction easier to read. Therefore, b₀ and b₁ below correspond to the chapter’s estimated intercept and slope.

SymbolMeaningPractical interpretation
nNumber of observations12 for consumption; 15 for the country exercise
X̄, ȲSample meansThe fitted line passes through this pair when it includes an intercept
xᵢ = Xᵢ − X̄Centered explanatory variableDistance from the sample mean of X
yᵢ = Yᵢ − ȲCentered outcomeDistance from the sample mean of Y
Sxx = Σxᵢ²Variation in XMust exceed zero to identify a slope
Sxy = ΣxᵢyᵢCross-product sumDetermines the slope’s direction
Syy = Σyᵢ²Total centered variation in YAlso called SST in this article
SSE = Σeᵢ²Residual sum of squaresUnexplained variation
SSR = Σ(Ŷᵢ − Ȳ)²Regression sum of squaresVariation accounted for by the fitted line

Which assumptions support which conclusions?

GoalConditions used hereWhat can go wrong
Calculate a unique fitted lineAn intercept and Sxx > 0Identical X values prevent separate slope identification
Show unbiasednessCorrect linear conditional mean; E(u | X) = 0Omitted confounders or simultaneity can bias the slope
Use conventional standard errorsVar(u | X) = σ²IUnequal variances or correlated errors invalidate the usual variance formulas
Claim BLUEFull rank, zero conditional mean, constant variance, uncorrelated errorsOLS need not remain the most efficient linear unbiased estimator
Use exact small-sample t testsConditional normality in addition to the classical error assumptionsWithout normality, small-sample reference distributions need not be exact
Give a causal interpretationA credible identification strategy beyond a fitted lineAssociation alone does not establish an intervention effect

Importantly, normality does not determine whether you can calculate OLS coefficients. Instead, it supports exact finite-sample inference under the classical model. StatLect’s Gauss–Markov discussion explains the narrower meaning of “best”: lowest variance within the class of linear unbiased estimators under the stated assumptions.

Exercises 6.5–6.8: derive and understand OLS regression

Exercise 6.5: why minimize squared vertical residuals?

OLS chooses the intercept and slope that minimize the sum of squared vertical gaps between observed and fitted Y values. Because the model predicts Y conditional on X, each gap measures an error in the outcome’s units. In contrast, a horizontal gap corresponds to predicting X from Y, which answers a different question.

Q(b0, b1) = Σ(Yi − b0 − b1Xi)²

For example, residuals of +4 and −4 sum to zero despite substantial errors. Squaring produces 16 + 16 = 32, so opposite signs no longer cancel. Moreover, doubling a residual multiplies its contribution to the objective by four.

Minimizing the raw sum of residuals is not a meaningful alternative: increasing the intercept can drive that signed sum toward negative infinity. At an OLS optimum with an intercept, the sum equals zero because of a normal equation. However, many other lines can also have a zero residual sum, so zero alone cannot identify the best fit.

Absolute residuals also avoid cancellation. Indeed, least absolute deviations offers a legitimate alternative that targets a conditional median under appropriate conditions. OLS uses a smooth quadratic objective and targets the conditional mean under the stated model; the choice should reflect the research goal, not a claim that squaring is universally superior.

For a concise institutional explanation of the least-squares objective, see NIST’s linear least-squares overview.

Exercise 6.6: derive the two normal equations

First, differentiate Q with respect to the intercept. Next, set the derivative equal to zero and rearrange the result.

∂Q / ∂b0 = −2Σ(Yi − b0 − b1Xi) = 0
ΣYi = nb0 + b1ΣXi

Similarly, differentiation with respect to the slope weights each residual by X. Therefore, the second normal equation requires the weighted residual sum to vanish.

∂Q / ∂b1 = −2ΣXi(Yi − b0 − b1Xi) = 0
ΣXiYi = b0ΣXi + b1ΣXi²

Together, these equations imply Σeᵢ = 0 and ΣXᵢeᵢ = 0. Furthermore, Q is a convex quadratic. Its Hessian has determinant 4nSxx, so Sxx > 0 makes the stationary point the unique minimum rather than a maximum or saddle point.

Exercise 6.7: solve for the slope and intercept

Multiply the slope normal equation by n. Then multiply the intercept normal equation by ΣXᵢ and subtract the second result from the first. The intercept term cancels, leaving an equation with only b₁.

nΣXiYi − (ΣXi)(ΣYi)
= b1[nΣXi² − (ΣXi)²]
b1 = [nΣXiYi − (ΣXi)(ΣYi)] / [nΣXi² − (ΣXi)²]
= Sxy / Sxx

b0 = Ȳ − b1X̄

As a useful check, substitute X̄ into the fitted equation. You obtain b₀ + b₁X̄ = Ȳ, which confirms that the line passes through the sample means. NIST’s least-squares derivation presents the same coefficient formulas.

Exercise 6.8: distinguish parameters, estimates, errors, and residuals

Population coefficients describe the unknown relationship you want to learn. Sample estimates change when you draw a different sample. Likewise, the disturbance uᵢ refers to the population equation, whereas the residual eᵢ uses the fitted sample equation.

ObjectEquationInterpretation
Population relationshipYᵢ = β₀ + β₁Xᵢ + uᵢObserved outcome includes the unknown disturbance
Population regression functionE(Yᵢ | Xᵢ) = β₀ + β₁XᵢRequires E(uᵢ | Xᵢ) = 0
Sample fitted lineŶᵢ = b₀ + b₁XᵢEstimated conditional mean
Sample decompositionYᵢ = b₀ + b₁Xᵢ + eᵢAn exact accounting identity after fitting

Consequently, zero sample correlation between X and OLS residuals does not prove zero population correlation between X and the disturbance. The algorithm enforces the first statement; a research design must justify the second.

Exercises 6.9–6.12: consumption and disposable income

Exercise 6.9: estimate the consumption equation

The first numerical example contains 12 observations. In the supplied explanation, both consumption and disposable income use billions of dollars. Therefore, a one-unit change in either variable means one billion dollars, not one household dollar.

Consumption data transcribed from the supplied Table 6.5; fitted values use unrounded coefficients.
iIncome XConsumption YXYX²Fitted ŶResidual e
11141021162812996100.30341.6966
21181061250813924103.74812.2519
31261081360815876110.6376-2.6376
41301101430016900114.0823-4.0823
51361221659218496119.24942.7506
61401241736019600122.69411.3059
71481281894421904129.5835-1.5835
81561302028024336136.4730-6.4730
91601422272025600139.91772.0823
101641482427226896143.36244.6376
111701502550028900148.52951.4705
121781542741231684155.4190-1.4190

First, compute the raw totals: ΣX = 1,740, ΣY = 1,524, ΣXY = 225,124, and ΣX² = 257,112. These imply X̄ = 145 and Ȳ = 127. Next, substitute the totals into the slope formula.

b1 = [12(225,124) − 1,740(1,524)] / [12(257,112) − 1,740²]
= 49,728 / 57,744 = 0.8611803824
b0 = 127 − 0.8611803824(145) = 2.1288445553
Ŷ = 2.128845 + 0.861180X

The photographed solution rounds the slope to 0.86 before calculating the intercept, producing 2.30. Although that line offers a close approximation, the exact intercept rounds to 2.13. Therefore, retain the full slope internally and round only the final reported results.

2026-10-21T20:21:34.647424 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 120 130 140 150 160 170 180 Disposable income X (billions of dollars) 100 110 120 130 140 150 Consumption Y (billions of dollars) Observed consumption OLS fitted line Vertical residuals
Figure 1. The exact OLS line and all 12 vertical residuals, calculated from the supplied consumption data.

Exercise 6.10: derive the centered-data formulas

Centering replaces each variable with its deviation from the sample mean. As a result, Σxᵢ = Σyᵢ = 0. Substituting these identities into the raw-sum slope formula removes the mean terms.

b1 = Σxiyi / Σxi²
b0, centered = 0 − b1(0) = 0

However, a zero intercept in centered coordinates does not mean the original relationship has a zero intercept. It means you moved the origin to (X̄, Ȳ). Therefore, translate back before interpreting autonomous consumption or another original-scale intercept.

Exercise 6.11: repeat the calculation with deviations

Centered worksheet; Σxy = 4,144 and Σx² = 4,812.
ix = X − 145y = Y − 127xyx²
1-31-25775961
2-27-21567729
3-19-19361361
4-15-17255225
5-9-54581
6-5-31525
73139
811333121
91515225225
101921399361
112523575625
1233278911089
b1 = 4,144 / 4,812 = 0.8611803824
ŷ = 0.8611803824x

The centered line passes through (0, 0). For example, income 10 units above its mean predicts consumption about 8.612 units above its mean. Adding the means back gives the original-scale point (155, 135.6118).

Thus, centering changes the coordinate labels but leaves fitted values, residuals, the slope, and R² unchanged. This equivalence also gives you an independent way to check a spreadsheet calculation.

Exercise 6.12: interpret the intercept, slope, and elasticity

The intercept predicts consumption of approximately 2.129 billion dollars when disposable income equals zero. However, zero income lies far outside the observed range of 114–178. Consequently, this estimate offers a model extrapolation rather than direct evidence about actual zero-income behavior.

The slope indicates that one additional billion dollars of disposable income corresponds to approximately 0.861 billion dollars of fitted consumption. In a consumption-function interpretation, analysts call this the estimated marginal propensity to consume. A causal interpretation would still require assumptions beyond the sample association.

Elasticity at X = (dŶ / dX)(X / Ŷ) = b1X / Ŷ
Elasticity at the sample means = 0.8611803824 × 145 / 127 = 0.983237

Therefore, a 1% income increase near the sample mean corresponds to roughly a 0.983% increase in fitted consumption. Unlike the constant slope, elasticity changes along a level-level line. In particular, a positive intercept makes b₁X/Ŷ less than one when both the slope and X are positive.

Exercises 6.13–6.18: uncertainty and statistical tests

Exercise 6.13: define the variance and standard-error formulas

The population error variance σ² describes dispersion around the population regression function. Because that function is unknown, we estimate its variance using sample residuals. With an intercept and one slope, two fitted coefficients leave n − 2 residual degrees of freedom.

s² = SSE / (n − 2)
Estimated Var(b1) = s² / Sxx
Estimated Var(b0) = s²[1/n + X̄²/Sxx]

Next, take square roots to obtain standard errors. The residual standard deviation s measures typical outcome scatter, whereas SE(b₁) measures uncertainty about the estimated slope. Therefore, these two quantities answer different questions and carry different units.

SE(b1) = s / √Sxx
SE(b0) = s√[1/n + X̄²/Sxx]

These formulas assume homoskedastic, uncorrelated disturbances conditional on X. Otherwise, suitable robust or dependence-adjusted standard errors may differ even though the OLS coefficients remain numerically unchanged.

Exercise 6.14: prove unbiasedness and coefficient variances

Define cᵢ = xᵢ/Sxx. Then Σcᵢ = 0, ΣcᵢXᵢ = 1, and Σcᵢ² = 1/Sxx. Substituting the population model into b₁ = ΣcᵢYᵢ gives a particularly useful identity.

b1 = β1 + Σciui

Under E(uᵢ | X) = 0, the weighted disturbance term has conditional expectation zero. Therefore, E(b₁ | X) = β₁. With conditional error variance σ² and zero conditional cross-error covariances, the variance follows directly.

Var(b1 | X) = σ²Σci² = σ² / Sxx

For the intercept, substitute the slope identity into b₀ = Ȳ − b₁X̄. This yields b₀ = β₀ + ū − X̄Σcᵢuᵢ. Consequently, E(b₀ | X) = β₀.

Var(b0 | X) = σ²/n + X̄²σ²/Sxx
= σ²[1/n + X̄²/Sxx]
= σ²ΣXi² / (nSxx)

The cross term vanishes because Cov(ū, Σcᵢuᵢ | X) = (σ²/n)Σcᵢ = 0. Notice that the proof needs an exogeneity condition, not merely an observed zero residual sum. Therefore, an algebraically correct fit can still produce a biased population estimate when the underlying research assumptions fail.

Exercise 6.15: calculate the consumption standard errors

Using the unrounded fitted line, SSE equals 115.268495. The sample has 12 observations, so the residual variance uses 10 degrees of freedom. Next, insert Sxx = 4,812 and X̄ = 145 into the coefficient variance formulas.

s² = 115.268495 / 10 = 11.526850
s = √11.526850 = 3.395121
Estimated Var(b1) = 11.526850 / 4,812 = 0.00239544
SE(b1) = 0.0489432
Estimated Var(b0) = 51.324663
SE(b0) = 7.164123

The slope has a small standard error relative to its estimate. In contrast, the intercept has a large standard error relative to 2.128845. This difference makes sense because the observations cluster far from X = 0, where the original intercept describes the regression function.

Exercise 6.16: choose hypotheses, a distribution, and degrees of freedom

For each coefficient, the standard two-sided significance test uses H₀: βⱼ = 0 against H₁: βⱼ ≠ 0. However, zero is only one possible null value. An economic theory may instead imply β₁ = 1 or another benchmark.

tj = (bj − βj,0) / SE(bj)
Under the classical normal-error model: tj ∼ tn−2 under H0

Therefore, the consumption tests use 10 degrees of freedom. At a 5% two-sided significance level, the critical value is approximately 2.22814. Normality supports this exact small-sample t distribution; a sample size below 30 does not, by itself, create the justification.

Exercise 6.17: test the intercept and slope

CoefficientEstimateStandard errort statisticTwo-sided p-value5% decision
Intercept2.1288457.1641230.2971540.772430Do not reject β₀ = 0
Income slope0.8611800.04894317.5955017.48 × 10⁻⁹Reject β₁ = 0

The intercept test does not provide evidence against zero at the 5% level. Nevertheless, that outcome does not prove the intercept equals zero or justify automatically removing it. A model without an intercept imposes a substantive restriction and changes several familiar regression identities.

Meanwhile, the slope test provides strong evidence of a positive linear association under the model assumptions. However, statistical significance does not establish causation or tell you whether the predictive errors are acceptable for a particular decision.

Exercise 6.18: construct 95% coefficient confidence intervals

95% confidence interval = bj ± t0.975, n−2SE(bj)
CoefficientCalculation95% confidence interval
Intercept2.128845 ± 2.228139 × 7.164123[−13.833817, 18.091506]
Slope0.861180 ± 2.228139 × 0.048943[0.752128, 0.970233]

As expected, the intercept interval includes zero, while the slope interval excludes it. Moreover, the slope interval also excludes one under the classical assumptions. Therefore, these data distinguish the estimated marginal propensity to consume from both zero and one at the 5% two-sided level.

A frequentist 95% interval describes the long-run coverage of the interval procedure. It does not assign a 95% probability to the fixed population coefficient after observing this particular interval. In practice, communicate both the plausible numerical range and the assumptions behind it.

Exercises 6.19–6.24: goodness of fit and correlation

Exercise 6.19: derive R² from the sum-of-squares decomposition

Start with Yᵢ − Ȳ = (Ŷᵢ − Ȳ) + eᵢ. Squaring and summing gives two sums of squares plus a cross term. Because OLS residuals are orthogonal to the fitted values and sum to zero, that cross term vanishes.

SST = SSR + SSE
Σ(Yi − Ȳ)² = Σ(Ŷi − Ȳ)² + Σei²
R² = SSR/SST = 1 − SSE/SST

For an in-sample OLS fit with an intercept and positive outcome variation, R² lies between zero and one. However, this familiar bound does not automatically apply to every out-of-sample score or every regression without an intercept. Always check which definition your software uses.

Exercise 6.20: what does correlation measure?

Pearson’s r measures the strength and direction of a linear association. Its sign identifies whether higher X values tend to accompany higher or lower Y values. Because r divides by both variables’ standard deviations, it has no measurement units.

r = Sxy / √(SxxSyy), with −1 ≤ r ≤ 1

A correlation of zero does not rule out a curved relationship. For example, symmetric X values and Y = X² can produce zero covariance despite a deterministic relationship. Likewise, a high correlation can reflect a common trend or a shared third variable rather than a causal effect.

Regression and correlation also differ in directionality. Correlation treats X and Y symmetrically, but regression of Y on X predicts one designated outcome. Therefore, reversing the regression generally produces a different line rather than the algebraic inverse of the first line.

Exercise 6.21: derive the relationship between r and the slope

Using the same divisor in the sample covariance and both sample variances causes those divisors to cancel. Thus, the usual correlation reduces to Sxy/√(SxxSyy). Next, substitute Sxy = b₁Sxx.

r = b1√(Sxx/Syy)
b1 = r√(Syy/Sxx) = r(sY/sX)

Consequently, the slope and Pearson correlation share a sign in simple regression. The slope, however, also reflects the ratio of measurement scales. For example, changing income from dollars to thousands of dollars changes the numerical slope while preserving r.

Exercise 6.22: calculate the consumption R² in two ways

SSR = b1²Sxx = 3,568.731505
R² = 3,568.731505 / 3,684 = 0.968711
R² = 1 − 115.268495 / 3,684 = 0.968711

Both methods give 96.8711%. Therefore, the fitted line accounts for about 96.87% of the sample’s centered consumption variation. This statement describes in-sample fit; it does not mean the model predicts every consumption observation with 96.87% accuracy.

Using an early-rounded slope in SSR while using a separately rounded residual table in SSE can make the two calculations disagree. Instead, preserve precision throughout and check that SSR + SSE equals SST before rounding the displayed totals.

Exercise 6.23: calculate the consumption correlation in three ways

r = +√R² = +√0.968711049 = 0.984231197
r = 4,144 / √(4,812 × 3,684) = 0.984231197
r = 0.8611803824√(4,812/3,684) = 0.984231197

The positive sign comes from the positive slope. For a negative slope, the square-root method requires the negative root. Consequently, reporting only √R² would erase the direction of a negative relationship.

A useful cross-check follows: in simple OLS with an intercept, R² = r². This identity does not extend to the square of one individual predictor’s correlation in a general multiple-regression model.

Exercise 6.24: compute rank correlation with a tied grade

The grade example contains ten students and one tie: two students scored 84. First, rank higher grades with smaller rank numbers to match the supplied IQ ranking. Next, assign both tied grades the average of ranks 4 and 5, which equals 4.5.

Original student order; the squared rank differences sum to 10.5.
StudentGradeGrade rankIQ rankDifference DD²
1777700
2786600
36510824
4844.55-0.50.25
5844.540.50.25
6883300
7679900
8922111
968810-24
109612-11

The familiar shortcut gives 1 − 6(10.5)/[10(10² − 1)] = 0.936364. However, its simplest form assumes no ties. The exact conventional Spearman coefficient instead equals Pearson correlation between the two sets of average ranks.

Mean rank = 5.5
Σ(Rgrade − 5.5)² = 82
Σ(RIQ − 5.5)² = 82.5
Σ(Rgrade − 5.5)(RIQ − 5.5) = 77
ρs = 77 / √(82 × 82.5) = 0.936174537

Both approaches round to 0.94, so the textbook’s broad interpretation remains unchanged. Nevertheless, distinguishing the exact tied-rank result from the shortcut prevents discrepancies when you compare hand calculations with software. The coefficient indicates a strong positive association between the two rankings.

Rank correlation works well when an ordered scale or a monotonic relationship matters more than raw distances. However, arbitrary numerical labels for unordered categories do not create meaningful ranks. SciPy’s official Spearman documentation also recommends considering permutation inference for small samples instead of relying on a large-sample p-value approximation.

Exercises 6.25–6.29: properties of OLS estimators

Exercise 6.25: define unbiasedness and bias

An estimator is unbiased when its expected value equals the population parameter across repeated samples. In symbols, E(b) = β. Therefore, its bias equals E(b) − β, which is zero for an unbiased estimator.

Unbiasedness does not require one observed estimate to equal the truth. For example, an unbiased slope estimator can produce a value above β in one sample and below β in another. The property concerns its repeated-sampling center, not the accuracy of every single realization.

Bias(b) = E(b) − β

Exercise 6.26: explain efficiency

Among unbiased estimators of the same parameter, an efficient estimator has the smallest variance within the comparison class. Therefore, its sampling distribution concentrates more closely around the true value. A narrower distribution generally yields more precise estimates, although any particular sample can still produce a large error.

The comparison class matters. For example, “best linear unbiased” compares only estimators that are both linear in the observed outcomes and unbiased. It does not automatically compare every nonlinear or deliberately biased estimator.

2026-10-21T20:21:34.791660 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ −4 −2 0 2 4 Estimate minus true parameter Density Bias: different centers Unbiased Biased −4 −2 0 2 4 Estimate minus true parameter Density Efficiency: different spreads Lower variance Higher variance −4 −2 0 2 4 Estimate minus true parameter Density Consistency: concentration Smaller n Larger n Still larger n
Figure 2. Schematic normal sampling distributions illustrate bias, efficiency, and consistency. These curves are teaching examples, not estimates from the supplied datasets.

Exercise 6.27: why is OLS widely used, and is it always superior?

OLS combines transparent formulas, accessible computation, and a strong theoretical result under classical assumptions. Specifically, the Gauss–Markov theorem makes OLS BLUE when the design has full rank and the conditional disturbance mean is zero with spherical error covariance. Therefore, no other linear unbiased estimator has a smaller variance under those conditions.

However, BLUE does not mean universally best. Heteroskedasticity, correlated disturbances, or a different loss function can motivate another approach. Likewise, a biased estimator may reduce total mean squared error through a sufficiently large reduction in variance.

The word “linear” refers to the estimator’s linear dependence on observed Y values conditional on X. It does not mean every fitted relationship must be a straight line in the original predictor. For example, a model with X and X² remains linear in its coefficients, as NIST explains in its discussion of statistically linear models.

Exercise 6.28: derive the bias–variance decomposition

Mean squared error measures the expected squared distance between an estimator and the true parameter. First, add and subtract E(b) inside that distance. Then expand the square and take expectations.

MSE(b) = E[(b − β)²]
= E[{b − E(b) + E(b) − β}²]
= E[(b − E(b))²] + [E(b) − β]²
+ 2[E(b) − β]E[b − E(b)]
MSE(b) = Var(b) + Bias(b)²

The last cross term equals zero because E[b − E(b)] = 0. Consequently, an unbiased estimator has MSE equal to its variance. A biased estimator can nevertheless perform better under squared-error loss if its variance falls enough.

For example, suppose estimator A has variance 4 and bias 0, while estimator B has variance 1 and bias 1. Then MSE(A) = 4 and MSE(B) = 2. Therefore, the biased estimator wins under this particular loss function, even though it fails the unbiasedness criterion.

Exercise 6.29: define consistency correctly

Consistency means an estimator converges in probability to the true parameter as sample size grows. In practical terms, the probability of an estimation error larger than any fixed positive tolerance approaches zero. A. Colin Cameron’s UC Davis notes on convergence and consistency use this probability-limit formulation.

For every ε > 0:
P(|bn − β| > ε) → 0 as n → ∞

A common sufficient route combines bias approaching zero with variance approaching zero. By the bias–variance identity, MSE then approaches zero, which implies convergence in probability. However, these moment conditions are sufficient rather than a universally necessary definition of consistency.

Likewise, the sampling density does not converge to a regular curve with height one. Instead, the limiting distribution places all probability mass at the true parameter. Figure 2 illustrates increasing concentration without confusing density height with probability.

Finally, more observations do not automatically remove a systematic endogeneity problem. If the explanatory variable remains related to the disturbance, the estimate may concentrate around the wrong limit. Therefore, consistency requires assumptions about the data-generating process as well as increasing sample size.

Exercise 6.30: income and agriculture across 15 countries

The final exercise relates per-capita income, Y, to agriculture’s share of the economy, X. The supplied source describes these observations as World Development Indicators data for 1999 and expresses income in hundreds of dollars. Therefore, Y = 76 represents approximately $7,600, not $76.

Historical exercise data as printed in Table 6.10, with newly computed fitted values and residuals. These are not current country statistics.
CountryAgriculture X (%)Income Y ($100 units)Fitted ŶResidual e
Argentina67643.531132.4689
Bolivia161017.5356-7.5356
Brazil94435.73248.2676
Chile84738.33208.6680
Colombia142322.73470.2653
Dominican Republic111930.5333-11.5333
Ecuador121327.9338-14.9338
El Salvador101933.1329-14.1329
Honduras18812.3365-4.3365
Mexico54446.1306-2.1306
Nicaragua264-8.459912.4599
Panama83138.3320-7.3320
Peru82438.3320-14.3320
Uruguay95935.732423.2676
Venezuela53746.1306-9.1306

For a modern replication, identify the precise income series before downloading data. The World Bank maintains separate GNI per-capita Atlas-method and agriculture, forestry, and fishing value-added share pages. However, the photographed caption does not provide enough metadata to certify that those current series exactly reproduce the historical exercise.

Part (a): estimate the equation

First, the original data give ΣX = 165 and ΣY = 458. Therefore, X̄ = 11 and Ȳ = 30.533333. The centered totals are Sxx = 442, Sxy = −1,149, and Syy = 5,859.733333.

b1 = −1,149 / 442 = −2.5995475113
b0 = 30.533333 − (−2.5995475113)(11)
= 59.1283559578
Ŷ = 59.128356 − 2.599548X

A one-percentage-point increase in agriculture’s share corresponds to approximately 2.59955 fewer units of fitted income. Since each income unit represents $100, the fitted difference equals about −$259.95 per person. Importantly, a percentage point differs from a 1% relative increase in the agriculture share.

This cross-country relationship does not demonstrate that reducing agriculture’s share would cause income to rise. Productivity, industrial structure, education, institutions, and other differences may influence both variables. Consequently, treat the slope as a sample association unless a separate identification strategy supports causality.

2026-10-21T20:21:34.850682 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 5 10 15 20 25 Agriculture share X (%) 0 20 40 60 80 Income Y (hundreds of dollars) Argentina Nicaragua
Figure 3. The historical country data and fitted OLS line. At X = 26, the line predicts negative income even though that X value lies inside the sample.

Part (b): test both coefficients at the 5% level

The residual sum of squares equals 2,872.853243. With 15 observations and two fitted coefficients, the residual degrees of freedom equal 13. Therefore, the residual variance equals 2,872.853243/13 = 220.988711.

Estimated Var(b1) = 220.988711 / 442 = 0.499974
SE(b1) = √0.499974 = 0.707089
Estimated Var(b0) = 75.229490
SE(b0) = 8.673494

The photographed solution prints a slope variance near 0.050, but its standard error near 0.71 implies a variance near 0.50. Therefore, the variance contains a factor-of-ten decimal error. The corrected value restores consistency between the variance and its square root.

CoefficientEstimateStandard errort statisticTwo-sided p-value95% interval
Intercept59.1283568.6734946.8171330.0000123[40.390412, 77.866300]
Agriculture share−2.5995480.707089−3.6764090.002793[−4.127120, −1.071975]

The 5% two-sided critical value for 13 degrees of freedom is 2.16037. Both absolute t statistics exceed that threshold, so both tests reject a zero coefficient. Nevertheless, the intercept describes X = 0, which lies outside the observed agriculture-share range of 5–26%.

Part (c): calculate the coefficient of determination

R² = 1 − 2,872.853243 / 5,859.733333 = 0.509730
r = −√R² = −0.713954

Thus, the fitted line accounts for approximately 50.97% of the sample’s centered income variation. The negative correlation reflects the slope’s direction. Compared with the consumption example, this relationship leaves substantially more variation unexplained.

Part (d): report the results in standard summary form

Ŷ = 59.1284 − 2.59955X
Standard errors: (8.67349)   (0.70709)
t statistics: (6.81713)   (−3.67641)
n = 15   |   R² = 0.509730   |   Residual SD = 14.865689

Always label what the parentheses contain. Some reports show standard errors, while others show t statistics. Consequently, an unlabeled parenthetical number can cause a reader to confuse precision with a test statistic.

In dollar units, the residual standard deviation equals approximately $1,486.57. This gives the reader a more concrete sense of unexplained dispersion than R² alone. However, it does not represent the same interval width for every country or every new prediction.

Beyond the exercises: insights that improve a real analysis

A high R² can coexist with a weakly estimated intercept

The consumption model has R² near 0.969 but an intercept p-value near 0.772. These results do not conflict. Most observed X values lie close to 145 and far from zero, so the sample strongly identifies changes around its center while providing little information about the zero-income intercept.

To see this directly, center only the predictor. The model becomes Ŷ = 127 + 0.861180(X − 145). Its intercept now estimates mean consumption at mean income, with standard error s/√n ≈ 0.980087 rather than 7.164123.

Therefore, centering can greatly improve the interpretability and precision of the intercept without changing a single fitted value. This is a parameterization change, not new information. The original intercept remains uncertain because it answers a different question.

Mean-response confidence intervals differ from prediction intervals

A confidence interval for the mean response describes uncertainty about the regression function at X₀. In contrast, a prediction interval must also allow for a new observation’s individual disturbance. Consequently, the prediction interval is wider.

Mean-response SE = s√[1/n + (X0 − X̄)²/Sxx]
New-observation SE = s√[1 + 1/n + (X0 − X̄)²/Sxx]
Interval = fitted value ± t0.975,n−2 × appropriate SE
Additional calculations under the classical normal-error model; units remain billions of dollars.
Income X₀Fitted consumption95% mean-response CI95% prediction interval
145127.0000[124.8162, 129.1838][119.1263, 134.8737]
170148.5295[145.0364, 152.0226][140.1972, 156.8618]

Notice that the mean-response interval is narrowest at X̄ = 145. As you move away from the mean, the squared distance term increases both interval widths. Penn State’s regression estimation and prediction lesson explains this distinction and the n − 2 degrees of freedom.

2026-10-21T20:21:34.905168 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 110 120 130 140 150 160 170 180 Disposable income X 90 100 110 120 130 140 150 160 170 Consumption Y 95% prediction interval 95% mean-response interval Fitted mean
Figure 4. Additional consumption intervals: prediction uncertainty includes individual noise and therefore exceeds uncertainty about the conditional mean.

The country model produces an impossible fitted value inside the sample

At Nicaragua’s X = 26, the fitted income equals −8.459879 hundred-dollar units, or approximately −$845.99. However, X = 26 is an observed value, so this issue does not result from extrapolating beyond the predictor range. It reveals a limitation of the unrestricted linear mean function for this particular positive outcome.

A log-income specification could guarantee positive fitted values after exponentiation, although it would change the interpretation and introduce retransformation considerations. Alternatively, a richer economic specification might describe the relationship better. The negative fitted value is a reason to investigate the model, not a reason to quietly replace it with zero.

Residual plots reveal information that a fitted line hides

The consumption residual at X = 156 is approximately −6.473, while the residual at X = 164 is approximately +4.638. Meanwhile, Argentina and Uruguay sit far above the country model’s fitted line. These observations deserve attention because large residuals and unusual predictor values can affect model assessment in different ways.

2026-10-21T20:21:35.007648 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 100 110 120 130 140 150 Fitted outcome −6 −4 −2 0 2 4 Residual Consumption residuals −10 0 10 20 30 40 Fitted outcome −10 0 10 20 30 Residual Country-income residuals
Figure 5. Residuals versus fitted values for both datasets. The graphs support inspection; they do not establish that all model assumptions hold.

For example, curvature can suggest a misspecified mean function, while a widening residual spread can suggest heteroskedasticity. A residual sequence plotted in time order may reveal dependence that a scatterplot misses. NIST’s model-validation guidance treats graphical checking as a central part of regression analysis.

Leverage and residual size answer different questions

Leverage measures how unusual an observation’s predictor value is relative to the design. A large residual instead measures how far its outcome lies from the fitted line. Therefore, an observation can have high leverage without having the largest residual.

hii = 1/n + (Xi − X̄)²/Sxx

For Nicaragua, hᵢᵢ = 1/15 + 15²/442 ≈ 0.575716. That value is large relative to average leverage 2/15 ≈ 0.133333. Consequently, its agriculture share gives it considerable potential to influence the fitted slope, even though Argentina has a much larger raw residual.

This calculation does not justify deleting Nicaragua. Instead, verify the observation, inspect influence, and compare substantively justified models. Removing inconvenient countries merely to raise R² would distort the analysis.

An extra consistency check: the slope t test and regression F test agree

With one predictor and an intercept, the classical overall regression F test has the same null hypothesis as the two-sided slope t test. Therefore, its statistic equals the square of the slope t statistic. This gives you another useful numerical check.

F1,n−2 = tslope² = [R²/(1 − R²)](n − 2)
DatasetSlope tOverall FDegrees of freedom
Consumption17.595501309.6016381 and 10
Country income−3.67640913.5159851 and 13

The country example illustrates why the sign disappears in the overall F test. The squared statistic measures evidence against a zero slope, while the coefficient itself preserves the direction. Thus, always report the estimated slope alongside significance statistics.

Numerical audit: corrections and precision choices

This section separates harmless rounding differences from substantive inconsistencies. All recalculated results use the original observation tables and full internal precision. Therefore, readers can reproduce the calculations without mixing rounded intermediate values.

Issue in the supplied pagesChecked resultWhy it matters
Consumption intercept of 2.30 after rounding slope to 0.86Full-precision intercept = 2.128845Rounding the slope early shifts the intercept
Consumption SSE = 115.2752 from the rounded lineExact OLS SSE = 115.268495Small differences propagate into standard errors and R²
Different routes give slightly different consumption r valuesEvery exact route gives r = 0.984231197Equivalent formulas agree when precision is consistent
No-tie rank shortcut applied despite two grades of 84Average-rank Pearson correlation = 0.936174537The shortcut is approximate here, though both round to 0.94
El Salvador X = 10 in Table 6.10 but 11 in Table 6.11Use X = 10; worksheet’s derived entries and total support itLiteral use of 11 changes the regression
A worksheet cross-product for Chile shows an inconsistent signx = −3 and y ≈ 16.4667 imply xy = −49.4The total needs the negative contribution
A worksheet cross-product for Uruguay shows an inconsistent signx = −2 and y ≈ 28.4667 imply xy = −56.9333The correct product is negative
Country slope variance printed near 0.050Estimated variance = 0.499974SE ≈ 0.707 requires variance near 0.50
Country slope t around −3.66 from rounded inputsFull-precision t = −3.676409The 5% decision remains unchanged
An intercept t formula visually shows a squared SE in the denominatorUse SE, not estimated varianceA t statistic divides by a standard error
Consistency described through a density of height oneConvergence in probability to the true parameterDensity height is not probability mass

What happens if you literally use the worksheet’s X = 11?

To measure the effect of the inconsistent row, change only El Salvador’s agriculture share from 10 to 11. Keep every income value and all other predictor values unchanged. The following comparison isolates the numerical consequence of that single change.

StatisticOriginal table: X = 10Literal worksheet: X = 11
Mean X11.00000011.066667
Sxx442.000000440.933333
Sxy-1149.000000-1160.533333
Intercept59.12835659.660720
Slope-2.599548-2.631993
Residual SSE2872.8532432805.218022
R²0.5097300.521272

The original table produces R² = 0.509730, while the changed entry produces R² = 0.521272. However, neither result authorizes choosing whichever version looks better. The data source and internal arithmetic determine the appropriate reconstruction, which is why this guide uses X = 10.

Three quick checks before trusting a regression worksheet

  1. Verify the raw totals. Sum X and Y directly from the observation rows before using a printed total.
  2. Check the OLS identities. With an intercept, Σe should be approximately zero, ΣXe should be approximately zero, and the line should pass through the means.
  3. Check compatible quantities. A standard error squared must equal its estimated variance, and SSR + SSE must equal SST up to numerical precision.

Frequently asked questions about OLS regression

Does OLS regression require normally distributed X or Y?

No. You can calculate OLS without assuming either variable has a normal marginal distribution. For exact classical small-sample tests, the relevant normality assumption concerns the disturbance conditional on X, together with the other model assumptions.

Can I compare the two R² values to decide which economic theory is better?

Not directly. The models use different outcomes, samples, and research questions. Although R² describes in-sample fit in each case, it does not provide a universal ranking of economic theories or practical predictive usefulness.

Should I remove an insignificant intercept?

Only when a defensible model restriction supports doing so. A large intercept p-value does not prove the population intercept equals zero. Moreover, removing the intercept changes the fitting problem and can invalidate familiar centered R² and residual-sum identities.

Why do two calculators produce different answers?

First, check whether they use identical observations and include an intercept. Then compare rounding rules, standard-error assumptions, and rank-tie handling. In these exercises, early rounding and one inconsistent predictor value explain several apparent disagreements.

What information should a complete OLS report include?

Report the equation, variable definitions, units, sample size, coefficient standard errors, and the model’s fit. In addition, state the assumptions behind inference and show relevant diagnostic evidence. A practical report should distinguish sample association, prediction, and causal interpretation.

Conclusion: calculate carefully, then interpret the evidence

OLS regression becomes far more useful when you connect the algebra to the data. The consumption example gives a precisely estimated positive slope and R² near 0.969. By comparison, the historical country example gives a negative slope and R² near 0.510, alongside an impossible negative fitted income that warrants further investigation.

Across the 26 exercises, the central habit remains the same: preserve numerical precision, verify identities, and match each interpretation to its assumptions. In addition, check the original data whenever a printed solution disagrees with its own arithmetic. A reliable regression analysis explains both what the fitted line shows and how confidently the evidence supports that conclusion.

References and source notes

The uploaded textbook pages supply the exercise data and numbering. The resources below support definitions, methods, and extensions; they do not independently verify the historical table’s exact series or data vintage. All hyperlinks were checked or located during preparation on October 21, 2026.

  1. NIST/SEMATECH. Linear Least Squares Regression.
    https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd141.htm
  2. NIST/SEMATECH. Least Squares: coefficient derivation.
    https://www.itl.nist.gov/div898/handbook/pmd/section4/pmd431.htm
  3. Taboga, Marco. Gauss Markov theorem. StatLect.
    https://www.statlect.com/fundamentals-of-statistics/Gauss-Markov-theorem
  4. SciPy. scipy.stats.spearmanr official documentation.
    https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.spearmanr.html
  5. Penn State. STAT 501, Lesson 3: SLR Estimation & Prediction.
    https://online.stat.psu.edu/stat501/Lesson03
  6. NIST/SEMATECH. How can I tell if a model fits my data?
    https://www.itl.nist.gov/div898/handbook/pmd/section4/pmd44.htm
  7. Cameron, A. Colin. Asymptotic theory notes: convergence in probability and consistency. UC Davis.
    https://cameron.econ.ucdavis.edu/slides/bgpev2_asymptotic.pdf
  8. World Bank. GNI per capita, Atlas method (current US$).
    https://data.worldbank.org/indicator/NY.GNP.PCAP.CD
  9. World Bank. Agriculture, forestry, and fishing, value added (% of GDP).
    https://data.worldbank.org/indicator/NV.AGR.TOTL.ZS

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *