Inference in multiple regression多元回歸的統計推論

Week 3 found that each extra year of education is associated with $42 more in monthly earnings, holding IQ fixed. But that number came from one sample of 935 people. Could the true effect be zero, and the $42 just luck? This week builds the tools to answer: t tests, p-values, confidence intervals and F tests.

第 3 週發現,在智商不變的情況下,每多一年教育,月收入平均高 42 美元。但這個數字只來自一個 935 人的樣本。真正的效應會不會是零,42 美元只是運氣?本週建立回答這個問題的工具:t 檢定、p 值、置信區間和 F 檢定。

Builds on 先修內容
Week 3
Reading time 閱讀時間
About 45 minutes
Data 數據
wage2, n = 935
Code 程式碼
R, Python

Hypotheses about the population關於總體的假設

A hypothesis test asks whether the data are consistent with a specific claim about the population. Start from the multiple regression model of Week 3:

假設檢定問的是:數據是否與某個關於總體的具體說法相符。先回到第 3 週的多元回歸模型:

wagei=β0+β1 educi+β2 IQi+ui.\text{wage}_i = \beta_0 + \beta_1\, \text{educ}_i + \beta_2\, \text{IQ}_i + u_i.

Every test begins with a claim in words, translated into a restriction on the coefficients. This is the null hypothesis, written H0H_0.

每個檢定都從一句文字說法開始,再把它翻譯成對係數的約束,這就是原假設(虛無假設),記作 H0H_0。

Education has no effect on wages once IQ is controlled for.

控制智商後,教育對工資沒有影響。

H0:β1=0H_0: \beta_1 = 0

An extra year of education has the same effect on average wages as one more IQ point.

多一年教育對平均工資的影響,與智商多一分相同。

H0:β1=β2H_0: \beta_1 = \beta_2

The alternative hypothesis H1H_1 is what we conclude if H0H_0 is rejected. It can be two-sided, H1:β1≠0H_1: \beta_1 \neq 0, or one-sided, H1:β1>0H_1: \beta_1 > 0 or H1:β1<0H_1: \beta_1 < 0. Choose a one-sided alternative only when theory or common sense rules out the other direction before you look at the data. For education it is hard to see how an extra year would lower wages, so H1:β1>0H_1: \beta_1 > 0 is reasonable.

備擇假設 H1H_1 是拒絕 H0H_0 後我們接受的結論。它可以是雙邊的 H1:β1≠0H_1: \beta_1 \neq 0,也可以是單邊的 H1:β1>0H_1: \beta_1 > 0 或 H1:β1<0H_1: \beta_1 < 0。只有在看數據之前,理論或常識已經排除了另一個方向,才應選用單邊備擇假設。很難想像多讀一年書會令工資下降,所以 H1:β1>0H_1: \beta_1 > 0 是合理的。

The classical linear model assumptions經典線性模型假設

To test a hypothesis, we need to know how β^j\bh_j would vary from sample to sample if H0H_0 were true. That requires assumptions. The classical linear model assumes:

要檢定一個假設,我們需要知道:如果 H0H_0 成立,β^j\bh_j 在不同樣本之間會怎樣變化。這需要一些假設。經典線性模型假設:

  1. Linear in parameters. y=β0+β1x1+⋯+βkxk+uy = \beta_0 + \beta_1 x_1 + \dots + \beta_k x_k + u.

    參數線性。y=β0+β1x1+⋯+βkxk+uy = \beta_0 + \beta_1 x_1 + \dots + \beta_k x_k + u。

  2. No perfect collinearity. No explanatory variable is an exact linear combination of the others, so X′X\mathbf{X}\T\mathbf{X} is invertible.

    沒有完全共線性。沒有任何解釋變數是其他變數的精確線性組合,所以 X′X\mathbf{X}\T\mathbf{X} 可逆。

  3. Zero conditional mean. E(u∣x1,…,xk)=0E(u \mid x_1, \dots, x_k) = 0.

    條件均值為零。E(u∣x1,…,xk)=0E(u \mid x_1, \dots, x_k) = 0。

  4. Random sampling. The observations are a random sample from the population.

    隨機抽樣。觀測值是從總體中隨機抽取的樣本。

  5. Homoskedasticity. Var⁡(u∣x1,…,xk)=σ2\operatorname{Var}(u \mid x_1, \dots, x_k) = \sigma^2: the spread of the errors does not depend on the explanatory variables.

    同方差。Var⁡(u∣x1,…,xk)=σ2\operatorname{Var}(u \mid x_1, \dots, x_k) = \sigma^2:誤差的離散程度不隨解釋變數改變。

  6. Normality. Conditional on the explanatory variables, u∼N(0,σ2)u \sim N(0, \sigma^2).

    正態性。在給定解釋變數的條件下,u∼N(0,σ2)u \sim N(0, \sigma^2)。

Each assumption does a different job. The first four make OLS unbiased: on average across samples, it hits the true coefficients. The fifth gives the simple formula for its standard errors. The sixth makes the distribution of the test statistic exact in any sample size.

每個假設各有作用。前四個令 OLS 無偏:在所有可能的樣本上平均,估計值等於真實係數。第五個給出標準誤的簡單公式。第六個令檢定統計量的分佈在任何樣本量下都是準確的。

The t statistict 統計量

Under the six assumptions, the estimation error β^j−βj\bh_j - \beta_j, divided by its standard error, follows a tt distribution with n−k−1n - k - 1 degrees of freedom:

在六個假設下,估計誤差 β^j−βj\bh_j - \beta_j 除以其標準誤,服從自由度為 n−k−1n - k - 1 的 tt 分佈:

β^j−βjse⁡(β^j)∼tn−k−1.\frac{\bh_j - \beta_j}{\operatorname{se}(\bh_j)} \sim t_{n-k-1}.

Here nn is the number of observations and kk the number of slope coefficients, so n−k−1n - k - 1 is the sample size minus the number of coefficients estimated. The standard error is

其中 nn 是觀測值數目,kk 是斜率係數的數目,所以 n−k−1n - k - 1 就是樣本量減去估計的係數數目。標準誤是

se⁡(β^j)=σ^ajj,σ^=SSRn−k−1,\operatorname{se}(\bh_j) = \hat\sigma \sqrt{a_{jj}}, \qquad \hat\sigma = \sqrt{\frac{\text{SSR}}{n - k - 1}},

where ajja_{jj} is the jjth diagonal element of (X′X)−1(\mathbf{X}\T\mathbf{X})^{-1} and σ^\hat\sigma estimates the standard deviation of the errors. To test H0:βj=βj0H_0: \beta_j = \beta_{j0}, put the hypothesised value in place of βj\beta_j:

其中 ajja_{jj} 是 (X′X)−1(\mathbf{X}\T\mathbf{X})^{-1} 的第 jj 個對角元素,σ^\hat\sigma 估計誤差的標準差。要檢定 H0:βj=βj0H_0: \beta_j = \beta_{j0},便把假設值代入 βj\beta_j:

t=β^j−βj0se⁡(β^j).t = \frac{\bh_j - \beta_{j0}}{\operatorname{se}(\bh_j)}.

It measures how many standard errors the estimate lies from the hypothesised value. If H0H_0 is true, values far from zero are unlikely.

它量度估計值距離假設值有多少個標準誤。如果 H0H_0 成立,遠離零的數值是不太可能出現的。

Why a t distribution? 為甚麼是 t 分佈?

Step 1: the estimator is normal. Write β^=(X′X)−1X′y\bhv = (\mathbf{X}\T\mathbf{X})^{-1}\mathbf{X}\T\mathbf{y} and substitute y=Xβ+u\mathbf{y} = \mathbf{X}\boldsymbol{\beta} + \mathbf{u}:

第一步:估計量服從正態分佈。把 y=Xβ+u\mathbf{y} = \mathbf{X}\boldsymbol{\beta} + \mathbf{u} 代入 β^=(X′X)−1X′y\bhv = (\mathbf{X}\T\mathbf{X})^{-1}\mathbf{X}\T\mathbf{y}:

β^=β+(X′X)−1X′u.\bhv = \boldsymbol{\beta} + (\mathbf{X}\T\mathbf{X})^{-1}\mathbf{X}\T\mathbf{u}.

Given X\mathbf{X}, the estimator is β\boldsymbol{\beta} plus a fixed linear combination of normal errors, so it is normal. Its mean is β\boldsymbol{\beta} by assumption 3. With Var⁡(u∣X)=σ2I\operatorname{Var}(\mathbf{u} \mid \mathbf{X}) = \sigma^2\mathbf{I} from assumptions 4 and 5, its variance is

給定 X\mathbf{X},估計量等於 β\boldsymbol{\beta} 加上正態誤差的固定線性組合,所以服從正態分佈。根據假設 3,它的均值是 β\boldsymbol{\beta}。由假設 4 和 5 得 Var⁡(u∣X)=σ2I\operatorname{Var}(\mathbf{u} \mid \mathbf{X}) = \sigma^2\mathbf{I},所以它的方差是

Var⁡(β^∣X)=(X′X)−1X′(σ2I)X(X′X)−1=σ2(X′X)−1.\begin{aligned} \operatorname{Var}(\bhv \mid \mathbf{X}) &= (\mathbf{X}\T\mathbf{X})^{-1}\mathbf{X}\T (\sigma^2 \mathbf{I}) \mathbf{X} (\mathbf{X}\T\mathbf{X})^{-1} \\ &= \sigma^2 (\mathbf{X}\T\mathbf{X})^{-1}. \end{aligned}

So β^j∼N(βj, σ2ajj)\bh_j \sim N(\beta_j,\, \sigma^2 a_{jj}), and standardising gives

所以 β^j∼N(βj, σ2ajj)\bh_j \sim N(\beta_j,\, \sigma^2 a_{jj}),標準化後得到

Z=β^j−βjσajj∼N(0,1).Z = \frac{\bh_j - \beta_j}{\sigma\sqrt{a_{jj}}} \sim N(0, 1).

Step 2: replace σ by its estimate. σ\sigma is unknown, so we use σ^\hat\sigma. Under the same assumptions, (n−k−1)σ^2/σ2(n-k-1)\hat\sigma^2/\sigma^2 has a chi-squared distribution with n−k−1n-k-1 degrees of freedom and is independent of ZZ. Then

第二步:以估計值代替 σ。σ\sigma 是未知的,所以改用 σ^\hat\sigma。在同樣的假設下,(n−k−1)σ^2/σ2(n-k-1)\hat\sigma^2/\sigma^2 服從自由度為 n−k−1n-k-1 的卡方分佈,並且與 ZZ 獨立。於是

β^j−βjσ^ajj=Z(n−k−1)σ^2/σ2n−k−1∼tn−k−1,\frac{\bh_j - \beta_j}{\hat\sigma\sqrt{a_{jj}}} = \frac{Z}{\sqrt{\dfrac{(n-k-1)\hat\sigma^2/\sigma^2}{n-k-1}}} \sim t_{n-k-1},

because a standard normal divided by the square root of an independent chi-squared over its degrees of freedom is, by definition, a tt variable. The unknown σ\sigma cancels from the top and bottom.

因為標準正態變數除以「獨立卡方變數除以其自由度」的平方根,按定義就是 tt 變數。分子分母中的未知 σ\sigma 互相抵銷。

The tt distribution looks like the standard normal but has fatter tails, because estimating σ\sigma adds uncertainty. With few degrees of freedom the difference is clear; with hundreds, it almost disappears. Move the degrees-of-freedom slider in the next section to see this.

tt 分佈的形狀與標準正態分佈相似,但尾部較厚,因為估計 σ\sigma 帶來了額外的不確定性。自由度少時差別明顯;自由度達到幾百時,差別幾乎消失。可以在下一節拖動自由度滑桿觀察。

Critical values and p-values臨界值與 p 值

A test needs a rule for when to reject H0H_0. First choose the significance level α\alpha: the probability of rejecting H0H_0 when it is in fact true. α=0.05\alpha = 0.05 is the usual choice. Then find the critical value cc that leaves probability α\alpha in the rejection region:

檢定需要一條規則,決定甚麼時候拒絕 H0H_0。首先選擇顯著水平 α\alpha:當 H0H_0 其實成立時,錯誤拒絕它的概率。通常取 α=0.05\alpha = 0.05。然後找出臨界值 cc,使拒絕域的概率剛好是 α\alpha:

Alternative 備擇假設Critical value 臨界值Reject H₀ if 拒絕 H₀ 的條件
H1:βj>0H_1: \beta_j > 0P(tn−k−1>c)=αP(t_{n-k-1} > c) = \alphat>ct > c
H1:βj<0H_1: \beta_j < 0P(tn−k−1>c)=αP(t_{n-k-1} > c) = \alphat<−ct < -c
H1:βj≠0H_1: \beta_j \neq 0P(tn−k−1>c)=α/2P(t_{n-k-1} > c) = \alpha/2∣t∣>c|t| > c

A two-sided test splits α\alpha between both tails, so its critical value is larger than a one-sided test’s at the same level.

雙邊檢定把 α\alpha 平分到兩條尾巴,所以在相同顯著水平下,它的臨界值比單邊檢定大。

tt distributionStandard normal 標準正態Rejection region 拒絕域

Alternative 備擇假設
Critical value 臨界值
–
pp-value
–
Decision 結論
–

Try:

Critical values at the 5% level 5% 顯著水平下的臨界值
One-sidedTwo-sided
t6t_{6}1.9432.447
t120t_{120} printed table 統計表1.6581.980
t932t_{932}1.6461.963
Standard normal 標準正態1.6451.960

Printed tables stop at 120 degrees of freedom, so worked answers often use 1.980 for large samples. The exact value for 932 degrees of freedom is 1.963. Either leads to the same decision unless the t statistic falls between them.

印刷的統計表通常只列到 120 個自由度,所以大樣本的題目常用 1.980。932 個自由度的準確值是 1.963。除非 t 統計量剛好落在兩者之間,否則結論不會改變。

The p-value reports the same comparison as a probability. It is the chance, if H0H_0 were true, of a test statistic at least as extreme as the one observed:

p 值以概率的形式表達同一個比較。它是在 H0H_0 成立時,得到一個至少與觀測值同樣極端的檢定統計量的概率:

p=P(∣tn−k−1∣>∣t∣).p = P\big(|t_{n-k-1}| > |t|\big).

That is the two-sided version. For H1:βj>0H_1: \beta_j > 0 it is P(tn−k−1>t)P(t_{n-k-1} > t), and for H1:βj<0H_1: \beta_j < 0 it is P(tn−k−1<t)P(t_{n-k-1} < t).

以上是雙邊檢定的 p 值。對 H1:βj>0H_1: \beta_j > 0,p 值是 P(tn−k−1>t)P(t_{n-k-1} > t);對 H1:βj<0H_1: \beta_j < 0,則是 P(tn−k−1<t)P(t_{n-k-1} < t)。

Reject H0H_0 at level α\alpha exactly when p<αp < \alpha. The p-value saves choosing α\alpha in advance: a reader can compare it with whatever level they prefer. Statistical software reports two-sided p-values for H0:βj=0H_0: \beta_j = 0. For a one-sided alternative, halve it, provided the estimate has the sign the alternative predicts.

當且僅當 p<αp < \alpha 時,在 α\alpha 水平下拒絕 H0H_0。p 值的好處是不必事先選定 α\alpha,讀者可以按自己偏好的水平比較。統計軟件報告的是 H0:βj=0H_0: \beta_j = 0 的雙邊 p 值。如果用單邊備擇假設,便把它減半,前提是估計值的符號與備擇假設的方向一致。

Example: is education significant?例子:教育是否顯著?

Here is the regression of monthly earnings on education and IQ, as a statistics package reports it:

以下是月收入對教育和智商的回歸,與統計軟件輸出的格式相同:

Dependent variable: monthly earnings (US$), n = 935 被解釋變數:月收入(美元)
EstimateStd. errorttpp
Intercept 截距−128.8992.18−1.400.162
educ 教育年數42.066.556.42< 0.001
IQ 智商5.140.965.38< 0.001

Degrees of freedom n−k−1=935−2−1=932n - k - 1 = 935 - 2 - 1 = 932. σ^=376.7\hat\sigma = 376.7, R2=0.134R^2 = 0.134. Overall F=72.02F = 72.02 on 2 and 932 degrees of freedom.

自由度 n−k−1=935−2−1=932n - k - 1 = 935 - 2 - 1 = 932。σ^=376.7\hat\sigma = 376.7,R2=0.134R^2 = 0.134。整體 F=72.02F = 72.02,自由度為 2 和 932。

Test whether education matters once IQ is held fixed, step by step:

逐步檢定在智商不變時教育是否有影響:

  1. Hypotheses 假設

    H0:β1=0H1:β1≠0H_0: \beta_1 = 0 \qquad H_1: \beta_1 \neq 0
  2. Test statistic and null distribution 檢定統計量與原假設下的分佈

    t=β^1−0se⁡(β^1)∼t932 under H0t = \frac{\bh_1 - 0}{\operatorname{se}(\bh_1)} \sim t_{932} \text{ under } H_0
  3. Calculate 計算

    t=42.066.55=6.42t = \frac{42.06}{6.55} = 6.42
  4. Critical value 臨界值

    Two-sided, α=0.05\alpha = 0.05: c=1.963c = 1.963 (1.980 from a printed table).

    雙邊,α=0.05\alpha = 0.05:c=1.963c = 1.963(統計表為 1.980)。

  5. Decision 決定

    ∣6.42∣>1.963|6.42| > 1.963, so reject H0H_0. Equivalently, p<0.001<0.05p < 0.001 < 0.05.

    ∣6.42∣>1.963|6.42| > 1.963,所以拒絕 H0H_0。等價地,p<0.001<0.05p < 0.001 < 0.05。

  6. Conclusion in context 結合背景的結論

    Education is statistically significant at the 5% level. We reject the hypothesis that, holding IQ fixed, education has no effect on earnings.

    教育在 5% 水平下統計顯著。我們拒絕「在智商不變時,教育對收入沒有影響」這個假設。

IQ is also significant (t=5.38t = 5.38). The intercept is not (t=−1.40t = -1.40, p=0.162p = 0.162), but that is of no interest: nobody in the sample has zero years of schooling and an IQ of zero.

智商同樣顯著(t=5.38t = 5.38)。截距並不顯著(t=−1.40t = -1.40,p=0.162p = 0.162),但這並不重要:樣本中沒有人教育年數和智商都是零。

Testing a single linear restriction檢定單一線性約束

Some questions involve two coefficients at once. In a model of log earnings,

有些問題同時涉及兩個係數。在對數收入的模型中,

log⁡(wagei)=β0+β1 educi+β2 experi+β3 IQi+ui,\begin{aligned} \log(\text{wage}_i) = \beta_0 &+ \beta_1\, \text{educ}_i + \beta_2\, \text{exper}_i \\ &+ \beta_3\, \text{IQ}_i + u_i, \end{aligned}

each coefficient times 100 is roughly the percentage change in earnings for a one-unit change in that variable. Is a year of education worth more than a year of work experience? That is H0:β1=β2H_0: \beta_1 = \beta_2 against H1:β1>β2H_1: \beta_1 > \beta_2, or equivalently H0:β1−β2=0H_0: \beta_1 - \beta_2 = 0.

每個係數乘以 100,大約就是該變數增加一個單位時收入變化的百分比。一年教育是否比一年工作經驗更有價值?這就是檢定 H0:β1=β2H_0: \beta_1 = \beta_2,備擇假設為 H1:β1>β2H_1: \beta_1 > \beta_2,等價於 H0:β1−β2=0H_0: \beta_1 - \beta_2 = 0。

The natural statistic is

最直接的檢定統計量是

t=β^1−β^2se⁡(β^1−β^2),t = \frac{\bh_1 - \bh_2}{\operatorname{se}(\bh_1 - \bh_2)},

but standard output does not report se⁡(β^1−β^2)\operatorname{se}(\bh_1 - \bh_2). It depends on the covariance between the two estimates, not only on their separate standard errors.

但標準輸出不會報告 se⁡(β^1−β^2)\operatorname{se}(\bh_1 - \bh_2),因為它不僅取決於兩個估計值各自的標準誤,還取決於兩者之間的協方差。

Why the separate standard errors are not enough 為甚麼單獨的標準誤不夠

For any two random variables,

對任意兩個隨機變數,

Var⁡(β^1−β^2)=Var⁡(β^1)+Var⁡(β^2)−2Cov⁡(β^1,β^2).\begin{aligned} \operatorname{Var}(\bh_1 - \bh_2) &= \operatorname{Var}(\bh_1) + \operatorname{Var}(\bh_2) \\ &\quad - 2\operatorname{Cov}(\bh_1, \bh_2). \end{aligned}

All three terms are entries of σ^2(X′X)−1\hat\sigma^2 (\mathbf{X}\T\mathbf{X})^{-1}, so se⁡(β^1−β^2)=σ^a11+a22−2a12\operatorname{se}(\bh_1 - \bh_2) = \hat\sigma\sqrt{a_{11} + a_{22} - 2a_{12}}. In this example it is 0.0067. Using only the two reported standard errors and ignoring the covariance would give 0.00732+0.00322=0.0080\sqrt{0.0073^2 + 0.0032^2} = 0.0080, which is wrong.

三項都是 σ^2(X′X)−1\hat\sigma^2 (\mathbf{X}\T\mathbf{X})^{-1} 中的元素,所以 se⁡(β^1−β^2)=σ^a11+a22−2a12\operatorname{se}(\bh_1 - \bh_2) = \hat\sigma\sqrt{a_{11} + a_{22} - 2a_{12}}。這個例子中它等於 0.0067。如果只用兩個報告出來的標準誤而忽略協方差,會得到 0.00732+0.00322=0.0080\sqrt{0.0073^2 + 0.0032^2} = 0.0080,這是錯的。

The reparametrisation trick makes the software report it for you. Define δ=β1−β2\delta = \beta_1 - \beta_2, so β1=δ+β2\beta_1 = \delta + \beta_2. Substitute and regroup:

重新參數化技巧可以讓軟件直接報告這個標準誤。定義 δ=β1−β2\delta = \beta_1 - \beta_2,即 β1=δ+β2\beta_1 = \delta + \beta_2。代入後重新整理:

log⁡(wagei)=β0+(δ+β2) educi+β2 experi+β3 IQi+ui=β0+δ educi+β2 (educi+experi)+β3 IQi+ui.\begin{aligned} \log(\text{wage}_i) &= \beta_0 + (\delta + \beta_2)\, \text{educ}_i + \beta_2\, \text{exper}_i \\ &\qquad + \beta_3\, \text{IQ}_i + u_i \\ &= \beta_0 + \delta\, \text{educ}_i + \beta_2\, (\text{educ}_i + \text{exper}_i) \\ &\qquad + \beta_3\, \text{IQ}_i + u_i. \end{aligned}

Regress log⁡(wage)\log(\text{wage}) on educ, a new variable educ + exper, and IQ. The coefficient on educ is now δ^\hat\delta, and its standard error and t statistic come with the output.

把 log⁡(wage)\log(\text{wage}) 對 educ、新變數 educ + exper 和 IQ 做回歸。這時 educ 的係數就是 δ^\hat\delta,它的標準誤和 t 統計量都會出現在輸出中。

Dependent variable: log monthly earnings, n = 935 被解釋變數:月收入的對數
(1) Original(2) Reparametrised
Intercept 截距 5.1981(0.1215)5.1981(0.1215)
educ 教育年數 0.0571(0.0073)0.0376(0.0067)
exper 工作經驗 0.0195(0.0032)—
educ + exper 教育 + 經驗 —0.0195(0.0032)
IQ 智商 0.0058(0.0010)0.0058(0.0010)
R2R^20.16220.1622
SSR\text{SSR}138.78138.78

Standard errors in parentheses. Both columns are the same fitted model: the residuals, R² and SSR are identical. Only the labels on the coefficients change.

括號內為標準誤。兩欄其實是同一個擬合模型:殘差、R² 和 SSR 完全相同,改變的只是係數的含義。

t=δ^se⁡(δ^)=0.03760.0067=5.59.t = \frac{\hat\delta}{\operatorname{se}(\hat\delta)} = \frac{0.0376}{0.0067} = 5.59.

This exceeds the one-sided 5% critical value of 1.646, so reject H0H_0. Holding IQ fixed, a year of education raises earnings by about 3.8 percentage points more than a year of experience: roughly 5.7% against 2.0%.

這大於單邊 5% 臨界值 1.646,所以拒絕 H0H_0。在智商不變的情況下,一年教育帶來的收入增幅比一年工作經驗高約 3.8 個百分點:大約是 5.7% 對 2.0%。

Confidence intervals置信區間

A test answers yes or no for one hypothesised value. A confidence interval gives the whole range of values the data are consistent with. A 100(1−α)%100(1-\alpha)\% confidence interval for βj\beta_j is

檢定只對一個假設值回答「是」或「否」。置信區間則給出與數據相符的整個數值範圍。βj\beta_j 的 100(1−α)%100(1-\alpha)\% 置信區間是

[ β^j−c⋅se⁡(β^j),    β^j+c⋅se⁡(β^j) ],\Big[\, \bh_j - c \cdot \operatorname{se}(\bh_j),\;\; \bh_j + c \cdot \operatorname{se}(\bh_j) \,\Big],

where cc is the two-sided critical value: P(tn−k−1>c)=α/2P(t_{n-k-1} > c) = \alpha/2.

其中 cc 是雙邊臨界值:P(tn−k−1>c)=α/2P(t_{n-k-1} > c) = \alpha/2。

Show every step 顯示完整推導

By the definition of cc, the t statistic lies between −c-c and cc with probability 1−α1 - \alpha:

按 cc 的定義,t 統計量落在 −c-c 與 cc 之間的概率是 1−α1 - \alpha:

P(−c≤β^j−βjse⁡(β^j)≤c)=1−α.P\left(-c \le \frac{\bh_j - \beta_j}{\operatorname{se}(\bh_j)} \le c\right) = 1 - \alpha.

Multiply through by se⁡(β^j)\operatorname{se}(\bh_j), subtract β^j\bh_j, and multiply by −1-1, which reverses both inequalities:

兩邊乘以 se⁡(β^j)\operatorname{se}(\bh_j),減去 β^j\bh_j,再乘以 −1-1(不等號方向隨之反轉):

P(β^j−c⋅se⁡(β^j)≤βj≤β^j+c⋅se⁡(β^j))=1−α.\begin{aligned} P\Big(\bh_j - c \cdot \operatorname{se}(\bh_j) &\le \beta_j \\ &\le \bh_j + c \cdot \operatorname{se}(\bh_j)\Big) = 1 - \alpha. \end{aligned}

For education in the wage regression, with c=1.963c = 1.963:

以工資回歸中的教育為例,c=1.963c = 1.963:

42.06±1.963×6.55  =  [ 29.20,  54.91 ].42.06 \pm 1.963 \times 6.55 \;=\; [\,29.20,\; 54.91\,].

Zero is not in the interval, which matches the test in Section 5: a two-sided test at level α\alpha rejects H0:βj=bH_0: \beta_j = b exactly when bb lies outside the 100(1−α)%100(1-\alpha)\% interval. The interval also says more than the test did: the effect is somewhere between about $29 and $55 a month.

零不在區間之內,與第 5 節的檢定結果一致:在 α\alpha 水平下的雙邊檢定拒絕 H0:βj=bH_0: \beta_j = b,當且僅當 bb 落在 100(1−α)%100(1-\alpha)\% 置信區間之外。區間提供的資訊也比檢定多:效應大約在每月 29 至 55 美元之間。

Joint hypotheses: the F test聯合假設:F 檢定

Some hypotheses impose several restrictions at once. In the model y=β0+β1x1+β2x2+β3x3+β4x4+uy = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \beta_3 x_3 + \beta_4 x_4 + u, consider

有些假設同時施加幾個約束。在模型 y=β0+β1x1+β2x2+β3x3+β4x4+uy = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \beta_3 x_3 + \beta_4 x_4 + u 中,考慮

H0:β1=β2,    β1=−β3,    β4=0,H_0: \beta_1 = \beta_2, \;\; \beta_1 = -\beta_3, \;\; \beta_4 = 0,

against H1H_1: at least one of the three fails. A t test handles only one restriction, so we compare two regressions. The unrestricted model is the original. The restricted model imposes H0H_0: replace β2\beta_2 by β1\beta_1, β3\beta_3 by −β1-\beta_1, and drop x4x_4:

備擇假設 H1H_1:三個約束中至少有一個不成立。t 檢定只能處理一個約束,所以我們比較兩個回歸。無約束模型就是原模型;約束模型則施加 H0H_0:把 β2\beta_2 換成 β1\beta_1、β3\beta_3 換成 −β1-\beta_1,並去掉 x4x_4:

y=β0+β1(x1+x2−x3)+u.y = \beta_0 + \beta_1 (x_1 + x_2 - x_3) + u.

Imposing restrictions can only make the fit worse, so SSRr≥SSRur\text{SSR}_r \ge \text{SSR}_{ur}. The question is whether it gets much worse. The F statistic scales the increase, and follows an F distribution when H0H_0 is true:

施加約束只會令擬合變差,所以 SSRr≥SSRur\text{SSR}_r \ge \text{SSR}_{ur}。問題是它是否變差很多。F 統計量把這個增幅標準化;當 H0H_0 成立時,它服從 F 分佈:

F=(SSRr−SSRur)/qSSRur/(n−k−1)∼Fq, n−k−1,F = \frac{(\text{SSR}_r - \text{SSR}_{ur})/q}{\text{SSR}_{ur}/(n - k - 1)} \sim F_{q,\, n-k-1},

where qq is the number of restrictions (here 3) and n−k−1n - k - 1 comes from the unrestricted model. FF is never negative, and large values are evidence against H0H_0, so we reject when F>cF > c, the upper α\alpha point of the Fq, n−k−1F_{q,\,n-k-1} distribution. For example, with q=3q = 3 and 60 degrees of freedom, the 5% critical value is 2.76.

其中 qq 是約束的數目(這裏是 3),n−k−1n - k - 1 來自無約束模型。FF 不會是負數,數值越大越是反對 H0H_0 的證據,所以當 F>cF > c 時拒絕,cc 是 Fq, n−k−1F_{q,\,n-k-1} 分佈的上 α\alpha 分位數。例如 q=3q = 3、自由度 60 時,5% 臨界值是 2.76。

When both models have the same dependent variable, the F statistic can also be written with R2R^2:

當兩個模型的被解釋變數相同時,F 統計量也可以用 R2R^2 表示:

F=(Rur2−Rr2)/q(1−Rur2)/(n−k−1).F = \frac{(R^2_{ur} - R^2_r)/q}{(1 - R^2_{ur})/(n - k - 1)}.
Show every step 顯示完整推導

From Week 3, R2=1−SSR/SSTR^2 = 1 - \text{SSR}/\text{SST}, so SSR=(1−R2) SST\text{SSR} = (1 - R^2)\,\text{SST}. Both models explain the same yy, so they share the same SST\text{SST}:

由第 3 週可知 R2=1−SSR/SSTR^2 = 1 - \text{SSR}/\text{SST},所以 SSR=(1−R2) SST\text{SSR} = (1 - R^2)\,\text{SST}。兩個模型解釋的是同一個 yy,所以 SST\text{SST} 相同:

F=[(1−Rr2)−(1−Rur2)] SST/q(1−Rur2) SST/(n−k−1)=(Rur2−Rr2)/q(1−Rur2)/(n−k−1).\begin{aligned} F &= \frac{\big[(1 - R^2_r) - (1 - R^2_{ur})\big]\,\text{SST}/q}{(1 - R^2_{ur})\,\text{SST}/(n-k-1)} \\ &= \frac{(R^2_{ur} - R^2_r)/q}{(1 - R^2_{ur})/(n-k-1)}. \end{aligned}

This fails if the restricted model has a different dependent variable, as it does when a restriction such as β1=1\beta_1 = 1 is imposed by moving x1x_1 to the left-hand side. Use the SSR form then.

如果約束模型的被解釋變數不同,這個公式便不成立。例如施加 β1=1\beta_1 = 1 時,要把 x1x_1 移到等號左邊。這時應使用 SSR 的公式。

Example. In the log earnings model, do experience and IQ matter at all, once education is included? Test H0:β2=β3=0H_0: \beta_2 = \beta_3 = 0, so q=2q = 2. The restricted model regresses log⁡(wage)\log(\text{wage}) on education alone.

例子。在對數收入模型中,加入教育之後,經驗和智商還有沒有作用?檢定 H0:β2=β3=0H_0: \beta_2 = \beta_3 = 0,所以 q=2q = 2。約束模型只把 log⁡(wage)\log(\text{wage}) 對教育做回歸。

UnrestrictedRestricted
Regressors 解釋變數educ, exper, IQeduc
SSR\text{SSR}138.78149.52
R2R^20.16220.0974
F=(149.52−138.78)/2138.78/931=5.370.149=36.02>3.005=c0.05.\begin{aligned} F &= \frac{(149.52 - 138.78)/2}{138.78/931} = \frac{5.37}{0.149} \\ &= 36.02 > 3.005 = c_{0.05}. \end{aligned}

Reject H0H_0: experience and IQ are jointly significant. The R2R^2 form gives the same answer, (0.1622−0.0974)/2÷(0.8378/931)=36.0(0.1622 - 0.0974)/2 \div (0.8378/931) = 36.0.

拒絕 H0H_0:經驗和智商聯合顯著。用 R2R^2 公式也得到同樣答案:(0.1622−0.0974)/2÷(0.8378/931)=36.0(0.1622 - 0.0974)/2 \div (0.8378/931) = 36.0。

Overall significance of a regression回歸的整體顯著性

One F test appears in every regression output. It tests whether any of the explanatory variables help explain yy:

每個回歸輸出都會報告一個 F 檢定,檢定是否有任何解釋變數有助解釋 yy:

H0:β1=β2=⋯=βk=0.H_0: \beta_1 = \beta_2 = \dots = \beta_k = 0.

The restricted model contains only an intercept, so its R2R^2 is zero, and q=kq = k:

約束模型只有截距,所以它的 R2R^2 為零,而且 q=kq = k:

F=R2/k(1−R2)/(n−k−1)∼Fk, n−k−1.F = \frac{R^2/k}{(1 - R^2)/(n - k - 1)} \sim F_{k,\, n-k-1}.

If this null cannot be rejected, the model explains nothing. For the wage regression on education and IQ, F=72.02F = 72.02 on 2 and 932 degrees of freedom; for the log earnings model, F=60.10F = 60.10 on 3 and 931. Both p-values are far below 0.001.

如果連這個原假設都無法拒絕,模型便甚麼也解釋不了。工資對教育和智商的回歸,F=72.02F = 72.02,自由度為 2 和 932;對數收入模型,F=60.10F = 60.10,自由度為 3 和 931。兩者的 p 值都遠低於 0.001。

Reproduce the results自己重現結果

Every number on this page comes from the code below and the free wooldridge data package.

本頁所有數字都來自以下程式碼和免費的 wooldridge 數據套件。

R
library(wooldridge)
data("wage2")

m1 <- lm(wage ~ educ + IQ, data = wage2)
summary(m1)                    # t statistics, p-values, overall F
confint(m1, level = 0.95)      # 95% confidence intervals
qt(c(0.95, 0.975), df = 932)   # critical values: 1.646, 1.963

# A single linear restriction: reparametrise
m2 <- lm(lwage ~ educ + I(educ + exper) + IQ, data = wage2)
summary(m2)                    # educ row: 0.0376, t = 5.59

# Joint test that exper and IQ both have no effect
ur <- lm(lwage ~ educ + exper + IQ, data = wage2)
r  <- lm(lwage ~ educ, data = wage2)
anova(r, ur)                   # F = 36.02
Python
# pip install wooldridge statsmodels
import statsmodels.formula.api as smf
import wooldridge as wd
from scipy import stats

df = wd.data("wage2")
m1 = smf.ols("wage ~ educ + IQ", data=df).fit()
print(m1.summary())                        # t statistics, p-values, overall F
print(m1.conf_int(alpha=0.05))             # 95% confidence intervals
print(stats.t.ppf([0.95, 0.975], 932))     # critical values: 1.646, 1.963

# A single linear restriction: reparametrise
df["educ_exper"] = df["educ"] + df["exper"]
m2 = smf.ols("lwage ~ educ + educ_exper + IQ", data=df).fit()
print(m2.params["educ"], m2.tvalues["educ"])   # 0.0376, 5.59

# Joint test that exper and IQ both have no effect
ur = smf.ols("lwage ~ educ + exper + IQ", data=df).fit()
print(ur.f_test("exper = 0, IQ = 0"))      # F = 36.02

Check your understanding自我測驗

  1. A regression has n=50n = 50 observations and 4 explanatory variables. How many degrees of freedom does the t statistic have?

    一個回歸有 n=50n = 50 個觀測值和 4 個解釋變數。t 統計量的自由度是多少?

    Answer 答案

    n−k−1=50−4−1=45n - k - 1 = 50 - 4 - 1 = 45. The 1 is for the intercept.

    n−k−1=50−4−1=45n - k - 1 = 50 - 4 - 1 = 45。減去的 1 對應截距。

  2. In the wage regression, test H0:β2=5H_0: \beta_2 = 5 for IQ against a two-sided alternative at the 5% level.

    在工資回歸中,以 5% 水平雙邊檢定智商係數 H0:β2=5H_0: \beta_2 = 5。

    Answer 答案

    t=(5.14−5)/0.96=0.14t = (5.14 - 5)/0.96 = 0.14, far below 1.963, so do not reject. The 95% interval for β2\beta_2, [3.26, 7.01], contains 5, which says the same thing.

    t=(5.14−5)/0.96=0.14t = (5.14 - 5)/0.96 = 0.14,遠低於 1.963,所以不拒絕。β2\beta_2 的 95% 置信區間 [3.26, 7.01] 包含 5,結論一致。

  3. Software reports a two-sided p-value of 0.08 for β^1=0.9\bh_1 = 0.9. What do you conclude at the 5% level against H1:β1>0H_1: \beta_1 > 0? And against H1:β1<0H_1: \beta_1 < 0?

    軟件報告 β^1=0.9\bh_1 = 0.9 的雙邊 p 值為 0.08。在 5% 水平下,對備擇假設 H1:β1>0H_1: \beta_1 > 0 結論如何?對 H1:β1<0H_1: \beta_1 < 0 又如何?

    Answer 答案

    Against β1>0\beta_1 > 0: the estimate has the predicted sign, so the one-sided p-value is 0.04 < 0.05; reject. Against β1<0\beta_1 < 0: the estimate points the other way, so the one-sided p-value is 0.96; do not reject.

    對 β1>0\beta_1 > 0:估計值符號與預期一致,單邊 p 值為 0.04 < 0.05,拒絕。對 β1<0\beta_1 < 0:估計值方向相反,單邊 p 值為 0.96,不拒絕。

  4. How would you reparametrise to test H0:β1+β2=1H_0: \beta_1 + \beta_2 = 1?

    要檢定 H0:β1+β2=1H_0: \beta_1 + \beta_2 = 1,應該怎樣重新參數化?

    Answer 答案

    Let θ=β1+β2−1\theta = \beta_1 + \beta_2 - 1, so β2=θ+1−β1\beta_2 = \theta + 1 - \beta_1. Substituting gives y−x2=β0+β1(x1−x2)+θ x2+⋯+uy - x_2 = \beta_0 + \beta_1 (x_1 - x_2) + \theta\, x_2 + \dots + u. Regress y−x2y - x_2 on x1−x2x_1 - x_2, x2x_2 and the other variables, then use the t test on x2x_2's coefficient.

    令 θ=β1+β2−1\theta = \beta_1 + \beta_2 - 1,即 β2=θ+1−β1\beta_2 = \theta + 1 - \beta_1。代入得 y−x2=β0+β1(x1−x2)+θ x2+⋯+uy - x_2 = \beta_0 + \beta_1 (x_1 - x_2) + \theta\, x_2 + \dots + u。把 y−x2y - x_2 對 x1−x2x_1 - x_2、x2x_2 及其他變數做回歸,再對 x2x_2 的係數做 t 檢定。

  5. A regression with k=3k = 3 and n=104n = 104 has R2=0.06R^2 = 0.06. Is the model jointly significant at the 5% level? The 5% critical value of F3,100F_{3,100} is 2.70.

    一個 k=3k = 3、n=104n = 104 的回歸,R2=0.06R^2 = 0.06。在 5% 水平下模型是否整體顯著?F3,100F_{3,100} 的 5% 臨界值是 2.70。

    Answer 答案

    F=(0.06/3) / (0.94/100)=2.13<2.70F = (0.06/3) \,/\, (0.94/100) = 2.13 < 2.70. Do not reject: we cannot rule out that none of the three variables helps explain yy.

    F=(0.06/3) / (0.94/100)=2.13<2.70F = (0.06/3) \,/\, (0.94/100) = 2.13 < 2.70。不拒絕:我們無法排除三個變數都對解釋 yy 沒有幫助的可能。

Sources and acknowledgement 資料來源與鳴謝

  • Lecture materials for Introductory Econometrics (ETC2410) by Associate Professor Didier Nibbering, Department of Econometrics and Business Statistics, Monash Business School.
  • Jeffrey M. Wooldridge, Introductory Econometrics: A Modern Approach, Chapter 4 and Appendix G.
  • Data: wage2, distributed with the textbook and in the wooldridge R package. All estimates on this page were computed from it.

Any errors are our own.