Engineering Skills

製品開発エンジニアがデータ解析のノウハウを垂れ流します

外れ値(2)ー Thompson/Masuyamaの棄却検定

外れ値検定としてはSmirnoff-Grubbsの検定を知っていれば十分な気がしますが、ThompsonとMasuyamaの棄却検定も勉強を兼ねて紹介、実装してみます。

Thompsonの棄却検定

[math] \bar{x} [/math]を標本平均、[math] \displaystyle {V}^2 [/math]を標本分散(不偏分散ではなく、サンプル数Nで割る方)とします。

[math] \displaystyle t = \frac {| x - \bar{x} |}{V} [/math]

とした時、下記を計算します。

[math] \displaystyle \tau = \frac { \tau \sqrt{N-2}}{\sqrt{N-1-{\tau}^2}} [/math]

これを、検定の有意水準[math] \displaystyle \alpha [/math]とした時、自由度[math] \displaystyle n-2 [/math][math] t [/math]分布から[math] \displaystyle t_{{\alpha}/2} [/math]を算出して左記統計量より大きい場合に有意とします。

Masuyamaの棄却検定

[math] \bar{x} [/math]を標本平均、[math] \displaystyle {\sigma}^2 [/math]を不偏分散とします。

検定の有意水準[math] \displaystyle \alpha [/math]とした時、自由度[math] \displaystyle n-2 [/math][math] t [/math]分布から[math] \displaystyle t_{{\alpha}/2} [/math]を算出します。検定対象が下記範囲外の場合、有意となります。

[math] \displaystyle \bar{x} \pm ({\sigma} \sqrt{\frac{N+1}{N}} t_{{\alpha}/2} ) [/math]


これを、Thompsonの棄却検定と同じ書き方をすれば下記のようになります。

[math] \displaystyle t = \frac {| x - \bar{x} |}{\sigma} [/math]
[math] \displaystyle \tau = t \sqrt {\frac {N}{N+1}} [/math]

上記が[math] \displaystyle t_{{\alpha}/2} [/math]より大きい場合に有意とします。

検定例

有名なアヤメ(iris)データのがく片の長さ(sepal length)を品種ごとに正規確率プロットした結果です。

f:id:OceanOne:20200806032501p:plain:w350

この例に通常のSmirnoff-Grubbs検定を適用した場合、P値<0.05では有意ではないので、平均値の代わりに中央値、標準偏差の代わりにNIQRを用いたSmirnoff-Grubbs検定が下記です。

f:id:OceanOne:20200806032625p:plain:w350

Thompson検定をP値<0.05で適用した場合は下記です。

f:id:OceanOne:20200809011650p:plain:w350

Masuyama検定をP値<0.05で適用した場合は下記です。

f:id:OceanOne:20200809011516p:plain:w350]

まとめ

これらも実装した結果を左記に置いています。こちらです。感触を掴む用にどうぞ。