9.12 Practice problems

Work each one before opening the solution. The question bank that follows has no answers.

Numerical problems

9.1 A regression of log monthly household expenditure on log monthly income across 900 Indian households gives a slope of 0.72 with a standard error of 0.04.

  1. Interpret the slope.
  2. Test whether the elasticity equals one at the 5% level.
  3. What would an elasticity of one imply about how expenditure shares change with income?

(i) A 1% rise in household income is associated with a 0.72% rise in expenditure. It is an elasticity, and unchanged if both were measured in thousands of rupees.

(ii) \(H_0: \beta_1 = 1\). Note this is not the test R prints, which uses zero.

\[t = \frac{0.72 - 1}{0.04} = -7\]

With 898 degrees of freedom the critical value is about 1.96, so we reject decisively. The elasticity is below one.

(iii) An elasticity of one means expenditure rises in exact proportion to income, so the share of income spent is constant. At 0.72 the share falls as income rises — richer households save a larger fraction, which is a very old empirical regularity.

9.2 A wage regression in log–level form returns a coefficient of 0.31 on a training programme indicator.

  1. What does the approximation say the programme is worth?
  2. Compute the exact percentage.
  3. Why do they differ by so much here when they agreed in Section 9.4?

(i) \(100 \times 0.31 = 31\%\).

(ii) \(100(e^{0.31} - 1) = 36.3\%\).

(iii) The approximation \(\Delta \ln y \approx \Delta y / y\) holds for small changes and degrades as the change grows. The schooling coefficient was 0.094, well inside the safe range; 0.31 is not. The error is always in the same direction — the approximation understates the true percentage.

9.3 A model with \(n = 200\) and \(k = 5\) has \(R^2 = 0.42\).

  1. Compute adjusted \(R^2\).
  2. A sixth variable is added and \(R^2\) rises to 0.425. Compute the new adjusted \(R^2\) and say whether the variable earned its place.

(i) With \(k = 5\), \(n - k - 1 = 194\):

\[\bar{R}^2 = 1 - \frac{(1-0.42)(199)}{194} = 0.4051\]

(ii) With \(k = 6\), \(n - k - 1 = 193\):

\[\bar{R}^2 = 1 - \frac{(1-0.425)(199)}{193} = 0.4071\]

Adjusted \(R^2\) rose, from 0.4051 to 0.4071, so on this criterion the variable paid for itself.

Note how little it rose. A gain of 0.002 is well within the range that a variable of pure noise can produce by chance, as Exercise 9.11 shows. Adjusted \(R^2\) is a weak criterion, and a near-tie like this one should not decide a specification on its own.

9.3 (continued) Why does a rise in adjusted \(R^2\) not establish that the sixth variable belongs in the model?

Because adjusted \(R^2\) charges a fixed price per parameter and asks only whether the improvement in fit exceeds it. It knows nothing about where the variable sits in the causal structure.

A mediator or a collider will often raise adjusted \(R^2\) — both are strongly related to the outcome — while making the coefficient of interest worse. Section 9.10 shows all three cases raising the fit and only one of them belonging.

9.4 Using india-production.csv, estimate a Cobb–Douglas production function \(\ln Y = \beta_0 + \beta_1 \ln L + \beta_2 \ln K + u\).

  1. Interpret both slopes.
  2. What do they sum to, and what does that mean?
  3. Test whether returns to scale are constant.
prod <- read.csv("data/india-production.csv")
cobb <- lm(logy ~ logl + logk, data = prod)
round(coef(summary(cobb)), 4)
#>             Estimate Std. Error t value Pr(>|t|)
#> (Intercept)  -6.8059     0.7698  -8.842        0
#> logl          0.7098     0.0838   8.476        0
#> logk          0.7879     0.0205  38.480        0

(i) A 1% rise in labour is associated with a 0.71% rise in output, holding capital fixed; a 1% rise in capital with a 0.79% rise, holding labour fixed. Both are elasticities.

(ii) They sum to 1.50. Doubling both inputs would raise output by about 150% rather than 100% — increasing returns to scale.

(iii) \(H_0: \beta_1 + \beta_2 = 1\). This is a restriction on a combination of coefficients, so neither printed \(t\) statistic tests it.

Impose the restriction by substituting \(\beta_2 = 1 - \beta_1\) into the model and rearranging:

\[\ln Y - \ln K = \beta_0 + \beta_1(\ln L - \ln K) + u\]

This is the restricted model. Its residuals are directly comparable with the unrestricted ones, because subtracting \(\ln K\) from both sides moves a known quantity and leaves the error untouched — so the \(F\) statistic of Section 8.6 can be computed from the two sums of squared residuals.

restricted <- lm(I(logy - logk) ~ I(logl - logk), data = prod)

ssr_r  <- sum(residuals(restricted)^2)
ssr_ur <- sum(residuals(cobb)^2)
n <- nrow(prod); k <- 2; q <- 1

f_stat <- ((ssr_r - ssr_ur) / q) / (ssr_ur / (n - k - 1))

round(c(ssr_restricted = ssr_r, ssr_unrestricted = ssr_ur,
        F = f_stat, critical_5pct = qf(0.95, q, n - k - 1),
        p_value = 1 - pf(f_stat, q, n - k - 1)), 5)
#>   ssr_restricted ssr_unrestricted                F    critical_5pct 
#>          0.08092          0.03111         59.22323          4.10546 
#>          p_value 
#>          0.00000

\(F = 59.2\) against a critical value of 4.11, so constant returns to scale is rejected decisively.

anova(restricted, cobb) will not do this comparison, and will not warn you. The two models have different dependent variables — \(\ln Y - \ln K\) against \(\ln Y\) — so R has no basis for treating them as nested and silently returns something else. Computing the statistic from the two sums of squared residuals is safer, and shows what the test is doing.

With 40 annual observations and inputs that trend together, this result is fragile. Labour and capital are highly collinear over this period, which is exactly the situation of Section 8.4.

9.5 A regression of crop yield on fertiliser gives

\[\widehat{\text{yield}} = 8.2 + 1.40\,\text{fert} - 0.025\,\text{fert}^2\]

with fertiliser applied ranging from 5 to 40 kg per hectare in the sample.

  1. What is the marginal effect of fertiliser at 10 kg? At 30 kg?
  2. Locate the turning point and say whether it falls inside the data.
  3. A student reports “the effect of fertiliser is 1.40”. What is wrong?

(i) The marginal effect is \(\beta_1 + 2\beta_2 x = 1.40 - 0.05x\).

At 10 kg: \(1.40 - 0.5 = 0.90\) quintals per kg. At 30 kg: \(1.40 - 1.5 = -0.10\) quintals per kg — already negative.

(ii) \(x^{*} = -1.40 / (2 \times -0.025) = 28\) kg per hectare.

That is well inside the range of 5 to 40, so the model is making a substantive claim: beyond 28 kg, more fertiliser reduces yield. Unlike the capital example in Section 9.6, this reversal cannot be dismissed as extrapolation, and agronomically it is plausible — over-application damages crops.

(iii) 1.40 is the marginal effect at \(\text{fert} = 0\), a level at which no farm in the sample operates. With a squared term in the model there is no single “effect of fertiliser”; it must be quoted at stated values of fertiliser.

Concept checks

9.6 A researcher reports that adding six control variables raised \(R^2\) from 0.31 to 0.44 and concludes the new model is better. Assess.

The rise in \(R^2\) is not evidence of anything: \(R^2\) cannot fall when variables are added, so it would have risen even had all six been random noise.

Adjusted \(R^2\) would at least charge for the six parameters, but it too is a weak criterion.

More importantly, “better” is undefined without a purpose. If the goal is prediction, some measure of fit is relevant, though one computed on data not used for fitting. If the goal is estimating an effect, fit is nearly irrelevant and the question is whether the six controls are confounders, mediators or colliders — which \(R^2\) cannot address.

9.7 Explain why controlling for occupation in a regression of earnings on education does not produce “the effect of education net of confounding”.

Occupation is largely a consequence of education, not a common cause of both. It is a mediator.

Controlling for it compares people who ended up in the same occupation, which removes the route through which much of education’s effect operates. The resulting coefficient is the direct effect — education’s value conditional on job — not the total effect, and not a confounding-corrected version of it.

The estimate is not biased for what it now measures. It measures something narrower than what was asked.

9.8 Two researchers analyse the same data. One reports the level–level model because its \(R^2\) is 0.48; the other reports log–log because its \(R^2\) is 0.51. What is wrong with both arguments?

The two \(R^2\) values are not comparable. One describes the share of variation explained in \(y\), the other in \(\ln y\). These are different quantities, so the comparison is meaningless regardless of which is larger.

Beyond that, neither researcher has given a reason of the kind that should decide the question: how the variable is naturally discussed, whether the relationship is plausibly multiplicative, and what the scatter looks like.

9.9 Why does an irrelevant variable that is highly correlated with \(x_1\) inflate \(\mathrm{se}(\hat{\beta}_1)\) even though its own coefficient is zero in the population?

The standard error depends on \((1-R_j^2)\), where \(R_j^2\) comes from regressing \(x_1\) on the other regressors. That quantity is about the relationship among the explanatory variables and has nothing to do with the outcome.

A variable strongly related to \(x_1\) raises \(R_j^2\) whether or not it affects \(y\). By the argument of Section 8.3, the coefficient is estimated from the part of \(x_1\) the other regressors cannot explain, and a strongly correlated variable leaves little of it.

R exercises

9.10 Using wages-india-synthetic.csv, fit the four functional forms relating annual earnings to education. Report each slope with its interpretation in a sentence, and explain why the four \(R^2\) values should not be compared.

wages <- read.csv("data/wages-india-synthetic.csv")
w <- subset(wages, education > 0)          # log(0) is undefined

forms <- list(
  level_level = lm(annual_earnings ~ education, data = w),
  log_level   = lm(log(annual_earnings) ~ education, data = w),
  level_log   = lm(annual_earnings ~ log(education), data = w),
  log_log     = lm(log(annual_earnings) ~ log(education), data = w))

t(sapply(forms, function(m) c(slope = coef(m)[2],
                              r2    = summary(m)$r.squared)))

Level–level: an extra year is worth about ₹5,400. Log–level: about 9.4% more. Level–log: a 1% rise in years of schooling is worth about slope/100 rupees. Log–log: a 1% rise in years of schooling raises earnings by the slope, in per cent.

The four \(R^2\) values are not comparable because the first and third explain variation in earnings while the second and fourth explain variation in log earnings.

Note also that dropping the zero-education observations changes the sample. The log forms answer a question about a different group of people from the level forms — which is the caution in Section 9.6 arriving in practice.

9.11 Demonstrate that \(R^2\) cannot fall. Take any regression, add a variable of pure noise, and confirm. Then repeat 500 times and report how often adjusted \(R^2\) rises.

students <- read.csv("data/attendance-grades.csv")
set.seed(31)

base <- lm(sem_gpa ~ attendance + cum_gpa, data = students)

results <- replicate(500, {
  students$junk <- rnorm(nrow(students))
  m <- lm(sem_gpa ~ attendance + cum_gpa + junk, data = students)
  c(r2_rose  = summary(m)$r.squared    >= summary(base)$r.squared,
    adj_rose = summary(m)$adj.r.squared > summary(base)$adj.r.squared)
})

rowMeans(results)

\(R^2\) rises in 100% of trials, as the algebra guarantees.

Adjusted \(R^2\) rises in about 31% of them. That is not a flaw: a noise variable will occasionally correlate with the outcome by chance, and adjusted \(R^2\) only charges a fixed price per parameter. It filters noise on average without doing so reliably in any single comparison.

9.12 Reproduce the collider simulation of Section 9.10, then vary the strength of the collider’s dependence on \(x\) and on \(u\). Which matters more for the size of the bias?

bias_at <- function(a, b, reps = 400, n = 2000) {
  est <- replicate(reps, {
    x <- rnorm(n); u <- rnorm(n)
    y <- 1 * x + u
    s <- a * x + b * u + rnorm(n)
    coef(lm(y ~ x + s))[2]
  })
  round(mean(est) - 1, 4)
}

set.seed(5)
c(weak_both   = bias_at(0.3, 0.3),
  strong_on_x = bias_at(1.2, 0.3),
  strong_on_u = bias_at(0.3, 1.2),
  strong_both = bias_at(1.2, 1.2))

The bias requires both dependences. If the collider does not depend on \(x\), conditioning on it induces no relationship between \(x\) and \(u\); if it does not depend on \(u\), there is no \(u\) to induce a relationship with.

This mirrors the omitted variable bias formula of Section 8.7, which was also a product of two terms and vanished if either was zero.