You are on page 1of 58

Statistical Inferences with Random Samples

Mei-Yuan Chen
Department of Finance
National Chung Hsing University

August 18, 2022

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 1 / 58
隨機樣本

隨機變數 X 的定義為

X : Ω → {x1 , x2 , . . . , xN } = DX (µX , σX2 , α3 (X), α4 (X)).

通常以 {x1 , x2 , . . . , xn } 表示自隨機母體 X 隨機抽出的一組樣本,


其中 n 表示樣本的個數 (number of sample observations) 為既定的
自然數,{x1 , x2 , . . . , xn } 為 {x1 , x2 , . . . , xN } 的子集合。此樣本為
隨機樣本,表示每一個樣本觀察值被抽到的可能性是相等的,進
而表示整個 n 個樣本觀察值被抽到的可能性也是相等的。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 2 / 58
樣本描述母體分配的方式

統計的目的在於以一組樣本觀察值藉由一個計算方式,達到瞭解
描述母體分配的母體參數或機率函數(或機率密度函數)的過
程;對應於母體參數的計算方式,稱為母體參數的樣本估計式
(sample estimator),而對應於機率(密度)函數的計算方式,稱
為機率(密度)函數的樣本估計式,即
1 母體參數樣本估計式:平均數 (µX )、變異數 (σX2 )、偏態係數
(α3 (X)) 及峰態係數 (α4 (X)) 樣本估計式;
2 母體機率函數或機率密度函數的樣本估計式。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 3 / 58
樣本觀察值的隨機性

一組樣本觀察值為已觀察到 (observed) 數值的集合,既已觀察


到,如何具有隨機性呢?在古典統計學派的立論中,重複抽樣
(repeating sampling) 是最基本的觀念。針對一組隨機變數 X 的樣
本觀察值 {x1 , x2 , . . . , xn },重複抽樣的觀念如下:
{x1 , x2 , . . . , xn }
第一次抽樣 {x11 , x12 , . . . , x1n }
第二次抽樣 {x21 , x22 , . . . , x2n }
第三次抽樣 {x31 , x32 , . . . , x3n }
.. ..
. .
第 ∞ 次抽樣 {x∞ ∞ ∞
1 , x2 , . . . , xn }

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 4 / 58
抽樣分配

若將第 i 個位置上的所有數值 {x1i , x2i , . . . , x∞


i } 點佈 (plot) 在實數
線上,其分佈情形即為第 i 個樣本觀察值 xi 的抽樣分配 (sampling
distribution),而此分配情形將與隨機變數 X 所有實現值的分佈情
形相同,表示第 i 個樣本觀察值 xi 的抽樣分配與母體分配相同,
或第 i 個樣本觀察值 xi 的隨機性與隨機變數 X 的隨機性相同;即

E(xi ) = E(X), var(xi ) = var(X)


α3 (xi ) = α3 (X). α4 (xi ) = α4 (X).

此外,在隨機抽樣中兩個觀察值的出現是相互獨立的,所以,
{x1 , x2 , . . . , xn } 不但表示一組母體 X 的樣本,亦可視為 n 個獨立
且相等分配的隨機變數 (independently and identically distributed
(i.i.d.) random variable)。
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 5 / 58
統計學討論的母體參數

由於隨機變數實現值的算術平均數可視為以相對次數計算的期望
值,因此,以樣本觀察值的簡單算術平均數作為以期望值所表現
之母體參數的估計式,為當然的選擇;即
∑n
i=1 xi
→ E(X)
∑n n
i=1 (xi − x̄n )
2
→ E[(X − E(X))2 ] = var(X)
∑n n
i=1 (xi − x̄n )
3
→ E[(X − E(X))3 ]
∑n n
i=1 (xi − x̄n )
4
→ E[(X − E(X))4 ].
n

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 6 / 58
兩個有關算術平均數的重要法則:大數法則

假設 X1 , X2 , . . . , Xn 為具有限平均數 µX < ∞ 的獨立且相等分配


的隨機變數,則當 n 足夠大時,
∑n
Xi
X̄n = i=1 → E(X) = µX
n
收斂至平均數 µ;此即稱為大數法則 (law of large number, LLN)。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 7 / 58
兩個有關算術平均數的重要法則:中央極限定

假設 X1 , X2 , . . . , Xn 為具有限平均數 µX < ∞ 和有限變異數


σX2 < ∞ 的獨立且相等分配的隨機變數,則當 n 足夠大時,
( )
√ X̄n − µX
n
σX

收斂到標準常態分配,其中,X̄n 為樣本平均數;此即稱為中央
極限定理 (central limit theorem, CLT)。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 8 / 58
x̄n 的抽樣分配


{x1 , x2 , . . . , xn } x̄n = ∑ ni=1 xi /n
第一次抽樣 {x11 , x12 , . . . , x1n } x̄1n = ∑ni=1 x1i /n
第二次抽樣 {x21 , x22 , . . . , x2n } x̄2n = ∑ni=1 x2i /n
第三次抽樣 {x31 , x32 , . . . , x3n } x̄3n = ni=1 x3i /n
.. ..
. . ∑n ∞
第 ∞ 次抽樣 {x∞ ∞ ∞
1 , x2 , . . . , xn } x̄∞
n = i=1 xi /n

若將所有的 x̄n 數值 {x̄n , x̄n , . . . , x̄n } 點佈 (plot) 在實數線上,其
1 2

分佈情形即為 x̄n 的抽樣分配,其平均數為 E(x̄n ) = E(X) 及變異


數 var(x̄n ) = σX2 /n。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 9 / 58
x̄n 的抽樣分配

1 不偏性 (unbiasedness):E(x̄n ) = E(X);


2 一致性 (consistency):var(x̄n ) = σX2 /n → 0;
3 當 X ∼ N(µX , σX2 ) 及 {x1 , x2 , . . . , xn } 為隨機樣本,
x̄n ∼ N(µX , σX2 /n);

n(x̄n −µX )
4
σX
→ N(0, 1) 若 σX2 < ∞。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 10 / 58
若 X 為一個 N(µX , σX2 ) 隨機變數,且樣本為獨立隨機抽樣,則每
一組隨機樣本觀察值的聯合機率密度函數為
∏n ( )
1 −(xi − µX )2
f(x1 , x2 , . . . , xn ) = √ exp 2
.
i=1
2πσ X 2σ X

若將實際觀察到的樣本觀察值及以 µ 與 σ 2 代替未知的 µX 與
σX2 ,則上式即為此樣本的概似函數 (likelihood function):


n ( )
1 −(xi − µ)2
L(x1 , x2 , . . . , xn ) = √ exp .
i=1
2πσ 2σ 2

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 11 / 58
硬幣是公平的嗎?

以統計的方式回答「這枚硬幣是公平的嗎?」
1 定義一個隨機變數(random variable)X : Ω = {反面, 正面} → {0, 1},其
中,Ω 為投擲這枚硬幣隨機實驗(random experiment) 所有出
項(outcomes) 的樣本空間(sample space),{0, 1} 為隨機變數 X 定義所
有實現值(realizations) 的集合。此外,P(X = 1) = pX 表示出現正面的機
率值,P(X = 0) = 1 − pX 表示出現反面的機率值。
2 「這枚硬幣是公平的嗎?」的問題可改寫成「Is PX = 0.5?」,或更有學問
的虛無假設「H0 : pX = 0.5」
3 蒐集一組具有 n 個觀察值(observation) 的隨機樣本(random
sample){x1 , x2 , . . . , xn },即以相同的方式投擲這枚硬幣 n 次,並以 1 記
錄正面、以 0 記錄反面的投擲結果;因此,xi = 1 或 0。
4 如何整理隨機樣本觀察值成為回答問題的有用資訊?

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 12 / 58
一個母體比例的假設檢定推論邏輯

x̄n ≈ pX If distance is large enough


↖ =⇒ reject H0
distance ∥ H0
↘ If distance is not large enough
p0
=⇒ do not reject H0

∑n
x̄n − p0 H0 i=1 xi x̄n (1 − x̄n )
tx̄n = → N(0, 1), x̄n = , s2x̄n = .
sx̄n n n
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 13 / 58
樣本訊息的萃取

1 X : Ω = {反面, 正面} → {0, 1} 稱為 Bernoulli(pX ) 分配,其特性為

E(X) = 1 × P(X = 1) + 0 × P(X = 0) = pX


VAR(X) = σX2 = E[(X − E(X))2 ] = pX (1 − pX ),

1∑
n
正面的個數 反面的個數
x̄n = xi = 1× +0×
n i=1 n n
= 1 × P∗ (X = 1) + 0 × P∗ (X = 0) = E∗ (X).

3 x̄n 抽樣分配具有的特性:
1 不偏性 (unbiasedness):E(x̄n ) = E(X) = pX
2 一致性 (consistency):limn→∞ x̄n = pX
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 14 / 58
樣本比例的特性:不偏性

樣本比例抽樣分配的平均數為

n
E(p̄n ) = E( xi /n)
∑i=1
n
i=1 E(xi )
=
∑n n
i=1 pX
= , as E(xi ) = E(X) = pX ,
n
= pX . unbiased estimator

所以,樣本比例為母體比例 pX 的不偏估計式;

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 15 / 58
樣本比例的特性:一致性
樣本比例抽樣分配的變異數為
[ ]
1∑
n
var(p̄n ) = var xi
n i=1
[ n ]
1 ∑
= var xi
n 2
i=1
 
1  ∑ n ∑
n−1 ∑ n
= var(xi ) + 2 cov(xi , xj ) , cov(xi , xj ) = 0,
n2 i=1 i=1 j=i+1

1 ∑
n
pX (1 − pX )
= pX (1 − pX ) = .
n2 i=1 n

由於當樣本個數 n → ∞ 時,pX (1 − pX )/n 收斂到 0,表示樣本


比例為母體比例 pX 的一致估計式。
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 16 / 58
樣本平均數變異數的估計式:獨立樣本

σX2
在獨立的隨機樣本下,樣本平均數的變異數為

σx̄n = n
,而母體
n
i=1 (xi −x̄n )
2
變異數 σX2 的估計式為 s2x = n−1
,因此,樣本平均數變異
數的估計式可為

σ̂x̄2n = var(x̄
ˆ n)
[ ]
1 ∑
n
s2x 1
= = (xi − x̄n )2 .
n n n − 1 i=1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 17 / 58
推論誤差

真實的母體參數數值必須由蒐集到所有的實現值或經過無限多次的實驗紀錄計
算而得,因此,真實的母體參數是無法得知的;在統計分析上,唯有一組有限
個數的觀察值或實驗記錄值所組成的樣本是可觀察到的,因此,必須由所觀察
到的樣本,從中萃取其樣本訊息,以獲致「支持(不棄卻)」或「不支持(棄
卻)」
虛無假設的推論結果,進而回答現實問題。由於真實的母體參數未知,因
此虛無假設下的母體參數假設數值可能為真、也可能為假,使得經由樣本訊息
的推論結果「支持(不棄卻)」
或「不支持(棄卻)」
虛無假設,呈現以下四種可
能情況:

真實情況
H0 為真 H0 為偽
推論 棄卻 H0 第一型錯誤推論 正確推論
結果 不棄卻 H0 正確推論 第二型錯誤推論

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 18 / 58
假設推論的型 I 誤差 α
型 I 誤差為在虛無假設為真下錯誤做出棄卻虛無假設的機率。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 19 / 58
假設推論的型 II 誤差 β
型 II 誤差為在對立假設為真下錯誤做出不棄卻虛無假設的機率。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 20 / 58
雙尾及單尾 p 值
在虛無假設為真下的假設檢定統計量的抽樣分配中,比由實際隨
機樣本計算的統計檢定量更為極端範圍所包含的機率值。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 21 / 58
檢定力 (Power)
在對立假設為真下,正確棄卻虛無假設範圍所包含的機率值。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 22 / 58
單尾檢定(I):H0 : µX ≥ 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 23 / 58
單尾檢定(II):H0 : µX ≤ 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 24 / 58
大樂透有明牌嗎?

大樂透、六合彩有明牌嗎?亦即,每一個號碼出現的機率是不是
一樣?從中國信託「台灣彩券」的網頁
http://www.taiwanlottery.com.tw/Lotto/Lotto649/history.aspx
下載各期的中獎號碼,首先以「某一個號碼出現的機率值是否等
於 1/49?」進行檢定。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 25 / 58
個別號碼出現機率值的檢定

令隨機變數 X1 的定義為

X1 : Ω = {號碼非為 1, 號碼為 1} → {0, 1}

並定義 P(X1 = 1) = PX1 ,則 P(X1 = 0) = 1 − PX1 。此時,我們問


題的虛無假設即為:H0 : PX1 = 1/49。

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 26 / 58
所有號碼的機率值是否相等?

為對於這個虛無假設進行統計檢定,一組具有母體代表性的樣本
是必要的,假設我們蒐集到一組具有母體代表性的 n = 673 個樣
本觀察值,由於我們相信樣本具有母體代表性,因此,如果虛無
假設為真,則此 n 個觀察值的樣本中每一號碼應有接近 n/49 個
觀察值,此 n/49 即稱為在虛無假設下樣本數為 n 的預期個
數(expected frequency) 或理論個數(theoretical frequency);所以藉
由實際樣本中各個號碼的個數與 n/49 數值間的差異,可作為該
樣本是否支持虛無假設的準則,即若差異大,表示實際觀察的樣
本不支持虛無假設,反之,則支持虛無假設。依

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 27 / 58
此概念,Karl Pearson (1990) 建議如下的統計量


k
(fi − Ei )2 ∑
k
(fi − nPi )2
ϕ= = ,
i=1
Ei i=1
nPi

其中

fi = 樣本中第 i 個出象的實際觀察個數 (樣本次數)


Pi = 虛無假設下第 i 個出象的機率值
Ei = 虛無假設下第 i 個類項的預期個數, Ei = nPi ,
n = 樣本觀察個數
k = 母體所定義出象的個數

在虛無假設下及樣本觀察個數 n 足夠大使中央極限定理成立下,
這個統計量 ϕ 的極限分配為一具有自由度 k − 1 的卡方分配
(χ2 (k − 1));其說明如下:
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 28 / 58
一個母體平均數的假設檢定推論邏輯:已知變
異數

x̄n ≈ µX If distance is large enough


↖ =⇒ reject H0
distance ∥ H0
↘ If distance is not large enough
µ0
=⇒ do not reject H0

∑n
x̄n − µ0 H0 i=1 xi σ02
tx̄n = → N(0, 1), x̄n = , σx̄2n = .
σx̄n n n
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 29 / 58
一個母體平均數的假設檢定推論邏輯:常態分
配假設且變異數未知

x̄n ≈ µX If distance is large enough


↖ =⇒ reject H0
distance ∥ H0
↘ If distance is not large enough
µ0
=⇒ do not reject H0

∑n
x̄n − µ0 H0 i=1 xi S2x
tx̄n = ∼ t(n − 1), x̄n = , s2x̄n =
sx̄ n n
∑n n
i=1 (xi − x̄n )
2
S2x = .
n−1 . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 30 / 58
不需常態分配假設且變異數未知:隨機樣本

x̄n ≈ µX If distance is large enough


↖ =⇒ reject H0
distance ∥ H0
↘ If distance is not large enough
µ0
=⇒ do not reject H0

∑n
x̄n − µ0 H0 i=1 xi S2x
tx̄n = ∼ t(n − 1), x̄n = , s2x̄n =
sx̄ n n
∑n n
i=1 (xi − x̄n )
2
S2x = .
n−1
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 31 / 58
不需常態分配假設且變異數未知:非隨機樣本

x̄n ≈ µX If distance is large enough


↖ =⇒ reject H0
distance ∥ H0
↘ If distance is not large enough
µ0
=⇒ do not reject H0

∑n
x̄n − µ0 H0 i=1 xi
tx̄n = → N(0, 1), x̄n = .
σ̂x̄n n

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 32 / 58
一個母體變異數的假設檢定推論邏輯

S2x ≈ σX2 If distance is large enough


↖ =⇒ reject H0
distance ∥ H0
↘ If distance is not large enough
σ02
=⇒ do not reject H0

∑n
(n − 1)S2x H0 2 − x̄n )2
i=1 (xi
χ= ∼ χ (n − 1), S2x = .
σ02 n−1
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 33 / 58
兩個母體比例的假設檢定推論邏輯

p̄x − p̄y ≈ PX − PY If distance is large enough


↖ =⇒ reject H0
distance ∥ H0
↘ If distance is not large enough
0
=⇒ do not reject H0

p̄x − p̄y H0
tp̄x −p̄y = ∼ N(0, 1), s2p̄x −p̄y = p̄(1 − p̄)(1/n + 1/m)
sp̄x −p̄y
∑n ∑m
i=1 xi + j=1 yj
p̄ = .
n+m
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 34 / 58
兩個母體平均數的假設檢定推論邏輯

x̄n − ȳm ≈ µX − µY If distance is large enough


↖ =⇒ reject H0
distance ∥ H0
↘ If distance is not large enough
0
=⇒ do not reject H0

x̄n − ȳm H0
tx̄n −ȳm = ∼ N(0, 1), s2x̄n −ȳm = S2n+m (1/n + 1/m)
sx̄n −ȳm
∑n ∑m
i=1 (xi − x̄n ) + j=1 (yj − ȳm )
2 2
S2n+m = .
n+m−2
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 35 / 58
兩個母體變異數的假設檢定推論邏輯

s2x /s2y 2 2
≈ σX /σY If distance is large enough
↖ =⇒ reject H0
distance ∥ H0
↘ If distance is not large enough
1
=⇒ do not reject H0

s2x H0
ϕ = ∼ F(n − 1, m − 1)
s2y
∑n ∑m
j=1 (yj − ȳm )
2
i=1 (xi − x̄n )
2
s2x = 2
, sy = .
n−1 m−1
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 36 / 58
Maximum Likelihood Estimator: MLE
Given a random sample, {x1 , x2 , . . . , xn }, from X ∼ N(µX , σX2 ), the density
function fX (xi ; µX , σX2 ) and likelihood function l(xi ; µ, σ 2 ) of xi are
( )
1 −(xi − µX )2
fX (xi ; µX , σX ) = √
2
exp
2πσX 2σX2
( )
1 −(xi − µ)2
l(xi ; µ, σ 2 ) = √ exp ,
2πσ 2σ 2

where µ and σ 2 are two variants. The joint density function and joint likelihood
function of {x1 , x2 , . . . , xn } are


n ( )
1 −(xi − µX )2
f(x1 , x2 , . . . , xn ; µX , σX2 ) = √ exp
i=1
2πσX 2σX2
∏n ( )
1 −(xi − µ)2
l(x1 , x2 , . . . , xn ; µ, σ 2 ) = √ exp .
i=1
2πσ 2σ 2

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 37 / 58
Log Joint Likelihood Function

The log joint likelihood function is

log[l(x1 , x2 , . . . , xn ; µ, σ 2 )]
[ n ( )]
∏ 1 −(xi − µ)2
= log √ exp
i=1
2πσ 2σ 2
n n ∑ n
−(xi − µ)2
= − log(2π) − log(σ ) + 2
.
2 2 i=1
2σ 2

The maximum likelihood estimators of µX and σX2 are obtained as

{µ̃n , σ̃n2 } = arg max log[l(x1 , x2 , . . . , xn ; µ, σ 2 )].


µ∈R,σ 2 ∈R+

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 38 / 58
First-order Conditions for Maximization

∂ log[l(x1 , x2 , . . . , xn ; µ, σ 2 )] ∑
n
(xi − µ) set
= =0
∂µ i=1
σ2
∑n
∂ log[l(x1 , x2 , . . . , xn ; µ, σ 2 )] n i=1 (xi − µ)2 set
= − 2+ = 0,
∂σ 2 2σ 2σ 4
Then, the MLE µ̃n and σ̃n2 satisfy the normal eqnation:


n
(xi − µ̃n )
= 0
i=1
σ̃n2
∑n
n i=1 (xi − µ̃n )2
− + = 0.
2σ̃n2 2σ̃n4
We have the MLE
∑n ∑n
xi i=1 (xi − µ̃n )2
µ̃n = i=1 = x̄n , σ̃n2 = ̸= s2X .
n n . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 39 / 58
Density and Joint Density Function

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 40 / 58
Likelihood and Joint Likelihhod Functions

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 41 / 58
Likelihood and Joint Likelihhod Functions

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 42 / 58
Likelihood and Joint Likelihhod Functions

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 43 / 58
Likelihood and Joint Likelihhod Functions

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 44 / 58
Run Test(連串檢定)of Bradley (1968) for
Randomness
The run test of Bradley (196) is commonly used to check whether a
sample is random or not. A run is defined as a series of increasing
values or a series of decreasing values. The number of increasing, or
decreasing, values is the length of the run. In a random data set, the
probability that the (i + 1)th value is larger or smaller than the ith
value follows a binomial distribution, which forms the basis of the
runs test. For example, a series of 20 coin tosses might produce the
following sequence of heads (H) and tails (T).

HHTTHTHHHHTHHTTTTTHH

The number of runs for this series is 9. There are 11 heads and 9
tails in the sequence.
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 45 / 58
Run Test of Bradley (1968)

We will code values above the median as positive and values below
the median as negative. A run is defined as a series of consecutive
positive (or negative) values. The runs test is defined as:

H0 : the sequence was produced in a random manner


Ha : the sequence was not produced in a random manner.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 46 / 58
Run Test of Bradley (1968)

Test statistic:
R − E(R)
Z= → N(0, 1)
σR
where R is the observed number of runs, and
2n1 n2
E(R) = + 1,
n1 + n2
2n1 n2 (2n1 n2 − n1 − n2 )
σR2 = .
(n1 + n2 )2 (n1 + n2 − 1)

with n1 and n2 denoting the number of positive and negative values


in the series.
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 47 / 58
Run Test
A run is defined as the repeated occurrence of the same value or
category of a variable. It is indexed by two parameters, which are the
type of the run and the length. Stock price runs can be positive,
negative, or have no change. The length is how often a run type
occurs in succession. Under the null hypothesis that successive
outcomes are independent, the total expected number of runs is
distributed as normal with the following mean and variance:
n + 2 nA nB
E(R) =
n
2 nA nB (2 nA nB − n)
var(R) = ,
n2 (n − 1)

where n is the total number of observations, nA is the number of first


run cycle, and nB is the number of second run cycle. Number of runs
is marked with R. .
.
.
.
.
. . . . .
. . . .
. . . .
. . . .
. . . .
. . . . .
.
.
.
.
.
.
.
.
.

M.-Y. Chen E370SiRgP.ctx August 18, 2022 48 / 58


The test statistic
R − E(R)
tR = √ → N(0, 1).
var(R)

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 49 / 58
Normal Distribution:

{Rit , t = 1, . . . , T} have been assumed as be independent and


identically distributed as normal with fixed mean and variance.
Drawbacks of this assumption are as follows. First, Rit has lower
bound -1 however there is no bound for realizations of a normal
distribution. Second, the multi-period simple return Rit [k] will not be
normally distributed even Rit is normally distributed. Third, the
normality assumption is not supported by most empirical empirical
asset returns.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 50 / 58
Jarque-Bera Test for Normal Distribution:
For a random variable X, a random sample {x1 , x2 , . . . , xn } is
obtained from X randomly. The Jarque-Bera test is to test the null
H0 : Xis normally distributed and its statistic is
( )
1 (K − 3)2
JB = Sk +
6 4

which converges to χ2 (2) asymptotically, where

1 ∑ (xi − x̄n )3
n
Sk =
n − 1 i=1 s3x
1 ∑ (xi − x̄n )4
n
K = .
n − 1 i=1 s4x
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 51 / 58
QQ Plot: Test for Normal Distribution

A random sample {x1 , x2 , . . . , xn } is from a random variable X. The interested


null hypothesis is whether X is normal or not. QQ-plot is a visual aid to do the
test:
∑N
1 Calculate the sample mean and sample variance as x̄n =
∑ i=1 xi /n and
n
s2X = i=1 (xi − x̄n )2 /(n − 1);
2 Standardized the sample observations as di = (xi − x̄n )/sX , i = 1, . . . , n;
3 Standard normal quantiles q1 = Z 2n1 , q2 = Z 2n3 , · · · , qn = Z 2n−1 ;
2n

4 The plots of {(qi , di ), i = 1, . . . , n} and {(qi , qi ), i = 1, . . . , n} constitutes


QQ-plot. The closer these two plots are, random variable X is closer to a
normal distribution.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 52 / 58
Goodness-of-fit Test for Normal Distribution

The goodness-of-fit test statistic provided by Karl Pearson (1900) is


k
(fi − Ei )2 H
ϕ= →0 χ2 (k − 1 − p),
i=1
Ei

where
fi = observed frequency for category i
Ei = expected frequency for category i based on the assumption
that H0 is true
k = number of categories
p = number of population parameters estimated from the sample.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 53 / 58
The goodness of fit test for normal probability distribution is also
based on the use of the chi-square distribution. For example, from a
sample {x1 , . . . , xn }, we have

x̄n = 68.42, sx = 10.41.

The null hypothesis is

H0 : The sample is from a Gaussian distribution with mean 68.42


and standard deviation 10.41

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 54 / 58
Denote zα as the αth quantile of the standard normal distribution Z,
i.e.,

zα : P(Z ≤ zα ) = α.

And then, under the null hypothesis that the sample {x1 , x2 , . . . , xn }
is from a normal distribution with mean x̄n = 68.42 and stadard
deviation sx = 10.41, the the αth quantile of the standard normal
distribution X is

xα = x̄n + zα × sx = 68.42 + zα × 10.41.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 55 / 58
Lower 10 %: 68.42 - 1.28 (10.41) = 55.10
Lower 20 %: 68.42 - 0.84 (10.41) = 59.68
Lower 30 %: 68.42 - 0.52 (10.41) = 63.01
Lower 40 %: 68.42 - 0.25 (10.41) = 65.82
Mid-score : 68.42 - 0.00 (10.41) = 68.42
Upper 40 %: 68.42 + 0.25 (10.41) = 71.02
Upper 30 %: 68.42 + 0.52 (10.41) = 73.83
Upper 20 %: 68.42 + 0.84 (10.41) = 77.16
Upper 10 %: 68.42 + 1.28 (10.41) = 81.74

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 56 / 58
Interval fi Ei (fi − Ei )
Less than 55.10 5 5 0
55.10 to 59.68 5 5 0
59.68 to 63.01 9 5 4
63.01 to 65.82 6 5 1
65.82 to 68.42 2 5 -3
68.42 to 71.02 5 5 0
71.02 to 73.83 2 5 -3
73.83 to 77.16 5 5 0
77.16 to 81.74 5 5 0
81.74 and Over 6 5 1
Total 50 50

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 57 / 58
The test statistic is calculated as

k
(fi − Ei )2 02 02 42 12
ϕ= = + + + ··· + = 7.2.
i=1
ei 5 5 5 5

Here k = 10 and p = 2. Thus, 7.2 is less than χ20.10 (7) = 12.017, the
null is not rejected. That is, the hypothesis that the probability
distribution for the test scores is a normal distribution can not be
rejected.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
M.-Y. Chen E370SiRgP.ctx August 18, 2022 58 / 58

You might also like