Ekonomi · Buku 4 · Sarjana Tahun 2

University Economics — Year 2

Buku ini belum tersedia dalam Bahasa Indonesia. Edisi: English.

University Economics — Year 2 · Sarjana Tahun 2

32Specification

A regression answers the question its specification asks. Which variables enter, in what form, measured how, and how many specifications were tried before one was reported: each choice changes the answer, sometimes predictably. This chapter goes through the common choices. The chart shows the most predictable of the effects: a regressor measured with noise gives a slope that shrinks toward zero by a factor the noise determines.

Estimated slope against the variance of the measurement error in the regressor, one simulated sample of 1,000 per point; true slope 2, variance of the true regressor 1. Curve: the limit 2/(1 + _e2).
Estimated slope against the variance of the measurement error in the regressor, one simulated sample of 1,000 per point; true slope 2, variance of the true regressor 1. Curve: the limit 2/(1+σe2)2/(1 + \sigma_e^2). Source: Simulated (seeded); our computation

With no measurement error the estimate is 1.99; with an error as variable as the regressor itself it is 0.99, half the true slope; with three times as much, 0.51. More data would not help: the points sit on the curve, not around the true value.

You already know

From the Year 1 volume: logarithms and percentage changes, elasticities, R2R^2, tests and pp-values. From Chapter 30: the omitted-variable bias formula and perfect collinearity. From Chapter 31: robust standard errors.

32.1 Logarithms and elasticities

Definition 32.1 (Constant-elasticity regression)

A constant-elasticity regression (log-log model) regresses ln⁡y\ln y on ln⁡x\ln x; its slope is the elasticity of yy with respect to xx, the same at every value of xx.

Definition 32.2 (Semi-elasticity)

In a regression of ln⁡y\ln y on xx, the slope β\beta is a semi-elasticity: a unit change in xx changes yy by approximately 100β100\beta per cent, exactly by 100(eβ−1)100(e^\beta - 1) per cent.

The listing fits an Engel curve, food spending against income, to 235 household budgets in three ways.

"""An Engel curve for food: levels, logs and the budget share."""

import numpy as np
import statsmodels.formula.api as smf
from econdata import sm_dataset

d = sm_dataset("engel")  # 235 households, income and food spending
d["lfood"] = np.log(d.foodexp)
d["linc"] = np.log(d.income)

loglog = smf.ols("lfood ~ linc", d).fit()
b, se = loglog.params.linc, loglog.bse.linc
print(f"log-log: elasticity {b:.3f} (s.e. {se:.3f}), R2 {loglog.rsquared:.3f}")

levels = smf.ols("foodexp ~ income", d).fit()
slope = levels.params.income
at_means = slope * d.income.mean() / d.foodexp.mean()
print(
    f"levels: {slope:.3f} francs of food per franc; elasticity at means {at_means:.3f}"
)

share = smf.ols("I(foodexp / income) ~ linc", d).fit()
print(f"budget share on log income: slope {share.params.linc:.3f}")
print(f"mean budget share {(d.foodexp / d.income).mean():.3f}")
Listing 32.1. An Engel curve for food in levels, in logs and as a budget share. code/bachelor-2/32-specification/listings/engel.py
$ python engel.py
log-log: elasticity 0.856 (s.e. 0.020), R2 0.884
levels: 0.485 francs of food per franc; elasticity at means 0.764
budget share on log income: slope -0.086
mean budget share 0.656
Output 32.1. The log-log elasticity, the elasticity implied by the linear fit at the means, and the slope of the budget share.

In logs, a 1 per cent rise in income goes with 0.856 per cent more food spending: food is a necessity, with an income elasticity below one. The linear fit gives 0.485 francs of food per extra franc, an elasticity of 0.764 at the means: the two forms answer the same question differently because the linear one forces the elasticity to change along the curve. The budget share, 0.656 on average, falls by 0.086 for each unit of log income. Which form is right is an empirical question (Exercise 7 lets the elasticity vary).

32.2 Dummy variables and interactions

Definition 32.3 (Dummy variable)

A dummy variable takes the value 1 if an observation belongs to a category and 0 otherwise; its coefficient is the difference in the mean outcome between the category and the omitted one, other regressors fixed.

Definition 32.4 (Dummy-variable trap)

The dummy-variable trap is the perfect collinearity created by including a constant and a dummy for every category of a variable; one category must be left out (or the constant dropped).

Definition 32.5 (Interaction term)

An interaction term is the product of two regressors; with it the effect of one regressor depends on the value of the other.

With ln⁡food=β0+β1ln⁡inc+β2owner+β3 owner×ln⁡inc+u\ln\mathit{food} = \beta_0 + \beta_1\ln\mathit{inc} + \beta_2\mathit{owner} + \beta_3\,\mathit{owner}\times\ln\mathit{inc} + u, the income elasticity is β1\beta_1 for tenants and β1+β3\beta_1 + \beta_3 for owners. The listing applies it to Brenland’s household survey, with a dummy for each household size but the first.

"""Brenland's households: dummy variables and an interaction in a food regression."""

import numpy as np
import statsmodels.formula.api as smf
from country import load

h = load("households")
h["lfood"] = np.log(h.food)
h["linc"] = np.log(h.disposable)

plain = smf.ols("lfood ~ linc", h).fit()
sizes = smf.ols("lfood ~ linc + C(size) + owner", h).fit()
inter = smf.ols("lfood ~ linc * owner + C(size)", h).fit()

print(f"no controls:     elasticity {plain.params.linc:.3f}")
print(f"size dummies:    elasticity {sizes.params.linc:.3f}, R2 {sizes.rsquared:.3f}")
for k in range(2, 6):
    name = f"C(size)[T.{k}]"
    print(f"  size {k} against size 1: {sizes.params[name]:+.3f}")
print(f"  owner: {sizes.params.owner:+.3f} (s.e. {sizes.bse.owner:.3f})")
b, g = inter.params["linc"], inter.params["linc:owner"]
print(f"interaction: tenants {b:.3f}, owners {b + g:.3f}, difference {g:+.3f}"
      f" (s.e. {inter.bse['linc:owner']:.3f})")  # fmt: skip
Listing 32.2. Size dummies, an owner dummy and an interaction in Brenland’s food regression. code/bachelor-2/32-specification/listings/dummies.py
$ python dummies.py
no controls:     elasticity 0.288
size dummies:    elasticity 0.196, R2 0.924
  size 2 against size 1: +0.246
  size 3 against size 1: +0.440
  size 4 against size 1: +0.597
  size 5 against size 1: +0.738
  owner: +0.001 (s.e. 0.004)
interaction: tenants 0.187, owners 0.211, difference +0.024 (s.e. 0.009)
Output 32.2. Household size absorbs a third of the raw elasticity; owners’ elasticity is slightly higher.

Without controls the elasticity is 0.288; with size dummies it is 0.196, because larger households have both more income and more mouths to feed. A household of five spends 0.738 log points, e0.738−1=109e^{0.738} - 1 = 109 per cent, more on food than a single person with the same income. Being an owner shifts nothing on its own, but owners’ elasticity is 0.024 higher than tenants’.

32.3 Measurement error

Definition 32.6 (Classical measurement error)

A regressor has classical measurement error if it is observed as x=x∗+ex = x^* + e, where the error ee has mean zero and is independent of the true value x∗x^* and of the regression error.

Definition 32.7 (Reliability ratio)

The reliability ratio of a measured variable is the share of its variance due to the true value: λ=Var⁡(x∗)/(Var⁡(x∗)+Var⁡(e))\lambda = \operatorname{Var}(x^*)/(\operatorname{Var}(x^*) + \operatorname{Var}(e)).

Proposition 32.8 (Attenuation)

If y=β0+βx∗+uy = \beta_0 + \beta x^* + u and x=x∗+ex = x^* + e with classical error, the least-squares slope of yy on xx converges in probability to λβ\lambda\beta.

Proof. The slope is Cov⁡^(x,y)/Var⁡^(x)\widehat{\operatorname{Cov}}(x, y)/\widehat{\operatorname{Var}}(x), which converges to Cov⁡(x∗+e,βx∗+u)/Var⁡(x∗+e)\operatorname{Cov}(x^* + e, \beta x^* + u)/\operatorname{Var}(x^* + e). By independence the numerator is βVar⁡(x∗)\beta\operatorname{Var}(x^*) and the denominator Var⁡(x∗)+Var⁡(e)\operatorname{Var}(x^*) + \operatorname{Var}(e). ∎

Definition 32.9 (Attenuation bias)

Attenuation bias is the shrinking of a coefficient toward zero caused by classical measurement error in its regressor.

Error in the outcome is different: it adds to uu, so it raises the standard errors but leaves the slope unbiased.

"""Measurement error in the regressor and in the outcome."""

import numpy as np

rng = np.random.default_rng(32)
n, beta = 100_000, 2.0
x_true = rng.standard_normal(n)
y_true = 1 + beta * x_true + rng.standard_normal(n)


def slope(x, y):
    return np.cov(x, y)[0, 1] / np.var(x, ddof=1)


print("error variance   slope (x noisy)   lambda * beta   slope (y noisy)")
for s2 in (0.0, 0.25, 1.0, 4.0):
    x = x_true + np.sqrt(s2) * rng.standard_normal(n)
    y = y_true + np.sqrt(s2) * rng.standard_normal(n)
    lam = 1 / (1 + s2)
    print(f"{s2:14.2f}  {slope(x, y_true):16.3f}  {lam * beta:14.3f}"
          f"  {slope(x_true, y):15.3f}")  # fmt: skip
Listing 32.3. The same noise added to the regressor, then to the outcome. code/bachelor-2/32-specification/listings/attenuation.py
$ python attenuation.py
error variance   slope (x noisy)   lambda * beta   slope (y noisy)
          0.00             2.000           2.000            2.000
          0.25             1.605           1.600            1.998
          1.00             1.006           1.000            1.995
          4.00             0.402           0.400            2.002
Output 32.3. Noise in xx shrinks the slope to λβ\lambda\beta; noise in yy leaves it at 2.

With several regressors the attenuation is stronger: what matters is the reliability of the part of xx not predicted by the other regressors, and controls remove true variation while leaving the noise. Errors that are not classical (people who under-report high incomes, for instance) can bias in either direction.

32.4 Proxies and bad controls

Definition 32.10 (Proxy variable)

A proxy variable is an observed variable included in place of an unobserved one, because it is correlated with it.

A test score stands in for ability in a wage regression. If the score were a perfect measure, controlling for it would remove the omitted-variable bias; a noisy score removes part of it. The listing simulates it.

"""An unobserved ability, a noisy test score as its proxy, and the schooling slope."""

import numpy as np
import statsmodels.api as sm

rng = np.random.default_rng(32)
n = 100_000
ability = rng.standard_normal(n)
school = 12 + 1.5 * ability + 2 * rng.standard_normal(n)
lwage = 1 + 0.08 * school + 0.10 * ability + 0.4 * rng.standard_normal(n)
score = ability + 0.7 * rng.standard_normal(n)  # the proxy


def coef(*cols):
    X = sm.add_constant(np.column_stack(cols))
    return sm.OLS(lwage, X).fit().params[1]


print("true return to schooling      0.080")
print(f"no control for ability        {coef(school):.3f}")
print(f"test score as a proxy         {coef(school, score):.3f}")
print(f"ability itself (unobservable) {coef(school, ability):.3f}")
Listing 32.4. Ability, a noisy test score, and the return to schooling. code/bachelor-2/32-specification/listings/proxy.py
$ python proxy.py
true return to schooling      0.080
no control for ability        0.105
test score as a proxy         0.091
ability itself (unobservable) 0.080
Output 32.4. The proxy removes more than half the bias, not all of it.

The true return is 0.080; leaving ability out gives 0.105; the score brings it to 0.091. A proxy is a good control: it is determined before the regressor of interest and is not changed by it. A control that the regressor itself changes is not.

Definition 32.11 (Bad control)

A bad control is a variable that is itself an outcome of the regressor of interest; holding it fixed removes part of the effect being measured, and can create bias where there was none.

Occupation in a regression of wages on schooling is the standard example: schooling changes occupation, so comparing people with different schooling in the same occupation compares a clerk who studied long, and so is unusual among clerks, perhaps unlucky or less able, with a clerk who did not. The 1975 earnings of Chapter 30 were a bad control of the same kind.

32.5 Searching over specifications

A 5 per cent test rejects a true null once in twenty. Try twenty unrelated regressors and keep the best, and the chance that at least one is “significant” is 1−0.9520=0.6421 - 0.95^{20} = 0.642.

The simulation gives 0.640. The Bonferroni correction divides the significance level by the number of tests, here 0.05/20=0.00250.05/20 = 0.0025, a ∣t∣|t| above about 3.1 with the listing’s 98 degrees of freedom (3.02 in large samples); by the union bound the chance that any of the twenty passes is then at most 5 per cent (0.045 in the simulation). The correction works only if every test tried is counted, which a reader cannot check; writing down the specification before seeing the data is the remedy that can be checked.

32.6 Functional form and outliers

A regression that is linear in the wrong variables misses curvature. One check adds the squares and cubes of the fitted values to the regression and tests them jointly with an FF statistic: if they help predict yy, the form is wrong somewhere (this is the RESET test). It says that something is missing, not what. Outliers are another matter: an observation far from the others in its regressors has high leverage and can move the fitted line on its own. Dropping it because it is inconvenient is a specification search; the honest course is to report the result with and without it, and to check that it is not a recording error.

Model — Classical measurement error

Assumes. The observed regressor is the true value plus an error with mean zero, independent of the true value and of the regression error.

Predicts. The slope converges to λβ\lambda\beta, shrunk toward zero by the reliability ratio; error in the outcome leaves the slope unbiased.

Tested. Where a variable is measured twice, by survey and by a record, the two can be compared: the reliability ratio of reported schooling or earnings can be estimated, and corrected slopes compared with uncorrected ones.

Breaks. Errors are often not classical: people who earn more may under-report more, so the error is negatively correlated with the true value; binary variables cannot have classical error at all, since a misreported 0 or 1 is always wrong in a direction that depends on the true value.

32.7 Exercises

Exercise 32.1 ★

Read the opening chart. What is the estimated slope when the error variance equals the variance of the true regressor? What is the reliability ratio then?

Solution

Solution of Exercise 32.1.

At σe2=1\sigma_e^2 = 1 the estimate is 0.99, against a limit of 1; the reliability ratio is 1/(1+1)=0.51/(1 + 1) = 0.5.

Exercise 32.2 ★

Interpret the Engel elasticity of 0.856. If income rises by 10 per cent, by how much does food spending rise, and what happens to the budget share?

Solution

Solution of Exercise 32.2.

A 1 per cent rise in income goes with 0.856 per cent more food spending. A 10 per cent rise raises food spending by about 8.6 per cent (exactly 1.10.856−1=8.51.1^{0.856} - 1 = 8.5 per cent), less than income, so the budget share falls.

Exercise 32.3 ★

Why does the Brenland regression have four size dummies for five sizes? By how much, in per cent, does a household of three spend more on food than a single person with the same income?

Solution

Solution of Exercise 32.3.

With a constant, a fifth dummy would make the dummies sum to the constant: the dummy-variable trap. Size 1 is the omitted category. A household of three: e0.440−1=55e^{0.440} - 1 = 55 per cent more.

Exercise 32.4 ★

A study reports that one of twenty diet variables significantly predicts a disease at the 5 per cent level, and says nothing of the other nineteen. What should a reader conclude?

Solution

Solution of Exercise 32.4.

If none of the twenty mattered, at least one would be significant at 5 per cent with probability about 0.64. One significant result in twenty is what chance alone predicts; the reader should ask for all twenty results, or a threshold of 0.05/200.05/20.

Exercise 32.5 ★★

In a regression of log wages on a dummy for union membership, the coefficient is 0.15. Give the approximate and the exact percentage difference.

Solution

Solution of Exercise 32.5.

About 15 per cent; exactly e0.15−1=16.2e^{0.15} - 1 = 16.2 per cent.

Exercise 32.6 ★★

Predict, then compute: what error variance makes the attenuated slope in the listing equal to 1.6? To 1?

Solution

Solution of Exercise 32.6.

λβ=2/(1+σe2)\lambda\beta = 2/(1 + \sigma_e^2): 1.6 needs σe2=0.25\sigma_e^2 = 0.25, 1 needs σe2=1\sigma_e^2 = 1; the listing prints 1.605 and 1.006.

Exercise 32.7 ★★

(D) With the Engel data, regress log food spending on centred log income and its square. Does the elasticity change with income? Give it at the 10th and 90th percentiles of income.

Solution

Solution of Exercise 32.7.

The coefficients are 0.872 on centred log income and −0.077-0.077 on its square (p=0.014p = 0.014): the elasticity falls with income, 0.872−2×0.077×(ln⁡inc−ln⁡inc‾)0.872 - 2 \times 0.077 \times (\ln\mathit{inc} - \overline{\ln\mathit{inc}}). It is 0.96 at the 10th percentile of income and 0.79 at the 90th.

Exercise 32.8 ★★

Change the proxy listing so that the test score has noise 0.3 instead of 0.7. Predict, then compute, the coefficient on schooling.

Solution

Solution of Exercise 32.8.

A better proxy removes more of the bias: 0.083, against 0.091 with the noisier score and 0.080 with ability itself. The population value is 0.08+0.10 δ0.08 + 0.10\,\delta, with δ=(1.5×1.09−1.5)/(6.25×1.09−1.52)=0.030\delta = (1.5 \times 1.09 - 1.5)/(6.25 \times 1.09 - 1.5^2) = 0.030.

Exercise 32.9 ★★

To evaluate a training programme on wages, a researcher controls for the worker’s occupation after the programme. Why is that a bad control? Which controls would be good?

Solution

Solution of Exercise 32.9.

The programme may change the worker’s occupation; comparing trained and untrained workers in the same occupation removes that channel and compares groups that differ in unobserved ways. Good controls are fixed before the programme: age, schooling, earlier earnings and occupation before the programme.

Exercise 32.10 ★★★

With y=β0+β1x1∗+β2x2+uy = \beta_0 + \beta_1x_1^* + \beta_2x_2 + u and x1=x1∗+ex_1 = x_1^* + e classical, show using the Frisch–Waugh–Lovell theorem that the slope on x1x_1 converges to λ1β1\lambda_1\beta_1, where λ1\lambda_1 is the reliability of x1x_1 after partialling out x2x_2, and that λ1≤λ\lambda_1 \leq \lambda.

Solution

Solution of Exercise 32.10.

By the theorem the slope on x1x_1 is the slope of yy on x~1\tilde x_1, the residual of x1x_1 on x2x_2. Since ee is uncorrelated with x2x_2, the regression of x1x_1 on x2x_2 has the same limit as that of x1∗x_1^*, so x~1=x~1∗+e\tilde x_1 = \tilde x_1^* + e in the limit, and yy moves with x~1∗\tilde x_1^* at rate β1\beta_1; so the slope converges to β1Var⁡(x~1∗)/(Var⁡(x~1∗)+Var⁡(e))=λ1β1\beta_1\operatorname{Var}(\tilde x_1^*)/(\operatorname{Var}(\tilde x_1^*) + \operatorname{Var}(e)) = \lambda_1\beta_1. Since Var⁡(x~1∗)≤Var⁡(x1∗)\operatorname{Var}(\tilde x_1^*) \leq \operatorname{Var}(x_1^*) and the noise variance is unchanged, λ1≤λ\lambda_1 \leq \lambda.

Exercise 32.11 ★★★

Show that classical error in the outcome leaves the slope consistent, and give its effect on the variance of the slope.

Solution

Solution of Exercise 32.11.

If y=y∗+vy = y^* + v with vv independent of xx, then y=β0+βx+(u+v)y = \beta_0 + \beta x + (u + v) and xx is still uncorrelated with the error: the slope is consistent. The error variance rises from σu2\sigma_u^2 to σu2+σv2\sigma_u^2 + \sigma_v^2, and the variance of the slope rises in proportion.

Exercise 32.12 ★★★

Show that if kk tests each have size α\alpha, the probability that at least one rejects is at most kαk\alpha, and equals 1−(1−α)k1 - (1 - \alpha)^k if they are independent. Compute both for k=20k = 20, α=0.05\alpha = 0.05 and for α=0.0025\alpha = 0.0025.

Solution

Solution of Exercise 32.12.

The probability of a union is at most the sum of the probabilities: kαk\alpha. Under independence the probability that none rejects is (1−α)k(1 - \alpha)^k. With α=0.05\alpha = 0.05: bound 1 (useless), exact 0.642. With α=0.0025\alpha = 0.0025: bound 0.05, exact 0.0488.

32.8 Problem: Brenland’s food survey

Problem 32.1

Weekend problem — Brenland’s food survey: logs, dummies and interactions, reported income with a known reliability, and a specification search

Brenland’s household survey records each household’s food spending, disposable income, size and whether it owns its home. A validation study, which compared reported incomes with tax records, found that the reliability ratio of reported log disposable income, after partialling out household size, is 0.8.

Part I — Logs.

  1. Regress log food on log disposable income. Give the elasticity and R2R^2.
  2. Is food a necessity or a luxury in Brenland?
  3. If income rises 10 per cent, by how much does food spending rise?
  4. What does the budget share of food do as income rises?
  5. Why use logs rather than levels here?

Part II — Dummies and interactions.

  1. Add a dummy for each household size from 2 to 5 and an owner dummy. Give the elasticity and R2R^2.
  2. Why did the elasticity fall?
  3. Give the size coefficients and the percentage difference for a household of five.
  4. Why is there no dummy for size 1?
  5. Interpret the owner coefficient.
  6. Add the interaction of owner and log income. Give the elasticities of owners and tenants.
  7. Is the difference significant at 5 per cent?

Part III — Reported income with a known reliability.

  1. If reported income has classical error, which way is the elasticity of Part II biased?
  2. Correct it with the reliability ratio.
  3. Why is the reliability after partialling out size the right one?
  4. Would the correction be the same without the size dummies?
  5. Would error in reported food spending call for a correction?
  6. What if high earners under-report most?

Part IV — A specification search and an honest threshold.

  1. An analyst tries twenty other household characteristics, one at a time, as extra regressors. If none matters, what is the chance that at least one is significant at 5 per cent?
  2. Give the Bonferroni threshold for the pp-value and the matching ∣t∣|t|.
  3. Would the interaction of Part II pass it?
  4. What should the analyst write down before looking at the data?
  5. Why is household size not part of the search?
  6. Could the analyst choose the twenty characteristics after seeing which look promising?
  7. State the result: the corrected food–income elasticity and the Bonferroni threshold for twenty tries.
Solution

Solution of Problem 32.1.

Part I. 1. 0.288; R2=0.181R^2 = 0.181. 2. A necessity: the elasticity is below one. 3. By about 2.9 per cent. 4. It falls, since food spending rises less than in proportion. 5. The slope is then an elasticity, free of units, and the relation is closer to linear. Part II. 6. 0.196; R2=0.924R^2 = 0.924. 7. Larger households have both more income and more mouths to feed; without size, the income coefficient picked up part of the effect of size. 8. 0.246, 0.440, 0.597 and 0.738 for sizes 2 to 5; a household of five spends e0.738−1=109e^{0.738} - 1 = 109 per cent more than a single person with the same income. 9. Size 1 is the omitted category; a dummy for it with the constant would be the dummy-variable trap. 10. +0.001+0.001 (s.e. 0.004): owners and tenants of the same size and income spend the same on food. 11. Tenants 0.187, owners 0.211. 12. Yes: t=2.64t = 2.64 (from the unrounded coefficient and standard error), above 1.96. Part III. 13. Toward zero. 14. 0.196/0.8=0.2450.196/0.8 = 0.245. 15. By the Frisch–Waugh–Lovell theorem the elasticity comes from the part of income not predicted by size, and it is the reliability of that part which sets the attenuation. 16. No: without size, the reliability of the whole of reported income would apply, which is higher, and the elasticity itself would be a different one. 17. No: error in the outcome raises the standard errors but leaves the slope unbiased. 18. Then the error is negatively correlated with true income and the classical correction is wrong; the bias depends on how reporting varies with income. Part IV. 19. 1−0.9520=0.6421 - 0.95^{20} = 0.642. 20. 0.05/20=0.00250.05/20 = 0.0025; ∣t∣>3.02|t| > 3.02. 21. No: its tt is 2.64. 22. The regressors, the form and the sample of the regression it will report, and how many others it will try. 23. It was chosen for a reason given in advance (larger households eat more), not found by the search. 24. No: choosing after seeing the data is a search too, and the number of tries is then not twenty but unknown. 25. Brenland’s food–income elasticity, holding household size fixed, is 0.196 as measured and 0.196/0.8=0.2450.196/0.8 = 0.245 corrected for the reliability of reported income; with twenty tries, a result should count only if its pp-value is below 0.0025.

Istilah yang didefinisikan dalam bab ini

Lihat semua 1086 istilah di glosarium