2016年2月4日木曜日

Metric 予測:外れ値と Robust 推定( t 分布)

SmartDrugIQ を高めるか?」からの続き。

"16.2 Outliers and robust estimation: The t Distribution" をもとにした。

左は前回投稿の図 16.3posterior-predictive check 。正規分布による MCMC 推定(水色曲線群)と、観測データのヒストグラム(赤色)との比較。

中央値付近でヒストグラムが曲線群突き抜けている、また、外れ値(x 軸両端)にも対応できていない。つまり

a more appropriate distribution than has taller or heavier tails than the normal 
正規分布より「高くて heavy-tailed な分布」が必要

そんな分布が t 分布ということ。以下は、ν(ギリシャ文字 nu)値を変化させた t 分布(μ = 0, σ = 1)で本書図 16.4 に相当。
> df<-data.frame(nu=as.factor(50),y=y,p=dt(y,50))
> df<-rbind(df,data.frame(nu=as.factor(30),y=y,p=dt(y,30)))
> df<-rbind(df,data.frame(nu=as.factor(3),y=y,p=dt(y,3)))
> df<-rbind(df,data.frame(nu=as.factor(2),y=y,p=dt(y,2)))
> df<-rbind(df,data.frame(nu=as.factor(1),y=y,p=dt(y,1)))
> p<-ggplot(df,aes(x=y,y=p,color=nu))+ geom_line()+ylab("p(y)")+ theme(legend.position=c(.1,.8))
> p

NHST を(ほぼ)否定」している本書なので、t 検定はないでしょう(笑)

Although the t distribution is usually conceived as a sampling distribution for the NHST t test, we will use it instead as a convenient descriptive model of data with outliers. 
NHST  t 検定の標本分布として通常は認識されている t 分布だが、ここでは「外れ値」を含むデータを表現するモデルとして使う。

WikipediaStudent's t-distribution にも同様の記述がある。
Robust parametric modeling 
The t-distribution is often used as an alternative to the normal distribution as a model for data. 

上記の t 分布のグラフ例で、3 つのパラメータ μ σ ν(ギリシャ文字 nu, "normality" パラメータ)の内、ν は NHST では「degrees of freedom 自由度」で、大抵は標本サイズから定数を引いた値。グラフからわかるように、ν = 1 で very heavy tails な分布 となる。ν = 30 で「ほぼ正規分布」。

「外れ値のデータを(慎重に)削除」という手法があるのかもしれないが、


heavy-tailed 分布

"heavy tailed" の意味は、以下の説明で理解できた。

There are three important subclasses of heavy-tailed distributions: the fat-tailed distributions, the long-tailed distributions and the subexponential distributions. In practice, all commonly used heavy-tailed distributions belong to the subexponential class. Wikipedia 
heavy-tailed 分布の 3 つの主要なサブクラスは、fat-tailed 分布, long-tailed 分布, subexponential 分布だが、実際的には通常使われる heavy-tailed 分布は  subexponential クラスに属する。

日本では「裾の重い分布」と訳されて Wikipedia のページもある。左の分類で理解がより進んだ。

とはいえ、「裾の重い」と訳しておきながら、「ヘヴィーテイル」と表記が混在するのはどうかと思うけど...。「heavy-tailed 分布」などの「英語混在表記」が一般化することを願う。


図 16.4 x[-3, -2] 付近を拡大して heavy-tailed な様子を見る。

> p+xlim(-3,-2)+ylim(0,0.07)

ν = 30, 50 より ν =1, 2, 3 の曲線が「下がっていない」様子が分かる。ν =1 が最も heavy-tailed なのも分かる。


How the t distribution is Robust

以下は本書図 16.5 の上段。
ここでは、6 つデータ(黒丸)の内 1 つが外れ値(y = 15付近)を正規分布と t 分布で最尤推定MLEs: maxmum likelihood estimates)したもの(データは "toy")。t 分布の μ = 0.12 と正規分布の μ = 2.5 から、正規分布が外れ値の影響を大きく受けている。

t 分布が外れ値に対応できるのは、正規分布では μ, σ で対応するのに加えて、t 分布では "normalityパラメータの ν が効いているため。

次は本書図 16.5 の下段で、実際のデータを最尤推定したもの。
明らかに正規分布より t 分布がデータにマッチしている。


t 分布のσ  ≠  正規分布の標準偏差

この題は、以下の説明で概ね理解できる。

 分布の中央域の ±σ が全体で占める割合は

  正規分布:68%
  t 分布   :ν = 2 で 58%、ν = 1 で 50% (以下の図16.6 の左列参照)

さらに視覚的に示したのが以下の図 16.6t 分布のパラメータ ν の変化と、分布中央の領域の変化を比較(μ = 0, σ = 1 で固定)。
v = Inf とは "infinity " で、t 分布は正規分布と等しいため、 ±σ の占める領域は正規分布の 68.27% となる。


「 t 分布で MCMC」に続く。

0 件のコメント:

コメントを投稿