অর্থনীতি · বই 4 · স্নাতক দ্বিতীয় বর্ষ

University Economics — Year 2

এই বইটি এখনো বাংলা ভাষায় পাওয়া যায় না। সংস্করণ: English।

University Economics — Year 2 · স্নাতক দ্বিতীয় বর্ষ

31Inference in Regression

A regression coefficient is an estimate; its standard error says how far it might be from what it estimates. The standard errors printed by default rest on assumptions about the errors that real data often break: that they all have the same variance, and that they are independent of each other. This chapter states those assumptions, shows why least squares is the best linear estimator when they hold, and builds the standard errors that remain valid when they do not. The chart shows how much the answer can change.

Heteroskedasticity-robust standard error divided by the classical standard error, for each coefficient of a regression of outpatient visits to a doctor on insurance-plan and health variables; 20,190 person-years.
Heteroskedasticity-robust standard error divided by the classical standard error, for each coefficient of a regression of outpatient visits to a doctor on insurance-plan and health variables; 20,190 person-years. Source: RAND Health Insurance Experiment, statsmodels randhie dataset; our computation

For most coefficients the two standard errors are within 10 per cent of each other. For four they are not: the robust standard error is 1.55 times the classical one for poor self-rated health, 1.29 times for the number of chronic diseases, 1.25 times for a physical limitation and 1.18 times for fair health. The classical formula assumes that every person’s visits are equally unpredictable; the sick are much less predictable than the healthy.

You already know

From the Year 1 volume: estimators, unbiased and consistent estimators, standard errors, confidence intervals, the tt and FF distributions, tests and pp-values, and the central limit theorem. From Chapter 30: the matrix form, the normal equations and the Frisch–Waugh–Lovell theorem.

31.1 The Gauss–Markov theorem

Definition 31.1 (Gauss–Markov assumptions)

The Gauss–Markov assumptions for y=Xβ+uy = X\beta + u are: XX has full column rank; E[u∣X]=0E[u \mid X] = 0; and Var⁡(u∣X)=σ2I\operatorname{Var}(u \mid X) = \sigma^2I, so that the errors are uncorrelated with each other and all have the same variance.

Definition 31.2 (Homoskedasticity)

Errors are homoskedastic if their variance given the regressors is the same for every observation, Var⁡(ui∣X)=σ2\operatorname{Var}(u_i \mid X) = \sigma^2; they are heteroskedastic if it varies across observations.

Under the first two assumptions β^=(X′X)−1X′y=β+(X′X)−1X′u\hat\beta = (X'X)^{-1}X'y = \beta + (X'X)^{-1}X'u is unbiased. Under the third, Var⁡(β^∣X)=(X′X)−1X′(σ2I)X(X′X)−1=σ2(X′X)−1\operatorname{Var}(\hat\beta \mid X) = (X'X)^{-1}X'(\sigma^2I)X(X'X)^{-1} = \sigma^2(X'X)^{-1}, and σ2\sigma^2 is estimated by s2=e′e/(n−k)s^2 = e'e/(n - k). These are the classical standard errors.

Definition 31.3 (Best linear unbiased estimator)

An estimator of β\beta is the best linear unbiased estimator if it is linear in yy, unbiased, and has a variance matrix no larger, in the sense of positive semi-definite matrices, than that of any other linear unbiased estimator.

Theorem 31.4 (Gauss–Markov)

Under the Gauss–Markov assumptions, the least-squares estimator is the best linear unbiased estimator of β\beta.

Proof. Let β~=Cy\tilde\beta = Cy be linear, and write C=(X′X)−1X′+DC = (X'X)^{-1}X' + D. Then E[β~∣X]=β+DXβE[\tilde\beta \mid X] = \beta + DX\beta, so unbiasedness for every β\beta requires DX=0DX = 0. Then β~−β=Cu\tilde\beta - \beta = Cu, and Var⁡(β~∣X)=σ2CC′=σ2((X′X)−1+(X′X)−1X′D′+DX(X′X)−1+DD′)=σ2(X′X)−1+σ2DD′\operatorname{Var}(\tilde\beta \mid X) = \sigma^2CC' = \sigma^2\bigl((X'X)^{-1} + (X'X)^{-1}X'D' + DX(X'X)^{-1} + DD'\bigr) = \sigma^2(X'X)^{-1} + \sigma^2DD', since DX=0DX = 0. The difference from the least-squares variance is σ2DD′\sigma^2DD', which is positive semi-definite. ∎

The listing compares least squares with another linear unbiased estimator of a slope: the difference between the mean outcomes of the upper and lower halves of the regressor, divided by the difference of their mean regressors.

"""Least squares against another linear unbiased estimator of the slope."""

import numpy as np

rng = np.random.default_rng(31)
n, sigma = 40, 2.0
x = np.linspace(0, 10, n)  # fixed regressor
low, high = x < np.median(x), x >= np.median(x)


def ols_slope(y):
    xd = x - x.mean()
    return xd @ y / (xd @ xd)


def group_slope(y):
    """Difference of group means: linear in y and unbiased, but not least squares."""
    return (y[high].mean() - y[low].mean()) / (x[high].mean() - x[low].mean())


samples = 1 + 0.5 * x + sigma * rng.standard_normal((20000, n))
draws = np.array([[ols_slope(y), group_slope(y)] for y in samples])
print("            mean    variance (simulated)   variance (formula)")
var_ols = sigma**2 / ((x - x.mean()) @ (x - x.mean()))
gap = x[high].mean() - x[low].mean()
var_group = sigma**2 * (1 / high.sum() + 1 / low.sum()) / gap**2
for name, col, v in (("OLS", 0, var_ols), ("groups", 1, var_group)):
    print(f"{name:8s} {draws[:, col].mean():7.4f}  {draws[:, col].var():12.5f}"
          f"  {v:20.5f}")  # fmt: skip
Listing 31.1. Least squares and the grouping estimator of a slope, over 20,000 simulated samples. code/bachelor-2/31-regression-inference/listings/gauss_markov_sim.py
$ python gauss_markov_sim.py
            mean    variance (simulated)   variance (formula)
OLS       0.5006       0.01145               0.01141
groups    0.4998       0.01508               0.01521
Output 31.1. Both are centred on the true slope 0.5; least squares has the smaller variance, as the theorem says.

The variances are 0.01145 and 0.01508 in the simulation, against 0.01141 and 0.01521 by the formulas. The theorem says nothing about estimators that are biased or non-linear, and nothing at all once the errors are heteroskedastic.

31.2 Normal errors: tt and FF

If, in addition, the errors are normal given XX, then (β^j−βj)/se⁡(β^j)(\hat\beta_j - \beta_j)/\operatorname{se}(\hat\beta_j) has a tt distribution with n−kn - k degrees of freedom, and confidence intervals and tests on one coefficient follow as in the Year 1 volume. Several restrictions at once need another statistic.

Definition 31.5 (Joint hypothesis)

A joint hypothesis is a set of q≥2q \geq 2 restrictions on the coefficients tested together, such as β2=β3=β4=0\beta_2 = \beta_3 = \beta_4 = 0.

Definition 31.6 (F statistic)

The F statistic for qq linear restrictions is F=(SSRr−SSRu)/qSSRu/(n−k)F = \dfrac{(\mathit{SSR}_r - \mathit{SSR}_u)/q}{\mathit{SSR}_u/(n - k)}, where SSRr\mathit{SSR}_r and SSRu\mathit{SSR}_u are the sums of squared residuals of the regressions with and without the restrictions. Under the classical assumptions with normal errors it has an F(q,n−k)F(q, n - k) distribution when the restrictions hold.

The FF statistic asks whether imposing the restrictions raises the sum of squared residuals by more than chance would. The listing applies it to the RAND Health Insurance Experiment, in which families were assigned at random to insurance plans that made them pay different shares of their medical bills.

"""Doctor visits in the RAND experiment: t statistics, and an F test by hand."""

import numpy as np
import statsmodels.api as sm
from scipy import stats
from econdata import sm_dataset

d = sm_dataset("randhie")
y = d.mdvis
X = sm.add_constant(d.drop(columns="mdvis"))
fit = sm.OLS(y, X).fit()
table = np.column_stack([fit.params, fit.bse, fit.tvalues])
for name, (b, se, t) in zip(X.columns, table):
    print(f"{name:8s} {b:8.4f} {se:7.4f} {t:7.2f}")

# H0: the three self-rated health dummies have zero coefficients
health = ["hlthg", "hlthf", "hlthp"]
restricted = sm.OLS(y, X.drop(columns=health)).fit()
n, k, q = len(y), X.shape[1], len(health)
ssr_u, ssr_r = fit.ssr, restricted.ssr
F = ((ssr_r - ssr_u) / q) / (ssr_u / (n - k))
print(f"SSR restricted {ssr_r:.1f}, unrestricted {ssr_u:.1f}")
F_sm = fit.f_test(" = ".join(health) + " = 0").fvalue
print(f"F by hand {F:.3f}; statsmodels {F_sm:.3f}")
print(f"5 % critical value F({q}, {n - k}): {stats.f.ppf(0.95, q, n - k):.3f}")
Listing 31.2. Doctor visits on plan and health variables; the joint test of the three health dummies, by hand and with statsmodels. code/bachelor-2/31-regression-inference/listings/t_and_f.py
$ python t_and_f.py
const      1.7379  0.0842   20.65
lncoins   -0.1695  0.0202   -8.41
idp       -0.7533  0.0753  -10.00
lpi        0.1066  0.0136    7.86
fmde      -0.1001  0.0115   -8.71
physlm     1.0658  0.1033   10.32
disea      0.1217  0.0049   25.01
hlthg     -0.0487  0.0667   -0.73
hlthf      0.2201  0.1218    1.81
hlthp      1.4410  0.2607    5.53
SSR restricted 382137.5, unrestricted 381469.6
F by hand 11.778; statsmodels 11.778
5 % critical value F(3, 20180): 2.605
Output 31.2. Coefficient, classical standard error and tt statistic for each term; the FF statistic of the joint test.

Each unit of log coinsurance goes with 0.17 fewer visits, holding the other plan variables and health fixed (t=−8.41t = -8.41). The health dummies, measured against excellent health, have tt statistics of −0.73-0.73, 1.811.81 and 5.535.53; jointly they raise the sum of squared residuals by 667.9 and give F=11.78F = 11.78, far above the 5 per cent critical value of 2.605. Both calculations used the classical variance. The next section asks whether it was right to.

31.3 Unequal error variances

Standard deviation of the residuals in twenty equal groups of person-years sorted by fitted number of visits, against the mean fitted value of each group.
Standard deviation of the residuals in twenty equal groups of person-years sorted by fitted number of visits, against the mean fitted value of each group. Source: RAND Health Insurance Experiment, statsmodels randhie dataset; our computation

Among the person-years with the fewest predicted visits the residuals have a standard deviation of 2.44; among those with the most, 8.20. The errors are heteroskedastic, and the classical variance formula does not apply. Least squares is still unbiased, but its variance is now

Var⁡(β^∣X)=(X′X)−1(∑iσi2xixi′)(X′X)−1,(31.1)\operatorname{Var}(\hat\beta \mid X) = (X'X)^{-1}\Bigl(\sum_i\sigma_i^2x_ix_i'\Bigr)(X'X)^{-1},\tag{31.1}

with xi′x_i' the iith row of XX and σi2=Var⁡(ui∣X)\sigma_i^2 = \operatorname{Var}(u_i \mid X) (Exercise 11). Its shape gives it the name of a sandwich.

Definition 31.7 (Heteroskedasticity-robust standard error)

A heteroskedasticity-robust standard error is the square root of a diagonal element of (31.1) with each σi2\sigma_i^2 replaced by the squared residual ei2e_i^2 (HC0), often multiplied by n/(n−k)n/(n - k) (HC1).

Each ei2e_i^2 is a poor estimate of its σi2\sigma_i^2, but the sum in the middle averages over many observations, and in large samples the robust variance is consistent whatever the form of heteroskedasticity.

"""Heteroskedasticity-robust standard errors by hand, against statsmodels."""

import numpy as np
import statsmodels.api as sm
from econdata import sm_dataset

d = sm_dataset("randhie")
y = d.mdvis.to_numpy(float)
X = sm.add_constant(d.drop(columns="mdvis")).to_numpy(float)
n, k = X.shape

A = np.linalg.inv(X.T @ X)
b = A @ X.T @ y
e = y - X @ b
classical = A * (e @ e) / (n - k)
meat = (X * e[:, None] ** 2).T @ X  # sum of e_i^2 x_i x_i'
hc0 = A @ meat @ A  # the sandwich
hc1 = hc0 * n / (n - k)

sm_hc1 = sm.OLS(y, X).fit(cov_type="HC1").cov_params()
print("same HC1 as statsmodels:", np.allclose(hc1, sm_hc1))
names = ["const", "lncoins", "idp", "lpi", "fmde", "physlm", "disea", "hlthg", "hlthf"]
names.append("hlthp")
print("term      classical   HC0      HC1    ratio")
for j, name in enumerate(names):
    se = [np.sqrt(v[j, j]) for v in (classical, hc0, hc1)]
    print(f"{name:8s} {se[0]:8.4f} {se[1]:8.4f} {se[2]:8.4f} {se[2] / se[0]:6.2f}")
Listing 31.3. The sandwich by hand, against statsmodels. code/bachelor-2/31-regression-inference/listings/robust_se.py
$ python robust_se.py
same HC1 as statsmodels: True
term      classical   HC0      HC1    ratio
const      0.0842   0.0884   0.0885   1.05
lncoins    0.0202   0.0188   0.0188   0.93
idp        0.0753   0.0719   0.0720   0.95
lpi        0.0136   0.0134   0.0134   0.99
fmde       0.0115   0.0112   0.0112   0.98
physlm     0.1033   0.1293   0.1293   1.25
disea      0.0049   0.0063   0.0063   1.29
hlthg      0.0667   0.0616   0.0616   0.92
hlthf      0.1218   0.1434   0.1434   1.18
hlthp      0.2607   0.4029   0.4030   1.55
Output 31.3. Classical, HC0 and HC1 standard errors; with 20,190 observations HC0 and HC1 differ only in the fourth decimal.

What happens to a test when the wrong standard error is used? The next listing draws samples in which the true slope is zero and the error spread grows with the regressor, and counts how often a nominal 5 per cent test rejects.

"""How often a nominal 5 % test rejects a true null, with unequal error variances."""

import numpy as np
import statsmodels.api as sm

rng = np.random.default_rng(31)
n, reps = 200, 4000
reject = {"classical": 0, "robust": 0}
for _ in range(reps):
    x = rng.standard_normal(n)
    u = np.abs(x) * rng.standard_normal(n)  # error spread grows with |x|
    y = 1 + 0 * x + u  # the true slope is zero
    model = sm.OLS(y, sm.add_constant(x))
    reject["classical"] += abs(model.fit().tvalues[1]) > 1.96
    reject["robust"] += abs(model.fit(cov_type="HC1").tvalues[1]) > 1.96

for name, count in reject.items():
    print(f"{name:9s} rejection rate {count / reps:.3f}")
Listing 31.4. The rejection rate of a true null, with classical and robust standard errors. code/bachelor-2/31-regression-inference/listings/size_sim.py
$ python size_sim.py
classical rejection rate 0.254
robust    rejection rate 0.057
Output 31.4. The classical test rejects a true null a quarter of the time; the robust test close to the nominal 5 per cent.

The classical test rejects in 25.4 per cent of samples, five times as often as it claims; the robust test in 5.7 per cent. With a joint hypothesis the robust version of the FF statistic uses the robust variance matrix; on the RAND data the test of the health dummies falls from 11.78 to 5.40, still above the critical value (Exercise 6).

31.4 Clustered errors

Observations often come in groups: pupils in a class, workers in a firm, families in a town, the same person in several years. Anything shared by the group (a teacher, a manager, a local shock) puts a common component in the errors of its members. If the regressor is also shared within the group, the sample contains much less independent information than its size suggests.

Suppose there are GG groups of mm members, the regressor xx is the same for every member of a group, and the errors have variance σ2\sigma^2 and correlation ρ\rho between members of the same group. Then (Exercise 12)

Var⁡(β^1∣X)=σ2∑i(xi−xˉ)2 (1+(m−1)ρ).(31.2)\operatorname{Var}(\hat\beta_1 \mid X) = \frac{\sigma^2}{\sum_i(x_i - \bar x)^2}\,\bigl(1 + (m - 1)\rho\bigr).\tag{31.2}

Definition 31.8 (Moulton factor)

The Moulton factor is the ratio of the true standard error of a coefficient to the classical one when errors are correlated within groups; for groups of equal size mm, a regressor constant within groups and an error correlation ρ\rho, it is 1+(m−1)ρ\sqrt{1 + (m - 1)\rho}.

With groups of 20 and a correlation of only 0.2, the factor is 2.19: classical standard errors are less than half what they should be.

Definition 31.9 (Cluster-robust standard error)

A cluster-robust standard error replaces the middle of the sandwich by ∑g(∑i∈geixi)(∑i∈geixi)′\sum_g\bigl(\sum_{i \in g}e_ix_i\bigr)\bigl(\sum_{i \in g}e_ix_i\bigr)', summing within each group first, so that the errors may be correlated in any way within groups but are independent across them.

"""Grouped data: classical, robust and cluster-robust standard errors."""

import numpy as np
import statsmodels.api as sm

rng = np.random.default_rng(31)
G, m, rho = 50, 20, 0.2  # groups, members per group, error correlation within group
group = np.repeat(np.arange(G), m)
slopes, se = [], {"classical": [], "robust": [], "cluster": []}
for _ in range(500):
    x = rng.standard_normal(G)[group]  # the regressor is the same within a group
    u = np.sqrt(rho) * rng.standard_normal(G)[group]
    u += np.sqrt(1 - rho) * rng.standard_normal(G * m)
    model = sm.OLS(1 + 0.5 * x + u, sm.add_constant(x))
    slopes.append(model.fit().params[1])
    se["classical"].append(model.fit().bse[1])
    se["robust"].append(model.fit(cov_type="HC1").bse[1])
    fit = model.fit(cov_type="cluster", cov_kwds={"groups": group})
    se["cluster"].append(fit.bse[1])

print(f"true s.d. of the slope across samples: {np.std(slopes):.4f}")
for name, values in se.items():
    print(f"mean {name:9s} standard error: {np.mean(values):.4f}")
print(f"Moulton factor sqrt(1 + (m - 1) rho): {np.sqrt(1 + (m - 1) * rho):.3f}")
ratio = np.mean(se["cluster"]) / np.mean(se["classical"])
print(f"cluster over classical: {ratio:.3f}")
Listing 31.5. Fifty groups of twenty: classical, robust and cluster-robust standard errors against the true spread of the estimate. code/bachelor-2/31-regression-inference/listings/cluster_sim.py
$ python cluster_sim.py
true s.d. of the slope across samples: 0.0696
mean classical standard error: 0.0323
mean robust    standard error: 0.0322
mean cluster   standard error: 0.0684
Moulton factor sqrt(1 + (m - 1) rho): 2.191
cluster over classical: 2.115
Output 31.5. Only the cluster-robust standard error is close to the true standard deviation of the estimate.

Across 500 samples the slope has a standard deviation of 0.0696. The classical standard errors average 0.0323, and the robust ones 0.0322: robustness to unequal variances does nothing for correlation within groups. The cluster-robust standard error averages 0.0684, 2.115 times the classical one, close to the Moulton factor of 2.191. Cluster-robust standard errors need many clusters: their middle term is an average over groups, and with few groups it is itself very noisy, and often too small (the weekend problem has three).

The RAND data of this chapter are such a case. The experiment assigned insurance plans to families, not to persons, and kept each family on its plan for several years, so the plan variables are the same for every member and every year of a family, and one person’s errors are correlated across years. The standard errors of the plan coefficients should then be clustered by family; the classical and the robust ones printed above are both likely too small. The file used here has no family or person identifier, so the clustering cannot be done with it.

31.5 Large-sample results

Without normal errors, the tt and FF distributions are not exact. Large samples give approximations that need neither normality nor homoskedasticity.

Definition 31.10 (Asymptotic normality)

An estimator θ^\hat\theta is asymptotically normal if n(θ^−θ)\sqrt n(\hat\theta - \theta) converges in distribution to a normal distribution with mean zero as n→∞n \to \infty.

Theorem 31.11 (Large-sample distribution of least squares)

If the observations (yi,xi)(y_i, x_i) are independent and identically distributed, E[xiui]=0E[x_iu_i] = 0, Q=E[xixi′]Q = E[x_ix_i'] is invertible and the relevant moments are finite, then β^\hat\beta is consistent and n(β^−β)\sqrt n(\hat\beta - \beta) converges in distribution to N(0,Q−1E[ui2xixi′]Q−1)N\bigl(0, Q^{-1}E[u_i^2x_ix_i']Q^{-1}\bigr).

Proof. Admitted at this level. ∎

The variance in the theorem is the sandwich again; its sample version is the robust variance matrix. So tt statistics built with robust standard errors are approximately standard normal in large samples, which is why the robust test of the listing rejected close to 5 per cent of the time.

31.6 The bootstrap

Definition 31.12 (Bootstrap)

The bootstrap estimates the sampling distribution of a statistic by recomputing it on many samples drawn with replacement from the data, treating the sample as if it were the population.

To bootstrap a regression coefficient, draw nn observations (rows) with replacement, run the regression, keep the coefficient, and repeat a thousand times or more; the standard deviation of the kept coefficients is a standard error. Drawing rows keeps each observation’s regressors and error together, so the result is robust to heteroskedasticity; with grouped data whole groups must be drawn. The bootstrap is useful for statistics without a simple variance formula. It does not repair a bad design: drawing from a sample that has three clusters still gives three clusters.

Model — The classical linear model

Assumes. The Gauss–Markov assumptions and, for exact tt and FF distributions, normal errors.

Predicts. Least squares is the best linear unbiased estimator; classical standard errors and tt and FF tests have their stated properties in any sample size.

Tested. The spread of residuals against fitted values, and the comparison of classical with robust and cluster-robust standard errors: on the RAND data the residual spread rises more than threefold across fitted values.

Breaks. Heteroskedasticity makes classical standard errors wrong in either direction (25.4 per cent rejections in the simulation); correlation within groups makes them too small by the Moulton factor; robust and cluster-robust standard errors repair these in large samples and with many clusters, not with few.

31.7 Exercises

Exercise 31.1 ★

Read the opening chart. For which coefficients is the robust standard error larger than the classical one by more than 20 per cent? For which is it smaller?

Solution

Solution of Exercise 31.1.

More than 20 per cent larger: poor health (1.55), chronic diseases (1.29) and physical limitation (1.25). Smaller: good health (0.92), log coinsurance (0.93), the deductible plan (0.95), log maximum expense (0.98) and log incentive (0.99).

Exercise 31.2 ★

In the regression of the listing t_and_f.py, interpret the coefficient on physlm and its tt statistic, with classical and with robust standard errors.

Solution

Solution of Exercise 31.2.

A person with a physical limitation has 1.07 more visits than one without, with the plan variables, chronic diseases and self-rated health fixed. The classical tt is 10.32; the robust one is 1.0658/0.1293=8.241.0658/0.1293 = 8.24. Both reject a zero coefficient by far; the robust interval is a quarter wider.

Exercise 31.3 ★

A test at the 5 per cent level rejects a true null in 25.4 per cent of simulated samples. What does that mean for a researcher who reports a “significant” coefficient with classical standard errors in such data?

Solution

Solution of Exercise 31.3.

A “significant” result would appear in a quarter of samples even if the coefficient were zero, five times the stated risk: the reported pp-values are much too small, and many of the findings would be false.

Exercise 31.4 ★

Pupils are taught in classes of 25, and the error correlation within a class is 0.1. A regressor is the same for every pupil in a class. Compute the Moulton factor, and say how many independent pupils the sample is worth per class.

Solution

Solution of Exercise 31.4.

1+24×0.1=3.4=1.84\sqrt{1 + 24 \times 0.1} = \sqrt{3.4} = 1.84. The variance is 3.4 times the classical one, so a class of 25 carries the information of about 25/3.4=7.425/3.4 = 7.4 independent pupils.

Exercise 31.5 ★★

From the listing’s output, compute the FF statistic of the health dummies by hand from the two sums of squared residuals.

Solution

Solution of Exercise 31.5.

F=(382,137.5−381,469.6)/3381,469.6/20,180=222.618.90=11.78F = \dfrac{(382{,}137.5 - 381{,}469.6)/3}{381{,}469.6/20{,}180} = \dfrac{222.6}{18.90} = 11.78.

Exercise 31.6 ★★

(D) With the RAND data, test jointly that the three health dummies are zero and, separately, that the four plan variables are zero, with classical and with robust variance matrices.

Solution

Solution of Exercise 31.6.

Health dummies: 11.78 classical, 5.40 robust; the 5 per cent critical value of F(3,20,180)F(3, 20{,}180) is 2.605, so both reject. Plan variables: 82.26 classical, 80.80 robust, against a critical value of 2.372 for F(4,20,180)F(4, 20{,}180): both reject by far. The robust test changes the health statistic much more, as the opening chart suggests.

Exercise 31.7 ★★

In the Gauss–Markov listing, use the bottom and top quarters of xx instead of the halves. Predict, then compute, the variance of the grouping estimator. Does it beat least squares?

Solution

Solution of Exercise 31.7.

With quarters the gap between the group means of xx widens from 5.128 to 7.692, but each group has 10 observations instead of 20: the variance is 4×(1/10+1/10)/7.6922=0.013524 \times (1/10 + 1/10)/7.692^2 = 0.01352, smaller than 0.01521 with halves but still above least squares, 0.01141.

Exercise 31.8 ★★

Change the size listing so that the errors are homoskedastic. Predict, then compute, the two rejection rates.

Solution

Solution of Exercise 31.8.

Both should be close to 5 per cent: the classical test is exact in that case up to normality, and the robust one is valid in large samples. The simulation gives 0.054 and 0.056.

Exercise 31.9 ★★

In the cluster listing, what would the Moulton factor be if the errors were uncorrelated within groups? If the regressor varied within groups and were uncorrelated between members of a group?

Solution

Solution of Exercise 31.9.

With ρ=0\rho = 0 the factor is 1=1\sqrt{1} = 1. More generally the factor is 1+(m−1)ρxρ\sqrt{1 + (m - 1)\rho_x\rho}, with ρx\rho_x the correlation of the regressor within groups; with ρx=0\rho_x = 0 it is 1 again: correlated errors matter only when the regressor is correlated within groups too.

Exercise 31.10 ★★★

Show that the least-squares estimator of β1\beta_1 in yi=β0+β1xi+uiy_i = \beta_0 + \beta_1x_i + u_i is a linear function of the yiy_i with weights that sum to zero and satisfy ∑iwixi=1\sum_iw_ix_i = 1, and show directly that any other set of such weights gives a larger variance under homoskedasticity.

Solution

Solution of Exercise 31.10.

β^1=∑iwiyi\hat\beta_1 = \sum_iw_iy_i with wi=(xi−xˉ)/∑j(xj−xˉ)2w_i = (x_i - \bar x)/\sum_j(x_j - \bar x)^2; ∑iwi=0\sum_iw_i = 0 and ∑iwixi=1\sum_iw_ix_i = 1. A linear estimator ∑iciyi\sum_ic_iy_i has expectation β0∑ci+β1∑cixi\beta_0\sum c_i + \beta_1\sum c_ix_i, so it is unbiased for every β\beta if and only if ∑ci=0\sum c_i = 0 and ∑cixi=1\sum c_ix_i = 1. Write ci=wi+dic_i = w_i + d_i: then ∑di=0\sum d_i = 0 and ∑dixi=0\sum d_ix_i = 0, so ∑widi=0\sum w_id_i = 0 since wiw_i is linear in xix_i. The variance is σ2∑ci2=σ2(∑wi2+∑di2)≥σ2∑wi2\sigma^2\sum c_i^2 = \sigma^2(\sum w_i^2 + \sum d_i^2) \geq \sigma^2\sum w_i^2, with equality only if every di=0d_i = 0.

Exercise 31.11 ★★★

Derive (31.1) from β^−β=(X′X)−1X′u\hat\beta - \beta = (X'X)^{-1}X'u, and show that it reduces to σ2(X′X)−1\sigma^2(X'X)^{-1} under homoskedasticity.

Solution

Solution of Exercise 31.11.

With A=(X′X)−1X′A = (X'X)^{-1}X', Var⁡(β^∣X)=AVar⁡(u∣X)A′\operatorname{Var}(\hat\beta \mid X) = A\operatorname{Var}(u \mid X)A'. With independent errors Var⁡(u∣X)=diag⁡(σi2)\operatorname{Var}(u \mid X) = \operatorname{diag}(\sigma_i^2) and X′diag⁡(σi2)X=∑iσi2xixi′X'\operatorname{diag}(\sigma_i^2)X = \sum_i\sigma_i^2x_ix_i', which gives the sandwich. If σi2=σ2\sigma_i^2 = \sigma^2, the middle is σ2X′X\sigma^2X'X and the product is σ2(X′X)−1\sigma^2(X'X)^{-1}.

Exercise 31.12 ★★★

Derive (31.2).

Solution

Solution of Exercise 31.12.

With one regressor, β^1−β1=∑i(xi−xˉ)ui/S\hat\beta_1 - \beta_1 = \sum_i(x_i - \bar x)u_i/S, S=∑i(xi−xˉ)2S = \sum_i(x_i - \bar x)^2. Let xgx_g be the value in group gg. Then ∑i(xi−xˉ)ui=∑g(xg−xˉ)∑i∈gui\sum_i(x_i - \bar x)u_i = \sum_g(x_g - \bar x)\sum_{i \in g}u_i, and the group sums are independent with variance mσ2+m(m−1)ρσ2m\sigma^2 + m(m - 1)\rho\sigma^2. So the variance is ∑g(xg−xˉ)2mσ2(1+(m−1)ρ)/S2\sum_g(x_g - \bar x)^2m\sigma^2(1 + (m - 1)\rho)/S^2; since S=m∑g(xg−xˉ)2S = m\sum_g(x_g - \bar x)^2, this is σ2(1+(m−1)ρ)/S\sigma^2(1 + (m - 1)\rho)/S.

31.8 Problem: Brenland’s census of firms

Problem 31.1

Weekend problem — Brenland’s census of firms: a log production function, robust and clustered intervals, the test of constant returns, and three clusters

Brenland’s census of 2025 covers 500 firms in three sectors: 51 in farming, 123 in manufacturing and 326 in services. Let yy be log output, ll log workers and kk log capital, and estimate y=β0+βll+βkk+uy = \beta_0 + \beta_ll + \beta_kk + u.

Part I — A log production function.

  1. What production function does the regression correspond to?
  2. What do βl\beta_l and βk\beta_k measure?
  3. Give the estimates and R2R^2.
  4. What does βl+βk\beta_l + \beta_k measure?
  5. Why might firms with a high error uu also choose more workers, and what would that do to β^l\hat\beta_l?

Part II — Robust and clustered intervals.

  1. Give the classical standard error of β^k\hat\beta_k.
  2. Give the heteroskedasticity-robust one, and a 95 per cent interval.
  3. Give the standard error clustered by sector.
  4. With three clusters, which critical value should the interval use?
  5. Give the clustered 95 per cent interval.
  6. Compare the three standard errors. Which is smallest, and should that reassure?

Part III — The test of constant returns.

  1. Write the hypothesis of constant returns as a restriction.
  2. Write the restricted regression.
  3. Give the two sums of squared residuals.
  4. Compute the FF statistic.
  5. Compare it with the 5 per cent critical value of F(1,497)F(1, 497), 3.86.
  6. Give the robust version of the test.
  7. State the verdict.

Part IV — What changes with three clusters.

  1. Why is a cluster-robust variance from three clusters unreliable?
  2. How many degrees of freedom does a tt test with three clusters have?
  3. Why can the clustered standard error be smaller than the robust one here?
  4. What could replace sector clustering with so few sectors?
  5. If the census had 300 villages, each with a few firms, would clustering by village help?
  6. Does the bootstrap solve the problem of three clusters?
  7. State the result: the capital elasticity with robust and clustered intervals, and the verdict on constant returns.
Solution

Solution of Problem 31.1.

Part I. 1. A Cobb–Douglas function Y=ALβlKβkeuY = AL^{\beta_l}K^{\beta_k}e^u. 2. Elasticities: the per cent change in output for a 1 per cent change in workers, or in capital, the other fixed. 3. β^0=2.777\hat\beta_0 = 2.777, β^l=0.650\hat\beta_l = 0.650, β^k=0.352\hat\beta_k = 0.352; R2=0.982R^2 = 0.982. 4. Returns to scale: 1.0014 here, close to one. 5. A firm that knows it is productive hires more; ll is then correlated with uu, and β^l\hat\beta_l is biased upward. Part II. 6. 0.0124. 7. 0.0120; interval 0.352±1.96×0.01200.352 \pm 1.96 \times 0.0120, from 0.328 to 0.375. 8. 0.0044. 9. The tt distribution with G−1=2G - 1 = 2 degrees of freedom: 4.303. 10. 0.352±4.303×0.00440.352 \pm 4.303 \times 0.0044, from 0.333 to 0.371. 11. The clustered one is the smallest, about a third of the others. It should not reassure: with three clusters the middle of the sandwich is a sum of three terms, and can be far too small by chance. Part III. 12. βl+βk=1\beta_l + \beta_k = 1. 13. y−l=β0+βk(k−l)+uy - l = \beta_0 + \beta_k(k - l) + u: log output per worker on log capital per worker. 14. 11.0341 restricted, 11.0329 unrestricted. 15. F=(11.0341−11.0329)/(11.0329/497)=0.054F = (11.0341 - 11.0329)/(11.0329/497) = 0.054 from the rounded sums, 0.053 from the unrounded ones: about 0.05. 16. Far below 3.86. 17. 0.055. 18. Constant returns are not rejected: the estimated sum is 1.0014. Part IV. 19. The cluster-robust variance is an average over clusters; with three it rests on three numbers. 20. Two. 21. Three sums of eixie_ix_i can happen to be small, or to cancel, so the estimate of the middle can fall below the robust one. 22. Robust standard errors with sector indicators in the regression, which remove anything shared by a sector from the error. 23. Yes, if errors are correlated within villages: 300 clusters are enough for the large-sample results. 24. No: drawing whole sectors with replacement from three sectors still gives only a handful of distinct samples. 25. Brenland’s capital elasticity is 0.352, with a robust 95 per cent interval of 0.328 to 0.375 and a sector-clustered one of 0.333 to 0.371 that should not be trusted with three clusters; constant returns to scale are not rejected (F=0.055F = 0.055).

এই অধ্যায়ে সংজ্ঞায়িত পরিভাষা-শব্দ

পরিভাষায় সব 1086 টি শব্দ দেখো