在前面的章節中,我們討論了兩種用於估計未知引數 的方法,即點估計 和區間估計 。估計未知引數是統計推斷中一個重要的領域,在本節中,我們將討論另一個重要領域,即假設檢驗 ,它與決策 有關。事實上,置信區間 和假設檢驗 的概念密切相關,正如我們將演示的那樣。
在討論如何進行 假設檢驗以及評估 假設檢驗的“好壞”之前,讓我們首先介紹一些與假設檢驗相關的基本概念和術語。
定義。 (假設)一個(統計)假設 是對總體引數的陳述。
有兩個術語用來對假設進行分類
定義。 (簡單和複合假設)如果一個假設完全指定 了總體的分佈(也就是說,該分佈是完全已知的,沒有任何未知引數參與),則它是簡單假設 ,否則它是複合假設 。
有時,是否一個假設是簡單還是複合並不立即清楚。為了更清楚地理解假設的分類,讓我們考慮以下示例。
在假設檢驗中,我們考慮兩個假設。
H 0 {\displaystyle H_{0}} 和 H 1 {\displaystyle H_{1}} 的一般形式是 H 0 : θ ∈ Θ 0 {\displaystyle H_{0}:\theta \in \Theta _{0}} 和 H 1 : θ ∈ Θ 1 {\displaystyle H_{1}:\theta \in \Theta _{1}} ,其中 Θ 1 = Θ 0 c {\displaystyle \Theta _{1}=\Theta _{0}^{c}} ,它是 Θ 0 {\displaystyle \Theta _{0}} 的補集 (相對於 Θ {\displaystyle \Theta } ),即 Θ 0 c = Θ ∖ Θ 0 {\displaystyle \Theta _{0}^{c}=\Theta \setminus \Theta _{0}} ( Θ {\displaystyle \Theta } 是引數空間,包含 θ {\displaystyle \theta } 的所有可能值)。選擇 Θ 0 {\displaystyle \Theta _{0}} 的補集在 H 1 {\displaystyle H_{1}} 中的原因是 H 1 {\displaystyle H_{1}} 是 H 0 {\displaystyle H_{0}} 的補充假設,如上述定義所示。
示例. 假設你的朋友給你一枚硬幣讓你拋,你不知道它是否是公平的。然而,由於這枚硬幣是由你的朋友給你的,你相信這枚硬幣是公平的,除非有充分的證據表明並非如此。在這個背景下,零假設和備擇假設是什麼(假設硬幣永遠不會立起來)?
解答 . 令 p {\displaystyle p} 為拋硬幣後正面朝上的機率。零假設是 H 0 : p = 1 2 {\displaystyle H_{0}:p={\frac {1}{2}}} 。備擇假設是 H 1 : p ≠ 1 2 {\displaystyle H_{1}:p\neq {\frac {1}{2}}} .
練習. 假設我們在上面的問題中將“硬幣”替換為“六面骰子”。零假設和備擇假設是什麼?(提示 : 你可以令 p 1 , p 2 , … , p 6 {\displaystyle p_{1},p_{2},\dotsc ,p_{6}} 分別表示“1”、“2”、“3”、“4”、“5”、“6” 在擲骰子後出現的機率)
解決方案
令 p 1 , p 2 , … , p 6 {\displaystyle p_{1},p_{2},\dotsc ,p_{6}} 分別表示“1”、“2”、“3”、“4”、“5”、“6” 在擲骰子後出現的機率。零假設是 H 0 : p 1 = p 2 = ⋯ = p 6 = 1 6 {\displaystyle H_{0}:p_{1}=p_{2}=\dotsb =p_{6}={\frac {1}{6}}} ,備擇假設是 H 1 : 至少有一個 p 1 , … , p 6 ≠ 1 6 {\displaystyle H_{1}:{\text{at least one of }}p_{1},\dotsc ,p_{6}\neq {\frac {1}{6}}} (事實上,當 p 1 , … , p 6 {\displaystyle p_{1},\dotsc ,p_{6}} 中的一個不等於 1 6 {\displaystyle {\frac {1}{6}}} 時,它必然會導致至少另一個機率不同於 1 6 {\displaystyle {\frac {1}{6}}} )。
我們已經提到,假設 H 0 {\displaystyle H_{0}} 和 H 1 {\displaystyle H_{1}} 之一為真。為了做出決定,我們需要 決定 哪個假設應該被認為是正確的。當然,正如你可能預料的那樣,這個決定並不完美,我們的決定會有一些錯誤。因此,我們不能說我們“證明”一個特定的假設是正確的(也就是說,我們不能 確定 一個特定的假設是正確的)。儘管如此,當我們有 足夠的證據 讓我們做出這個決定(理想情況下,錯誤很小 [ 2] )時,我們可以“認為”(或“接受”)一個特定的假設是正確的(但 不是 證明它是正確的)。
現在,我們面臨著兩個問題。首先,我們應該考慮哪些證據?其次,“足夠”是什麼意思?對於第一個問題,一個自然的答案是,我們應該考慮觀察到的樣本 ,對嗎?這是因為我們對總體進行假設,而樣本是從總體中抽取的,因此與總體密切相關,這應該有助於我們做出決定。
為了回答第二個問題,我們需要假設檢驗 的概念。特別是在假設檢驗中,我們將構建一個所謂的拒絕域 或臨界域 來幫助我們確定是否 應該拒絕零 假設(即,認為 H 0 {\displaystyle H_{0}} 為假),因此(自然地)認為 H 1 {\displaystyle H_{1}} 為真(“接受” H 1 {\displaystyle H_{1}} )(我們假設 H 0 {\displaystyle H_{0}} 和 H 1 {\displaystyle H_{1}} 中只有一個為真,因此當我們認為其中一個為假時,我們應該認為另一個為真)。特別地,當我們不 拒絕 H 0 {\displaystyle H_{0}} 時,我們將像 H 0 {\displaystyle H_{0}} 為真那樣行動,或者接受 H 0 {\displaystyle H_{0}} 為真(因此也應該拒絕 H 1 {\displaystyle H_{1}} ,因為 H 0 {\displaystyle H_{0}} 或 H 1 {\displaystyle H_{1}} 中只有一個為真)。
讓我們正式定義以下與假設檢驗相關的術語。
備註:
假設檢驗有時為了簡潔起見簡稱為“檢驗”。我們有時也使用希臘字母" φ {\displaystyle \varphi } "," ψ {\displaystyle \psi } ",等等來表示檢驗。
備註:
S
*------------*
|///|........|
|///\........|
|////\.......|
|/////\......|
*------------*
*--*
|//|: R
*--*
*--*
|..|: R^c
*--*
通常,我們使用 檢驗統計量 (用於進行假設檢驗的統計量)來指定拒絕域。例如,如果隨機樣本是 X 1 , … , X n {\displaystyle X_{1},\dotsc ,X_{n}} 且檢驗統計量是 X ¯ {\displaystyle {\overline {X}}} ,則拒絕域可能是,例如, R = { x : x ¯ < 2 } {\displaystyle R=\{\mathbf {x} :{\overline {x}}<2\}} (其中 x 1 , … , x n {\displaystyle x_{1},\dotsc ,x_{n}} 和 x ¯ {\displaystyle {\overline {x}}} 分別是 X 1 , … , X n {\displaystyle X_{1},\dotsc ,X_{n}} 和 X ¯ {\displaystyle {\overline {X}}} 的觀察值)。透過這種方式,我們可以直接構建假設檢驗:當 x ∈ R {\displaystyle \mathbf {x} \in R} 時,我們拒絕 H 0 {\displaystyle H_{0}} 並接受 H 1 {\displaystyle H_{1}} 。否則,如果 x ∈ R c {\displaystyle \mathbf {x} \in R^{c}} ,我們接受 H 0 {\displaystyle H_{0}} 。因此,一般來說,為了在假設檢驗中指定規則,我們只需要一個 拒絕域 。之後,我們將應用該檢驗來檢驗 H 0 {\displaystyle H_{0}} 相對於 H 1 {\displaystyle H_{1}} 。關於以這種方式構建的假設檢驗,有一些相關的術語
示例。 假設拒絕域為 R = { ( x 1 , x 2 , x 3 ) : x 1 + x 2 + x 3 > 6 } {\displaystyle R=\{(x_{1},x_{2},x_{3}):x_{1}+x_{2}+x_{3}>6\}} ,並且觀察到 x 1 = 1 , x 2 = 2 , x 3 = 3 {\displaystyle x_{1}=1,x_{2}=2,x_{3}=3} 。我們應該接受哪個假設, H 0 {\displaystyle H_{0}} 還是 H 1 {\displaystyle H_{1}} ?
解答 。由於 ( x 1 , x 2 , x 3 ) ∈ R c {\displaystyle (x_{1},x_{2},x_{3})\in R^{c}} ,我們應該(不拒絕並)接受 H 0 {\displaystyle H_{0}} 。
練習。 這種假設檢驗是什麼型別?
正如我們已經提到的,假設檢驗做出的決定不應該完美,並且會發生錯誤。事實上,當我們仔細思考時,實際上有兩種型別 的錯誤,如下所示
我們可以使用以下表格更清楚地說明這兩種型別的錯誤。
I 類和 II 類錯誤
接受 H 0 {\displaystyle H_{0}}
拒絕 H 0 {\displaystyle H_{0}}
H 0 {\displaystyle H_{0}} 為真
正確決策
I 類錯誤
H 0 {\displaystyle H_{0}} 為假
II 類錯誤
正確決策
我們可以表示 H 0 : θ ∈ Θ 0 {\displaystyle H_{0}:\theta \in \Theta _{0}} 和 H 1 : θ ∈ Θ 0 c {\displaystyle H_{1}:\theta \in \Theta _{0}^{c}} 。另外,假設拒絕域為 R = R ( X ) {\displaystyle R=R(\mathbf {X} )} (即,用 " X {\displaystyle X} " 替換 " x {\displaystyle x} " 的拒絕域)。通常,當 " R {\displaystyle R} " 與 " X {\displaystyle X} " 結合在一起時,我們假設 R = R ( X ) {\displaystyle R=R(\mathbf {X} )} 。
接下來,我們針對犯第一類和第二類錯誤的 機率 做一些符號和表示式說明:(假設 X 1 , … , X n {\displaystyle X_{1},\dotsc ,X_{n}} 是一個隨機樣本, X = ( X 1 , … , X n ) {\displaystyle \mathbf {X} =(X_{1},\dotsc ,X_{n})} )
犯第一類錯誤的機率,記作 α ( θ ) {\displaystyle \alpha (\theta )} ,當 θ ∈ Θ 0 {\displaystyle \theta \in \Theta _{0}} 時,為 P θ ( X ∈ R ) {\displaystyle \mathbb {P} _{\theta }(\mathbf {X} \in R)} 。
犯第二類錯誤的機率,記作 β ( θ ) {\displaystyle \beta (\theta )} ,當 θ ∈ Θ 0 c {\displaystyle \theta \in \Theta _{0}^{c}} 時,為 P θ ( X ∈ R c ) = 1 − P θ ( X ∈ R ) {\displaystyle \mathbb {P} _{\theta }(\mathbf {X} \in R^{c})=1-\mathbb {P} _{\theta }(\mathbf {X} \in R)} 。
請注意, α ( θ ) {\displaystyle \alpha (\theta )} 和 β ( θ ) {\displaystyle \beta (\theta )} 中有一個共同的表示式,即“ P θ ( ( X 1 , … , X n ) ∈ R ) {\displaystyle \mathbb {P} _{\theta }((X_{1},\dotsc ,X_{n})\in R)} ”。事實上,我們也可以將此表示式寫成 P θ ( ( X 1 , … , X n ) ∈ R ) = { α ( θ ) , θ ∈ Θ 0 ; 1 − β ( θ ) , θ ∈ Θ 0 c . {\displaystyle \mathbb {P} _{\theta }((X_{1},\dotsc ,X_{n})\in R)={\begin{cases}\alpha (\theta ),&\theta \in \Theta _{0};\\1-\beta (\theta ),&\theta \in \Theta _{0}^{c}.\end{cases}}} 透過此表示式,我們可以觀察到,它包含了所有關於錯誤機率的資訊,這些錯誤機率來自於一個具有拒絕域 R {\displaystyle R} 的假設檢驗。因此,我們將為它賦予一個特殊的名稱。
示例: 假設我們擲一枚(公平或不公平)硬幣 5 次(假設硬幣永遠不會側立),並且我們有以下假設: H 0 : p ≤ 1 2 vs. H 1 : p > 1 2 {\displaystyle H_{0}:p\leq {\frac {1}{2}}\quad {\text{vs.}}\quad H_{1}:p>{\frac {1}{2}}} 其中 p {\displaystyle p} 是擲硬幣後正面朝上的機率。令 X 1 , … , X 5 {\displaystyle X_{1},\dotsc ,X_{5}} 為 5 次擲硬幣的隨機樣本,並且 x 1 , … , x 5 {\displaystyle x_{1},\dotsc ,x_{5}} 是相應的實現。此外,隨機樣本的值為 1(如果出現正面),否則為 0。假設我們將在所有 5 次擲硬幣中都出現正面時拒絕 H 0 {\displaystyle H_{0}} 。
(a) 確定拒絕區域 R {\displaystyle R} 。
(b) 功率函式是什麼 π ( p ) {\displaystyle \pi (p)} (用 p {\displaystyle p} 表示)?
(c) 計算 α ( 1 / 2 ) {\displaystyle \alpha (1/2)} 和 β ( 2 / 3 ) {\displaystyle \beta (2/3)} 。
解決方案 .
(a) 拒絕區域 R = { ( x 1 , … , x 5 ) : x 1 + ⋯ + x 5 = 5 } {\displaystyle R=\{(x_{1},\dotsc ,x_{5}):x_{1}+\dotsb +x_{5}=5\}} 。
(b) 功率函式為 π ( p ) = { P θ ( ( X 1 , … , X 5 ) ∈ R ) = p 5 , p ≤ 1 2 ; 1 − P θ ( ( X 1 , … , X 5 ) ∈ R ) = 1 − p 5 , p > 1 2 . {\displaystyle \pi (p)={\begin{cases}\mathbb {P} _{\theta }((X_{1},\dotsc ,X_{5})\in R)=p^{5},&p\leq {\frac {1}{2}};\\1-\mathbb {P} _{\theta }((X_{1},\dotsc ,X_{5})\in R)=1-p^{5},&p>{\frac {1}{2}}.\end{cases}}}
(c) 我們有 α ( 1 / 2 ) = ( 1 2 ) 5 = 0.03125 {\displaystyle \alpha (1/2)=\left({\frac {1}{2}}\right)^{5}=0.03125} 以及 β ( 2 / 3 ) = 1 − ( 2 3 ) 5 ≈ 0.8683 {\displaystyle \beta (2/3)=1-\left({\frac {2}{3}}\right)^{5}\approx 0.8683} 。(注意,雖然 I 類錯誤的機率可能很低,但 II 類錯誤的機率可能很高。這是因為,直觀地,拒絕 H 0 {\displaystyle H_{0}} 是“困難”的,因為要求很嚴格。所以,即使 H 0 {\displaystyle H_{0}} 是假的,它可能不被拒絕,從而導致 II 類錯誤。)
示例。 假設 X 1 , … , X n {\displaystyle X_{1},\dotsc ,X_{n}} 是來自正態分佈 N ( μ , σ 2 ) {\displaystyle {\mathcal {N}}(\mu ,\sigma ^{2})} 的隨機樣本,其中 σ 2 {\displaystyle \sigma ^{2}} 已知。考慮以下假設: H 0 : μ ≤ μ 0 vs. μ > μ 0 {\displaystyle H_{0}:\mu \leq \mu _{0}\quad {\text{vs.}}\quad \mu >\mu _{0}} 其中 μ 0 {\displaystyle \mu _{0}} 是一個常數。我們使用檢驗統計量 T = X ¯ − μ 0 σ / n ∼ N ( 0 , 1 ) {\displaystyle T={\frac {{\overline {X}}-\mu _{0}}{\sigma /{\sqrt {n}}}}\sim {\mathcal {N}}(0,1)} 進行假設檢驗,當且僅當 T ≥ k {\displaystyle T\geq k} 時,我們拒絕 H 0 {\displaystyle H_{0}} 。
求功效函式 π ( μ ) {\displaystyle \pi (\mu )} , lim μ → − ∞ π ( μ ) {\displaystyle \lim _{\mu \to -\infty }\pi (\mu )} 和 lim μ → ∞ π ( μ ) {\displaystyle \lim _{\mu \to \infty }\pi (\mu )} 。
解決方案 。 冪函式是 π ( μ ) = P μ ( T ≥ k ) = P μ ( X ¯ − μ 0 σ / n ≥ k ) = P μ ( X ¯ − μ + μ − μ 0 σ / n ≥ k ) = P μ ( X ¯ − μ σ / n ≥ k + μ 0 − μ σ / n ) = P ( Z ≥ k + μ 0 − μ σ / n ) . ( Z ∼ N ( 0 , 1 ) , which is independent from μ , so we can drop the subscript ` μ ' for P ) {\displaystyle {\begin{aligned}\pi (\mu )&=\mathbb {P} _{\mu }(T\geq k)\\&=\mathbb {P} _{\mu }\left({\frac {{\overline {X}}-\mu _{0}}{\sigma /{\sqrt {n}}}}\geq k\right)\\&=\mathbb {P} _{\mu }\left({\frac {{\overline {X}}-\mu +\mu -\mu _{0}}{\sigma /{\sqrt {n}}}}\geq k\right)\\&=\mathbb {P} _{\mu }\left({\frac {{\overline {X}}-\mu }{\sigma /{\sqrt {n}}}}\geq k+{\frac {\mu _{0}-\mu }{\sigma /{\sqrt {n}}}}\right)\\&=\mathbb {P} \left(Z\geq k+{\frac {\mu _{0}-\mu }{\sigma /{\sqrt {n}}}}\right).&(Z\sim {\mathcal {N}}(0,1),{\text{ which is independent from }}\mu ,{\text{so we can drop the subscript `}}\mu {\text{' for }}\mathbb {P} )\\\end{aligned}}} 因此, lim μ → − ∞ π ( μ ) = P ( Z ≥ ∞ ) = 0 {\displaystyle \lim _{\mu \to -\infty }\pi (\mu )=\mathbb {P} (Z\geq \infty )=0} 並且 lim μ → ∞ π ( μ ) = P ( Z ≥ − ∞ ) = 1 {\displaystyle \lim _{\mu \to \infty }\pi (\mu )=\mathbb {P} (Z\geq -\infty )=1} (一些符號上的濫用),根據累積分佈函式的定義。(事實上, π ( μ ) {\displaystyle \pi (\mu )} 是 μ {\displaystyle \mu } 的嚴格遞增函式。)
練習。 證明如果 P ( Z ≥ k ) = α {\displaystyle \mathbb {P} (Z\geq k)=\alpha } ,則 π ( μ 0 ) = α {\displaystyle \pi (\mu _{0})=\alpha } 。
解決方案
證明。 假設 P ( Z ≥ k ) = α {\displaystyle \mathbb {P} (Z\geq k)=\alpha } 。 那麼, π ( μ 0 ) = P ( Z ≥ k + 0 ) = P ( Z ≥ k ) = α {\displaystyle \pi (\mu _{0})=\mathbb {P} (Z\geq k+0)=\mathbb {P} (Z\geq k)=\alpha } 。
◻ {\displaystyle \Box }
理想情況下,我們希望將 α ( θ ) {\displaystyle \alpha (\theta )} 和 β ( θ ) {\displaystyle \beta (\theta )} 都降到任意小。但這通常是不可能的。為了理解這一點,我們可以考慮以下極端例子。
將拒絕域 R {\displaystyle R} 設定為 S = { x } {\displaystyle S=\{\mathbf {x} \}} ,即所有可能的隨機樣本觀測值的集合。那麼,對於每個 θ ∈ Θ {\displaystyle \theta \in \Theta } ,都有 π ( θ ) = 1 {\displaystyle \pi (\theta )=1} 。由此,當然我們有 β ( θ ) = 0 {\displaystyle \beta (\theta )=0} ,這是很好的。但嚴重的問題是,由於盲目拒絕, α ( θ ) = 1 {\displaystyle \alpha (\theta )=1} 。
另一個極端情況是將拒絕域 R {\displaystyle R} 設定為空集 ∅ {\displaystyle \varnothing } 。那麼,對於每個 θ ∈ Θ {\displaystyle \theta \in \Theta } ,都有 π ( θ ) = 0 {\displaystyle \pi (\theta )=0} 。由此,我們有 α ( θ ) = 0 {\displaystyle \alpha (\theta )=0} ,這是很好的。但是,再次,嚴重的問題是,由於盲目接受, β ( θ ) = 1 {\displaystyle \beta (\theta )=1} 。
我們可以觀察到,為了使 α ( θ ) {\displaystyle \alpha (\theta )} ( β ( θ ) {\displaystyle \beta (\theta )} )非常小,不可避免地, β ( θ ) {\displaystyle \beta (\theta )} ( α ( θ ) {\displaystyle \alpha (\theta )} )將隨之增加,這是因為“接受”(拒絕)了“太多”。因此,我們只能嘗試最小化犯一種型別錯誤的機率,同時將犯另一種型別錯誤的機率控制 在一定範圍內。
現在,我們感興趣的是瞭解應該控制哪種型別的錯誤。為了激發這種選擇,我們可以再次考慮無罪推定法律原則的類比。在這種情況下,I 類錯誤意味著將無辜者判為有罪,而 II 類錯誤意味著赦免有罪者。然後,正如 布萊克斯通比率 所建議的那樣,I 類錯誤比 II 類錯誤更嚴重,也更重要。這促使我們控制 I 類錯誤的機率,即 α ( θ ) {\displaystyle \alpha (\theta )} ,在指定的小值 α ∗ {\displaystyle \alpha ^{*}} 處,以便我們可以控制犯這種更嚴重錯誤的機率。在那之後,我們考慮“在該水平上控制 I 類錯誤機率”的檢驗,其中具有最小 β ( θ ) {\displaystyle \beta (\theta )} 的檢驗是“最佳”檢驗(從犯錯機率的角度來看)。
為了更精確地描述“在該水平上控制 I 類錯誤機率”,讓我們定義以下術語。
因此,根據這個定義,將 I 類錯誤機率控制在特定水平 α {\displaystyle \alpha } 意味著檢驗的功效不應超過 α {\displaystyle \alpha } ,即 sup θ ∈ Θ 0 π ( θ ) ≤ α {\displaystyle \sup _{\theta \in \Theta _{0}}\pi (\theta )\leq \alpha } (在其他一些地方,這種檢驗被稱為 水平 α {\displaystyle \alpha } 檢驗 。)
例: 考慮正態分佈 N ( μ , 1 ) {\displaystyle {\mathcal {N}}(\mu ,1)} (引數空間為: Θ = { μ : μ = 20 or 21 } {\displaystyle \Theta =\{\mu :\mu =20{\text{ or }}21\}} ),以及假設 H 0 : μ = 20 vs. H 1 : μ = 21 {\displaystyle H_{0}:\mu =20\quad {\text{vs.}}\quad H_{1}:\mu =21} 。令 X 1 , … , X 10 {\displaystyle X_{1},\dotsc ,X_{10}} 為來自正態分佈 N ( μ , 1 ) {\displaystyle {\mathcal {N}}(\mu ,1)} 的隨機樣本,相應的實現值為 x 1 , … , x 10 {\displaystyle x_{1},\dotsc ,x_{10}} 。假設拒絕域為 { ( x 1 , … , x 10 ) : x ¯ ≥ k } {\displaystyle \{(x_{1},\dotsc ,x_{10}):{\overline {x}}\geq k\}} .
(a) 求 k {\displaystyle k} 使得檢驗的顯著性水平為 α = 0.05 {\displaystyle \alpha =0.05} .
(b) 計算第二類錯誤機率 β {\displaystyle \beta } 。要使第二類錯誤機率 β ≤ 0.05 {\displaystyle \beta \leq 0.05} ,最小樣本量是多少(使用相同的拒絕域)?
解決方案 .
(a) 為了使顯著性水平為0.05,我們需要滿足 sup μ ∈ Θ 0 π ( μ ) = 0.05. {\displaystyle \sup _{\mu \in \Theta _{0}}\pi (\mu )=0.05.} 但 Θ 0 = { 20 } {\displaystyle \Theta _{0}=\{20\}} 。因此,這意味著 0.05 = π ( 20 ) = P μ = 20 ( X ¯ ≥ k ) = P ( X ¯ − 20 1 / 10 ≥ k − 20 1 / 10 ) = P ( Z ≥ 10 ( k − 20 ) ) {\displaystyle 0.05=\pi (20)=\mathbb {P} _{\mu =20}({\overline {X}}\geq k)=\mathbb {P} \left({\frac {{\overline {X}}-20}{1/{\sqrt {10}}}}\geq {\frac {k-20}{1/{\sqrt {10}}}}\right)=\mathbb {P} (Z\geq {\sqrt {10}}(k-20))} 其中 Z ∼ N ( 0 , 1 ) {\displaystyle Z\sim {\mathcal {N}}(0,1)} 。然後我們有 10 ( k − 20 ) = z 0.05 ≈ 1.64 ⟹ k ≈ 20.51861. {\displaystyle {\sqrt {10}}(k-20)=z_{0.05}\approx 1.64\implies k\approx 20.51861.}
(b) II 類錯誤機率為 β ≈ 1 − P μ = 21 ( X ¯ ≥ 20.51861 ) = 1 − P ( X ¯ − 21 1 / 10 ≥ 20.51861 − 21 1 / 10 ) ≈ 1 − P ( Z ≥ − 1.522 ) = P ( Z < − 1.522 ) ≈ 0.06426. {\displaystyle \beta \approx 1-\mathbb {P} _{\mu =21}({\overline {X}}\geq 20.51861)=1-\mathbb {P} \left({\frac {{\overline {X}}-21}{1/{\sqrt {10}}}}\geq {\frac {20.51861-21}{1/{\sqrt {10}}}}\right)\approx 1-\mathbb {P} (Z\geq -1.522)=\mathbb {P} (Z<-1.522)\approx 0.06426.} ( Z ∼ N ( 0 , 1 ) {\displaystyle Z\sim {\mathcal {N}}(0,1)} ) 樣本量為 n {\displaystyle n} 時,II 類錯誤機率為 β ≈ P ( Z < n ( 20.51861 − 21 ) ) {\displaystyle \beta \approx \mathbb {P} \left(Z<{\sqrt {n}}(20.51861-21)\right)} 當樣本量 n {\displaystyle n} 增加時, n ( 20.51861 − 21 ) {\displaystyle {\sqrt {n}}(20.51861-21)} 將變得更負,因此 II 類錯誤機率會降低。因此, P ( Z < n ∗ ( 20.51861 − 21 ) ≤ 0.05 ⟹ n ( 20.51861 − 21 ) ≥ − 1.64 ⟹ n ≥ 11.603. {\displaystyle \mathbb {P} (Z<{\sqrt {n^{*}}}(20.51861-21)\leq 0.05\implies {\sqrt {n}}(20.51861-21)\geq -1.64\implies n\geq 11.603.} 因此,最小樣本量為 12。
練習。 當樣本量為 12 時(拒絕域保持不變),計算 I 類錯誤機率和 II 類錯誤機率。
解決方案
II 類錯誤機率為 P ( Z < 12 ( 20.51861 − 21 ) ) ≈ P ( Z < − 1.668 ) ≈ 0.04746. {\displaystyle \mathbb {P} (Z<{\sqrt {12}}(20.51861-21))\approx \mathbb {P} (Z<-1.668)\approx 0.04746.} I 類錯誤機率為 P ( Z ≥ 12 ( 20.51861 − 20 ) ) ≈ P ( Z ≥ 1.797 ) ≈ 0.0359. {\displaystyle \mathbb {P} (Z\geq {\sqrt {12}}(20.51861-20))\approx \mathbb {P} (Z\geq 1.797)\approx 0.0359.} 因此,在相同拒絕域和不同樣本量的情況下,檢驗的顯著性水平(在本例中為 I 類錯誤機率)發生了變化。
到目前為止,我們一直專注於使用 拒絕域 來進行假設檢驗。但這並不是唯一的方法。另外,我們可以使用 p {\displaystyle p} -值。
下面的定理允許我們使用 p {\displaystyle p} -值進行假設檢驗。
Proof. (Partial) We can prove "if" and "only if" directions at once. Let us first consider the case 1 in the definition of p {\displaystyle p} -value. By definitions, p {\displaystyle p} -value is sup θ ∈ Θ 0 P θ ( T ( X ) ≤ T ∗ ( x ) ) {\displaystyle \sup _{\theta \in \Theta _{0}}\mathbb {P} _{\theta }(T(\mathbf {X} )\leq T^{*}(\mathbf {x} ))} and α = sup θ ∈ Θ 0 π ( θ ) = sup θ ∈ Θ 0 P θ ( T ( X ) ≤ T ∗ ( x ) ) {\displaystyle \alpha =\sup _{\theta \in \Theta _{0}}\pi (\theta )=\sup _{\theta \in \Theta _{0}}\mathbb {P} _{\theta }(T(\mathbf {X} )\leq T^{*}(\mathbf {x} ))} (Define T ∗ ( X ) {\displaystyle T^{*}(\mathbf {X} )} such that T ( X ) ≤ T ∗ ( x ) ⟺ ( X 1 , … , X n ) ∈ R {\displaystyle T(\mathbf {X} )\leq T^{*}(\mathbf {x} )\iff (X_{1},\dotsc ,X_{n})\in R} .). Then, we have p -value ≤ α ⟺ sup θ ∈ Θ 0 P θ ( T ( X ) ≤ T ( x ) ) ≤ sup θ ∈ Θ 0 P θ ( T ( X ) ≤ T ∗ ( x ) ) ⟺ T ( x ) ≤ T ∗ ( x ) ( by some omitted arguments and the monotonicity of cdf ) ⟺ ( x 1 , … , x n ) ∈ { ( y 1 , … , y n ) : T ( y 1 , … , y n ) ≤ T ∗ ( x ) } ( x 1 , … , x n are realizations of X 1 , … , X n respectively ) ⟺ ( x 1 , … , x n ) ∈ R ( defined above ) ⟺ H 0 is rejected at significance level α . ( the test with power function π ( θ ) is size α test ) {\displaystyle {\begin{aligned}p{\text{-value}}\leq \alpha &\iff \sup _{\theta \in \Theta _{0}}\mathbb {P} _{\theta }(T(\mathbf {X} )\leq T(\mathbf {x} ))\leq \sup _{\theta \in \Theta _{0}}\mathbb {P} _{\theta }(T(\mathbf {X} )\leq T^{*}(\mathbf {x} ))\\&\iff T(\mathbf {x} )\leq T^{*}(\mathbf {x} )&({\text{by some omitted arguments and the monotonicity of cdf}})\\&\iff (x_{1},\dotsc ,x_{n})\in \{(y_{1},\dotsc ,y_{n}):T(y_{1},\dotsc ,y_{n})\leq T^{*}(\mathbf {x} )\}&(x_{1},\dotsc ,x_{n}{\text{ are realizations of }}X_{1},\dotsc ,X_{n}{\text{ respectively}})\\&\iff (x_{1},\dotsc ,x_{n})\in R&({\text{defined above}})\\&\iff H_{0}{\text{ is rejected at significance level }}\alpha .&({\text{the test with power function }}\pi (\theta ){\text{ is size }}\alpha {\text{ test}})\end{aligned}}} For other cases, the idea is similar (just the directions of inequalities for T {\displaystyle T} are different).
◻ {\displaystyle \Box }
示例。 回想之前示例的設定:考慮正態分佈 N ( μ , 1 ) {\displaystyle {\mathcal {N}}(\mu ,1)} ( μ {\displaystyle \mu } 的引數空間為: Θ = { 20 , 21 } {\displaystyle \Theta =\{20,21\}} ),以及假設 H 0 : μ = 20 vs. H 1 : μ = 21 {\displaystyle H_{0}:\mu =20\quad {\text{vs.}}\quad H_{1}:\mu =21} 令 X 1 , … , X 10 {\displaystyle X_{1},\dotsc ,X_{10}} 是來自正態分佈 N ( μ , 1 ) {\displaystyle {\mathcal {N}}(\mu ,1)} 的隨機樣本,對應的實現為 x 1 , … , x 10 {\displaystyle x_{1},\dotsc ,x_{10}} .
在顯著性水平 α = 0.05 {\displaystyle \alpha =0.05} 下,我們已經確定拒絕域為 R = { ( y 1 , … , y 10 ) : y ¯ ≥ 20.51861 } {\displaystyle R=\{(y_{1},\dotsc ,y_{10}):{\overline {y}}\geq 20.51861\}} 。假設觀察到 x ¯ = 20.5 {\displaystyle {\overline {x}}=20.5} .
(a) 使用拒絕域來確定我們是否應該拒絕 H 0 {\displaystyle H_{0}} 。
(b) 使用 p {\displaystyle p} 值來確定我們是否應該拒絕 H 0 {\displaystyle H_{0}} 。
解決方案 .
(a) 由於 x ¯ = 20.5 < 20.51861 {\displaystyle {\overline {x}}=20.5<20.51861} ,我們有 ( x 1 , … , x 10 ) ∈ R c {\displaystyle (x_{1},\dotsc ,x_{10})\in R^{c}} 。因此,我們不應該拒絕 H 0 {\displaystyle H_{0}} 。
(b) 由於檢驗是右尾檢驗, p {\displaystyle p} -值是 sup μ ∈ { 20 } P μ ( X ¯ ≥ x ¯ ) = P μ = 20 ( X ¯ ≥ 20.5 ) = P ( X ¯ − 20 1 / 10 ≥ 20.5 − 20 1 / 10 ) ≈ P ( Z ≥ 1.581 ) ≈ 0.05705 > α = 0.05 {\displaystyle \sup _{\mu \in \{20\}}\mathbb {P} _{\mu }({\overline {X}}\geq {\overline {x}})=\mathbb {P} _{\mu =20}({\overline {X}}\geq 20.5)=\mathbb {P} \left({\frac {{\overline {X}}-20}{1/{\sqrt {10}}}}\geq {\frac {20.5-20}{1/{\sqrt {10}}}}\right)\approx \mathbb {P} (Z\geq 1.581)\approx 0.05705>\alpha =0.05} ,其中 Z ∼ N ( 0 , 1 ) {\displaystyle Z\sim {\mathcal {N}}(0,1)} 。因此, H 0 {\displaystyle H_{0}} 不應該被拒絕。
練習。
在討論了一些基本概念和術語之後,我們現在來研究一些評估假設檢驗好壞的方法。正如我們之前提到的,我們希望犯 I 類錯誤和 II 類錯誤的機率都很小,但我們已經提到,通常不可能使這兩個機率都任意小。因此,我們建議控制 I 類錯誤,使用檢驗的規模,並且“最佳”檢驗應該是控制 I 類錯誤後,具有最小犯 II 類錯誤機率的檢驗。
這些想法導致了以下定義。
使用這個定義,與其說“最佳”檢驗(具有最小 II 類錯誤機率的檢驗),不如說“具有最大功效的檢驗”,換句話說,就是“最強大的檢驗”。
構建假設檢驗的方法很多,但當然並非所有方法都是好的(即“強大”的)。在下文中,我們將提供一些構建假設檢驗的常用方法。特別是,以下引理對於構建大小為 α {\displaystyle \alpha } 的 MP 檢驗非常有用。
引理。 (奈曼-皮爾遜引理)令 X 1 , … , X n {\displaystyle X_{1},\dotsc ,X_{n}} 是來自具有機率密度函式或機率質量函式 f ( x ; θ ) {\displaystyle f(x;\theta )} ( θ {\displaystyle \theta } 可以是一個引數向量,引數空間為 Θ = { θ 0 , θ 1 } {\displaystyle \Theta =\{\theta _{0},\theta _{1}\}} )的隨機樣本。令 L ( ⋅ ) {\displaystyle {\mathcal {L}}(\cdot )} 為似然函式。則檢驗 φ {\displaystyle \varphi } 具有拒絕域 R = { ( x 1 , … , x n ) : L ( θ 0 ; x ) L ( θ 1 ; x ) ≤ k } {\displaystyle R=\left\{(x_{1},\dotsc ,x_{n}):{\frac {{\mathcal {L}}(\theta _{0};\mathbf {x} )}{{\mathcal {L}}(\theta _{1};\mathbf {x} )}}\leq k\right\}} 和大小 α {\displaystyle \alpha } 是用於檢驗 H 0 : θ = θ 0 vs. H 1 : θ = θ 1 {\displaystyle H_{0}:\theta =\theta _{0}\quad {\text{vs.}}\quad H_{1}:\theta =\theta _{1}} 的最優檢驗,其中 k {\displaystyle k} 是由大小 α {\displaystyle \alpha } 決定的值。
證明。 讓我們首先考慮基礎分佈是連續的情況。 假設 φ {\displaystyle \varphi } 的大小為 α {\displaystyle \alpha } ,作為 UMP 檢驗的“大小”要求立即得到滿足。因此,只需證明 φ {\displaystyle \varphi } 滿足作為 MP 檢驗的“UMP”要求。
請注意,在這種情況下,“ Θ 1 {\displaystyle \Theta _{1}} ” 只是 { θ 1 } {\displaystyle \{\theta _{1}\}} 。因此,對於每個具有拒絕區域 R ∗ ≠ R {\displaystyle R^{*}\neq R} 且 π ψ ( θ 0 ) ≤ α {\displaystyle {\color {purple}\pi _{\psi }(\theta _{0})\leq \alpha }} 的檢驗 ψ {\displaystyle \psi } ,我們將證明 π φ ( θ 1 ) ≥ π ψ ( θ 1 ) {\displaystyle \pi _{\varphi }(\theta _{1})\geq \pi _{\psi }(\theta _{1})} 。
Since π φ ( θ 1 ) − π ψ ( θ 1 ) = P θ 1 ( ( X 1 , … , X n ) ∈ R ) − P θ 1 ( ( X 1 , … , X n ) ∈ R ∗ ) = ∫ ⋯ ∫ R L ( θ 1 ; x ) d x n ⋯ d x 1 − ∫ ⋯ ∫ R ∗ L ( θ 1 ; x ) d x n ⋯ d x 1 = ∫ ⋯ ∫ R L ( θ 1 ; x ) d x n ⋯ d x 1 − ∫ ⋯ ∫ R ∩ R ∗ L ( θ 1 ; x ) d x n ⋯ d x 1 − ( ∫ ⋯ ∫ R ∗ L ( θ 1 ; x ) d x n ⋯ d x 1 − ∫ ⋯ ∫ R ∩ R ∗ L ( θ 1 ; x ) d x n ⋯ d x 1 ) = ∫ ⋯ ∫ R ∖ R ∗ L ( θ 1 ; x ) d x n ⋯ d x 1 − ∫ ⋯ ∫ R ∗ ∖ R L ( θ 1 ; x ) d x n ⋯ d x 1 ≥ 1 k ∫ ⋯ ∫ R ∖ R ∗ L ( θ 0 ; x ) d x n ⋯ d x 1 − 1 k ∫ ⋯ ∫ R ∗ ∖ R L ( θ 0 ; x ) d x n ⋯ d x 1 ( In R , L ( θ 1 ; x ) ≥ 1 k L ( θ 0 ; x ) . In R c , L ( θ 1 ; x ) < 1 k L ( θ 0 ; x ) ⟺ − L ( θ 1 ; x ) > − 1 k L ( θ 0 ; x ) ) = 1 k ∫ ⋯ ∫ R ∖ R ∗ L ( θ 0 ; x ) d x n ⋯ d x 1 + 1 k ∫ ⋯ ∫ R ∩ R ∗ L ( θ 0 ; x ) d x n ⋯ d x 1 − ( 1 k ∫ ⋯ ∫ R ∗ ∖ R L ( θ 0 ; x ) d x n ⋯ d x 1 + 1 k ∫ ⋯ ∫ R ∩ R ∗ L ( θ 0 ; x ) d x n ⋯ d x 1 ) = 1 k ∫ ⋯ ∫ R L ( θ 0 ; x ) d x n ⋯ d x 1 − 1 k ∫ ⋯ ∫ R ∗ L ( θ 0 ; x ) d x n ⋯ d x 1 = 1 k ( P θ 0 ( ( X 1 , … , X n ) ∈ R ) ⏟ = α − P θ 0 ( ( X 1 , … , X n ) ∈ R ∗ ) ⏟ ≤ α ) ≥ 1 k ( α − α ) = 0 , {\displaystyle {\begin{aligned}\pi _{\varphi }(\theta _{1})-\pi _{\psi }(\theta _{1})&=\mathbb {P} _{\theta _{1}}((X_{1},\dotsc ,X_{n})\in R)-\mathbb {P} _{\theta _{1}}((X_{1},\dotsc ,X_{n})\in R^{*})\\&=\int \dotsi \int _{R}^{}{\mathcal {L}}(\theta _{1};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}-\int \dotsi \int _{R^{*}}^{}{\mathcal {L}}(\theta _{1};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}\\&={\color {blue}\int \dotsi \int _{R}^{}{\mathcal {L}}(\theta _{1};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}-\int \dotsi \int _{R\cap R^{*}}^{}{\mathcal {L}}(\theta _{1};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}}-\left({\color {red}\int \dotsi \int _{R^{*}}^{}{\mathcal {L}}(\theta _{1};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}-\int \dotsi \int _{R\cap R^{*}}^{}{\mathcal {L}}(\theta _{1};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}}\right)\\&={\color {blue}\int \dotsi \int _{R\setminus R^{*}}^{}{\mathcal {L}}(\theta _{1};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}}-{\color {red}\int \dotsi \int _{R^{*}\setminus R}^{}{\mathcal {L}}(\theta _{1};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}}\\&\geq {\color {blue}{\frac {1}{k}}}\int \dotsi \int _{R\setminus R^{*}}^{}{\color {blue}{\mathcal {L}}(\theta _{0};\mathbf {x} )}\,dx_{n}\cdots \,dx_{1}-{\color {red}{\frac {1}{k}}}\int \dotsi \int _{R^{*}\setminus R}^{}{\color {red}{\mathcal {L}}(\theta _{0};\mathbf {x} )}\,dx_{n}\cdots \,dx_{1}\qquad ({\text{In }}R,{\color {blue}{\mathcal {L}}(\theta _{1};\mathbf {x} )\geq {\frac {1}{k}}{\mathcal {L}}(\theta _{0};\mathbf {x} )}.{\text{ In }}R^{c},{\mathcal {L}}(\theta _{1};\mathbf {x} )<{\frac {1}{k}}{\mathcal {L}}(\theta _{0};\mathbf {x} )\iff {\color {red}-{\mathcal {L}}(\theta _{1};\mathbf {x} )>-{\frac {1}{k}}{\mathcal {L}}(\theta _{0};\mathbf {x} )})\\&={\frac {1}{k}}\int \dotsi \int _{R\setminus R^{*}}^{}{\mathcal {L}}(\theta _{0};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}+{\frac {1}{k}}\int \dotsi \int _{R\cap R^{*}}^{}{\mathcal {L}}(\theta _{0};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}-\left({\frac {1}{k}}\int \dotsi \int _{R^{*}\setminus R}^{}{\mathcal {L}}(\theta _{0};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}+{\frac {1}{k}}\int \dotsi \int _{R\cap R^{*}}^{}{\mathcal {L}}(\theta _{0};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}\right)\\&={\frac {1}{k}}\int \dotsi \int _{R}^{}{\mathcal {L}}(\theta _{0};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}-{\frac {1}{k}}\int \dotsi \int _{R^{*}}^{}{\mathcal {L}}(\theta _{0};\mathbf {x} )\,dx_{n}\cdots \,dx_{1}\\&={\frac {1}{k}}{\bigg (}{\color {brown}\underbrace {\mathbb {P} _{\theta _{0}}((X_{1},\dotsc ,X_{n})\in R)} _{=\alpha }}-{\color {purple}\underbrace {\mathbb {P} _{\theta _{0}}((X_{1},\dotsc ,X_{n})\in R^{*})} _{\leq \alpha }}{\bigg )}\\&\geq {\frac {1}{k}}(\alpha -\alpha )=0,\end{aligned}}} we have π ϕ ( θ 1 ) ≥ π ψ ( θ 1 ) {\displaystyle \pi _{\phi }(\theta _{1})\geq \pi _{\psi }(\theta _{1})} as desired.
對於底層分佈為離散的情況,證明非常類似(只需將積分替換為求和),因此省略。
◻ {\displaystyle \Box }
即使奈曼-皮爾遜引理中涉及的假設很簡單,在一些條件下,我們可以使用該引理來構造一個UMP檢驗,以檢驗複合 零假設與複合 備擇假設。具體細節如下:為了檢驗 H 0 : θ ≤ θ 0 vs. H 1 : θ > θ 0 {\displaystyle H_{0}:\theta \leq \theta _{0}\quad {\text{vs.}}\quad H_{1}:\theta >\theta _{0}}
找到一個MP檢驗 φ {\displaystyle \varphi } ,其大小為 α {\displaystyle \alpha } ,用於檢驗 H 0 : θ = θ 0 vs. H 1 : θ = θ 1 > θ 0 {\displaystyle H_{0}:\theta =\theta _{0}\quad {\text{vs.}}\quad H_{1}:\theta =\theta _{1}>\theta _{0}} ,使用奈曼-皮爾遜引理,其中 θ 1 {\displaystyle \theta _{1}} 是任意值,使得 θ 1 > θ 0 {\displaystyle \theta _{1}>\theta _{0}} 。
如果拒絕域 R {\displaystyle R} 不依賴於 θ 1 {\displaystyle \theta _{1}} ,那麼檢驗 φ {\displaystyle \varphi } 對每個 θ ∈ Θ 1 = { ϑ : ϑ > θ 0 } {\displaystyle \theta \in \Theta _{1}=\{\vartheta :\vartheta >\theta _{0}\}} 都有最大的功效。因此,檢驗 φ {\displaystyle \varphi } 是一個大小為 α {\displaystyle \alpha } 的UMP檢驗,用於檢驗 H 0 : θ = θ 0 vs. H 1 : θ > θ 0 {\displaystyle H_{0}:\theta =\theta _{0}\quad {\text{vs.}}\quad H_{1}:\theta >\theta _{0}}
如果我們能進一步證明 sup θ ≤ θ 0 π φ ( θ ) = α = π φ ( θ 0 ) {\displaystyle \sup _{\theta \leq \theta _{0}}\pi _{\varphi }(\theta )=\alpha =\pi _{\varphi }(\theta _{0})} ,這意味著測試 φ {\displaystyle \varphi } 的大小仍然是 α {\displaystyle \alpha } ,即使零假設被更改為 H 0 : θ ≤ θ {\displaystyle H_{0}:\theta \leq \theta } 。因此,在將 H 0 : θ = θ 0 {\displaystyle H_{0}:\theta =\theta _{0}} 更改為 H 0 : θ ≤ θ 0 {\displaystyle H_{0}:\theta \leq \theta _{0}} 並且不改變 H 1 {\displaystyle H_{1}} (同時也調整了測試 φ {\displaystyle \varphi } 的引數空間),測試 φ {\displaystyle \varphi } 仍然滿足“MP”要求(因為沒有改變 H 1 {\displaystyle H_{1}} ,因此步驟 2 中的結果仍然適用),並且測試 φ {\displaystyle \varphi } 將滿足“大小”要求(因為以這種方式改變了 H 0 {\displaystyle H_{0}} )。因此,測試 φ {\displaystyle \varphi } 是一個大小為 α {\displaystyle \alpha } 的 UMP 測試,用於測試 H 0 : θ ≤ θ 0 vs. H 1 : θ > θ 0 {\displaystyle H_{0}:\theta \leq \theta _{0}\quad {\text{vs.}}\quad H_{1}:\theta >\theta _{0}} .
對於測試 H 0 : θ ≥ θ 0 vs. H 1 : θ < θ 0 {\displaystyle H_{0}:\theta \geq \theta _{0}\quad {\text{vs.}}\quad H_{1}:\theta <\theta _{0}} ,步驟類似。但一般來說,對於測試 H 0 : θ = θ 0 vs. H 1 : θ ≠ θ 0 {\displaystyle H_{0}:\theta =\theta _{0}\quad {\text{vs.}}\quad H_{1}:\theta \neq \theta _{0}} ,不存在UMP檢驗。
當然,當步驟 3 中的條件成立而步驟 2 中的條件不成立時,步驟 1 中的檢驗 φ {\displaystyle \varphi } 是一個大小為 α {\displaystyle \alpha } 的UMP檢驗,用於測試 H 0 : θ ≤ θ 0 vs. H 1 : θ = θ 1 {\displaystyle H_{0}:\theta \leq \theta _{0}\quad {\text{vs.}}\quad H_{1}:\theta =\theta _{1}} ,其中 θ 1 {\displaystyle \theta _{1}} 是一個常數(大於 θ 0 {\displaystyle \theta _{0}} ,否則 H 1 {\displaystyle H_{1}} 和 H 0 {\displaystyle H_{0}} 不相交)。但是,假設通常不採用這種形式。
示例。 令 X 1 , … , X 10 {\displaystyle X_{1},\dotsc ,X_{10}} 是從正態分佈 N ( μ , 1 ) {\displaystyle {\mathcal {N}}(\mu ,1)} 中抽取的隨機樣本。
(a) 構造一個大小為 0.05 的MP檢驗 φ {\displaystyle \varphi } ,用於測試 H 0 : μ = 20 vs. H 1 : μ = 21 {\displaystyle H_{0}:\mu =20\quad {\text{vs.}}\quad H_{1}:\mu =21} 。
(b) 因此,證明檢驗 φ {\displaystyle \varphi } 也是一個大小為 0.05 的 UMP 檢驗,用於檢驗 H 0 : μ = 20 vs. H 1 : μ > 20 {\displaystyle H_{0}:\mu =20\quad {\text{vs.}}\quad H_{1}:\mu >20} 。
(c) 因此,證明檢驗 φ {\displaystyle \varphi } 也是一個大小為 0.05 的 UMP 檢驗,用於檢驗 H 0 : μ ≤ 20 vs. H 1 : μ > 20 {\displaystyle H_{0}:\mu \leq 20\quad {\text{vs.}}\quad H_{1}:\mu >20} 。
Solution . (a) We can use the Neyman-Pearson lemma. First, consider the likelihood ratio L ( 20 ) L ( 21 ) = ( 1 2 π ( 1 ) ) 10 ∏ i = 1 10 exp ( − ( x i − 20 ) 2 2 ) ( 1 2 π ( 1 ) ) 10 ∏ i = 1 10 exp ( − ( x i − 21 ) 2 2 ) = exp ( − 1 2 ∑ i = 1 10 [ ( x i − 20 ) 2 − ( x i − 21 ) 2 ] ) = exp ( − 1 2 ∑ i = 1 10 [ x i 2 − 40 x i + 400 − x i 2 + 42 x i − 441 ] ) = exp ( − 1 2 ∑ i = 1 10 [ 2 x i − 41 ] ) = exp ( 41 2 − ∑ i = 1 10 x i ) . {\displaystyle {\frac {{\mathcal {L}}(20)}{{\mathcal {L}}(21)}}={\frac {{\cancel {\left({\frac {1}{\sqrt {2\pi (1)}}}\right)^{10}}}\prod _{i=1}^{10}\exp \left(-{\frac {(x_{i}-20)^{2}}{2}}\right)}{{\cancel {\left({\frac {1}{\sqrt {2\pi (1)}}}\right)^{10}}}\prod _{i=1}^{10}\exp \left(-{\frac {(x_{i}-21)^{2}}{2}}\right)}}=\exp \left(-{\frac {1}{2}}\sum _{i=1}^{10}{\big [}(x_{i}-20)^{2}-(x_{i}-21)^{2}{\big ]}\right)=\exp \left(-{\frac {1}{2}}\sum _{i=1}^{10}{\big [}{\cancel {x_{i}^{2}}}-40x_{i}+400{\cancel {-x_{i}^{2}}}+42x_{i}-441{\big ]}\right)=\exp \left(-{\frac {1}{2}}\sum _{i=1}^{10}{\big [}2x_{i}-41{\big ]}\right)=\exp \left({\frac {41}{2}}-\sum _{i=1}^{10}x_{i}\right).} Now, we have L ( 20 ) L ( 21 ) ≤ k ′ ⟺ exp ( 41 2 − 10 x ¯ ) ≤ k ′ ⟺ − 10 x ¯ ≤ k ″ ⟺ x ¯ ≥ k {\displaystyle {\frac {{\mathcal {L}}(20)}{{\mathcal {L}}(21)}}\leq k'\iff \exp \left({\frac {41}{2}}-10{\overline {x}}\right)\leq k'\iff -10{\overline {x}}\leq k''\iff {\overline {x}}\geq k} where k , k ′ , k ″ {\displaystyle k,k',k''} are some constants. To find k {\displaystyle k} , consider the size 0.05: 0.05 = P μ = 20 ( X ¯ ≥ k ) = P μ = 20 ( X ¯ − 20 1 / 10 ≥ k − 20 1 / 10 ) = P ( Z ≥ 10 ( k − 20 ) ) . {\displaystyle 0.05=\mathbb {P} _{\mu =20}({\overline {X}}\geq k)=\mathbb {P} _{\mu =20}\left({\frac {{\overline {X}}-20}{1/{\sqrt {10}}}}\geq {\frac {k-20}{1/{\sqrt {10}}}}\right)=\mathbb {P} (Z\geq {\sqrt {10}}(k-20)).} ( Z ∼ N ( 0 , 1 ) {\displaystyle Z\sim {\mathcal {N}}(0,1)} ) Hence, we have 10 ( k − 20 ) ≈ 1.64 ⟹ k ≈ 20.51861 {\displaystyle {\sqrt {10}}(k-20)\approx 1.64\implies k\approx 20.51861} . Now, we can construct the rejection region: R = { ( x 1 , … , x n ) : x ¯ ≥ 20.51861 } , {\displaystyle R=\{(x_{1},\dotsc ,x_{n}):{\overline {x}}\geq 20.51861\},} and the test φ {\displaystyle \varphi } with the rejection region R {\displaystyle R} is a MP test with size 0.05 for testing H 0 : μ = 20 vs. μ = 21 {\displaystyle H_{0}:\mu =20\quad {\text{vs.}}\quad \mu =21} .
(b)
(c)
現在,讓我們考慮另一個例子,其中基礎分佈是離散的。
例: 令 X {\displaystyle X} 為一個離散隨機變數,其機率質量函式為 θ x 1 2 3 4 5 6 7 8 0 f ( x ; θ ) 0 0.02 0.02 0.02 0.02 0.02 0.02 0.88 1 f ( x ; θ ) 0.01 0.02 0.03 0.04 0.05 0 0.06 0.79 {\displaystyle {\begin{array}{c|ccccccccc}\theta &x&1&2&3&4&5&6&7&8\\\hline 0&f(x;\theta )&0&0.02&0.02&0.02&0.02&0.02&0.02&0.88\\1&f(x;\theta )&0.01&0.02&0.03&0.04&0.05&0&0.06&0.79\\\end{array}}} (注意每行值的總和均為 1。引數空間為 Θ = { 0 , 1 } {\displaystyle \Theta =\{0,1\}} 。)給定一個 單一觀測值 x {\displaystyle x} ,構建一個大小為 0.1 的最優檢驗來檢驗 H 0 : θ = 0 vs. H 1 : θ = 1 {\displaystyle H_{0}:\theta =0\quad {\text{vs.}}\quad H_{1}:\theta =1} 。
Solution . We use the Neyman-Pearson lemma. First, we calculate the likelihood ratio f ( x ; 0 ) / f ( x ; 1 ) {\displaystyle f(x;0)/f(x;1)} for each value of x {\displaystyle x} : x 1 2 3 4 5 6 7 8 f ( x ; 0 ) f ( x ; 1 ) 0 1 0.667 0.5 0.4 undefined 0.333 1.114 {\displaystyle {\begin{array}{ccccccccc}x&1&2&3&4&5&6&7&8\\\hline {\frac {f(x;0)}{f(x;1)}}&0&1&0.667&0.5&0.4&{\text{undefined}}&0.333&1.114\end{array}}} For convenience, let us sort the likelihood ratios in ascending order (we put the undefined value at the last): x 1 7 5 4 3 2 8 6 f ( x ; 0 ) f ( x ; 1 ) 0 0.333 0.4 0.5 0.667 1 1.114 undefined {\displaystyle {\begin{array}{ccccccccc}x&1&7&5&4&3&2&8&6\\\hline {\frac {f(x;0)}{f(x;1)}}&0&0.333&0.4&0.5&0.667&1&1.114&{\text{undefined}}\end{array}}} By Neyman-Pearson lemma, the MP test with size 0.1 for testing H 0 : θ = 0 vs. H 1 : θ = 1 {\displaystyle H_{0}:\theta =0\quad {\text{vs.}}\quad H_{1}:\theta =1} is a test with size 0.1 and rejection region R = { x : f ( x ; 0 ) f ( x ; 1 ) ≤ k } . {\displaystyle R=\left\{x:{\frac {f(x;0)}{f(x;1)}}\leq k\right\}.} So, it remains to determine R {\displaystyle R} . Since the size is 0.1, we have 0.1 = α ( 0 ) = P θ = 0 ( X ∈ R ) . {\displaystyle 0.1=\alpha (0)=\mathbb {P} _{\theta =0}(X\in R).} Notice that P θ = 0 ( X = 1 ) + P θ = 0 ( X = 7 ) + P θ = 0 ( X = 5 ) + P θ = 0 ( X = 4 ) + P θ = 0 ( X = 3 ) + P θ = 0 ( X = 2 ) = 0 + 0.02 + 0.02 + 0.02 + 0.02 + 0.02 = 0.1. {\displaystyle \mathbb {P} _{\theta =0}(X=1)+\mathbb {P} _{\theta =0}(X=7)+\mathbb {P} _{\theta =0}(X=5)+\mathbb {P} _{\theta =0}(X=4)+\mathbb {P} _{\theta =0}(X=3)+\mathbb {P} _{\theta =0}(X=2)=0+0.02+0.02+0.02+0.02+0.02=0.1.} So, we can choose k ∈ [ 1 , 1.114 ) {\displaystyle k\in [1,1.114)} (approximately), so that rejection region is { x : f ( x ; 0 ) f ( x ; 1 ) ≤ k } = { 1 , 7 , 5 , 4 , 3 , 2 } . {\displaystyle \left\{x:{\frac {f(x;0)}{f(x;1)}}\leq k\right\}=\{1,7,5,4,3,2\}.}
練習: 計算上述檢驗的第二類錯誤機率。
解決方案
機率為 β ( 1 ) = P θ = 1 ( X ∈ R c ) = P θ = 1 ( X = 8 ) + P θ = 1 ( X = 6 ) = 0.79. {\displaystyle \beta (1)=\mathbb {P} _{\theta =1}(X\in R^{c})=\mathbb {P} _{\theta =1}(X=8)+\mathbb {P} _{\theta =1}(X=6)=0.79.} (注意儘管該檢驗是最優的,但這種情況下第二類錯誤機率仍然很大。)
使用 Neyman-Pearson 引理構建另一個大小為 0.05 的最優檢驗來檢驗 H 0 : θ = 0 vs. H 1 : θ = 1 {\displaystyle H_{0}:\theta =0\quad {\text{vs.}}\quad H_{1}:\theta =1} 。
之前,我們建議使用 Neyman-Pearson 引理來構建檢驗簡單零假設與簡單備擇假設的最優檢驗。然而,當假設是複合的時候,我們可能無法使用 Neyman-Pearson 引理。因此,在接下來的內容中,我們將提供一個通用的方法來構建任何假設檢驗,不受限於簡單假設。但我們應該注意到,構建的檢驗不一定是均勻最優檢驗。
我們已經提到,假設檢驗與置信區間之間存在相似之處。在本節中,我們將介紹一個定理,該定理建議如何從置信區間(或更一般地,置信 集 )構造假設檢驗,反之亦然。
定理。 對於每個 θ 0 ∈ Θ {\displaystyle \theta _{0}\in \Theta } ,令 R ( θ 0 ) {\displaystyle R(\theta _{0})} 為大小為 α {\displaystyle \alpha } 的檢驗 H 0 : θ = θ 0 vs. H 1 : θ ≠ θ 0 {\displaystyle H_{0}:\theta =\theta _{0}\quad {\text{vs.}}\quad H_{1}:\theta \neq \theta _{0}} 的拒絕域。另外,令 x 1 , … , x n {\displaystyle x_{1},\dotsc ,x_{n}} 為來自潛在分佈的隨機樣本 X 1 , … , X n {\displaystyle X_{1},\dotsc ,X_{n}} 的對應實現。此外,令 x = ( x 1 , … , x n ) {\displaystyle \mathbf {x} =(x_{1},\dotsc ,x_{n})} 和 X = ( X 1 , … , X n ) {\displaystyle \mathbf {X} =(X_{1},\dotsc ,X_{n})} 。
定義一個集合 C ( x ) = { θ 0 : x ∈ R ( θ 0 ) c } . {\displaystyle C(\mathbf {x} )=\{\theta _{0}:\mathbf {x} \in R(\theta _{0})^{c}\}.} 那麼,隨機集合 C ( X ) {\displaystyle C(\mathbf {X} )} 是 1 − α {\displaystyle 1-\alpha } 置信集 θ 0 {\displaystyle \theta _{0}} 。
相反,設集合 C ∗ ( X ) {\displaystyle C^{*}(\mathbf {X} )} 是一個未知引數 θ {\displaystyle \theta } 的 1 − α {\displaystyle 1-\alpha } 置信集。對於每一個 θ 0 ∈ Θ {\displaystyle \theta _{0}\in \Theta } ,定義 R ( θ 0 ) = { x : θ 0 ∉ C ∗ ( x ) } . {\displaystyle R(\theta _{0})=\{\mathbf {x} :\theta _{0}\notin C^{*}(\mathbf {x} )\}.} 那麼, R ( θ 0 ) {\displaystyle R(\theta _{0})} 是一個檢驗 H 0 : θ = θ 0 vs. H 1 : θ ≠ θ 0 {\displaystyle H_{0}:\theta =\theta _{0}\quad {\text{vs.}}\quad H_{1}:\theta \neq \theta _{0}} 的大小為 α {\displaystyle \alpha } 的拒絕域。
↑ 如果 Θ 0 {\displaystyle \Theta _{0}} 為空,則該假設毫無意義,所以我們對此情況不感興趣。
↑ 因此,一個自然衡量假設檢驗“好壞”的指標是它的“誤差大小”。我們將在本章後面討論這些。
↑ 這是因為在" θ ∈ Θ 0 {\displaystyle \theta \in \Theta _{0}} "或" H 0 {\displaystyle H_{0}} (為真)"上進行條件化是沒有意義的,因為它們不是隨機的,因此機率為零或一。當機率為零時,“條件機率”沒有定義。當機率為一時,在它上的條件化與不在它上的條件化相同。
↑ 即使對於 Θ 0 {\displaystyle \Theta _{0}} 中的大多數引數值,測試犯第一類錯誤的機率很低,如果對於 Θ 0 {\displaystyle \Theta _{0}} 中的某個特定引數值,該測試犯第一類錯誤的機率很高,那麼直觀地說,這意味著該測試 不能很好地控制 第一類錯誤,對嗎?