中野智文

中野智文(VOYAGE GROUP)のコンピュータなどのメモ

Wilson score interval with continuity correction の式のテンプレート

2016-08-29 15:45:36 | 統計・機械学習

背景

二項分布のUCB、LCBを求めるに、近似式である Wilson score interval with continuity correction の式を使いたい。 近似式だが、Wald interval より正確で、さらに計算が面倒な、exact method とよばれる Clopper-Pearson interval より「良い」のだそうだ。

応用

信頼区間と聞くと検定的な話や、グラフに表示することくらいしか思い浮かべられないが、次の「いいねが209/259と、118/143の場合、どちらを高く順位付けしたらいい」 How Not To Sort By Average Rating みたいな単純に平均だけで評価すると数により信頼性が失われるので妥当な順位が付けられない問題を解決することが出来る。

その他の手法との比較

adjusted Wald と Wilson score の比較

近似式は他にも、adjusted Wald confidence interval などがあるが、Wallis, S. (2013). Binomial confidence intervals and contingency tests: mathematical fundamentals and the evaluation of alternative methods. Journal of Quantitative Linguistics, 20(3), 178-208.では、 One alternative proposal, termed the Agresti-Coull interval (Brown et al. 2001) employs the adjusted Wilson centre p' and then substitutes it for p into the Wald standard deviation s (see Equation 1). We do not consider this interval here, whose merits primarily concern ease of presentation. Its performance is inferior to the Wilson interval. とある。また、Sauro, J., & Lewis, J. R. (2005, September). Estimating completion rates from small samples using binomial confidence intervals: comparisons and recommendations. In Proceedings of the human factors and ergonomics society annual meeting (Vol. 49, No. 24, pp. 2100-2103). SAGE Publications.では、実験結果にて、 The Adjusted Wald and Score methods provided average coverage closest to the 95% nominal level, which confirms earlier recommendations in the statistical literature (Agresti and Coull, 1998). であり、Adjusted Waldの方がいいとしつつも、 The only advantage in using the Score method is that it provides more precise endpoints when the ends of the intervals are close to 0 or 1. For some values (e.g. 9/10) the adjusted Wald’s crude intervals go beyond 1 and a substitution of >.999 is used. For the Score method, however, the upper interval is calculated as a more precise .9975. ということは、CTRやCVRの計算ではScore method (Wilson)の方がよいということだろうか。 adjusted Waldを提案している論文Agresti, A., & Coull, B. A. (1998). Approximate is better than “exact” for interval estimation of binomial proportions. The American Statistician, 52(2), 119-126.では、 We strongly recommended that instructors present the score interval instead. と述べている。その後、adjusted Wald はこれまで Waldを使っていた人で、score interval が使いたくない人向けに作ったよ的な感じで話が進んでいくが、 The adjusted Wald interval also has the advantage, relative to the score interval, of not having spikes with seriously low converge near p = 0 and 1. とも述べている。ただ全体的に score intervalと adjusted Wald を比較している実験結果がないように思える。 (一般的なことかもしれないが)

Wilson score interval とその他の手法の比較

Newcombe, Robert G. "Interval estimation for the difference between independent proportions: comparison of eleven methods." Statistics in medicine 17.8 (1998): 873-890. では、Wilson score interval と、Wilson score interval with continuity correction の二手法がよいとされる。なおこの論文の中で、 Wilson score interval with continuity correction が提案された模様。

Wilson score interval と Wilson score interval with continuity correction の比較

Wallis, S. (2013). Binomial confidence intervals and contingency tests: mathematical fundamentals and the evaluation of alternative methods. Journal of Quantitative Linguistics, 20(3), 178-208.では、 Consequently the most accurate estimate of the single sample confidence interval about an observation p that we have examined is the Wilson score interval with continuity correction. だそうで、今回の、 Wilson score interval with continuity correction が出てくる。

Webでの言及

日本語では、具体的にクリック率やコンバージョン率の信頼区間を求めたい! (1)というページでまとめられている。 そこでは、 Agresti & Coull の Adjusted Wald confidence interval を利用するのがよいのではないか という結論になっている。ただWilson scoreを選ばなかった理由ははっきりしていない。 先の論文では、信頼区間が0や1に近い(CTRではそのようなことが多い)場合はWilson scoreが良いようなことが言及されていただけに、何か別の理由があるのかもしれない。

テンプレート

間違いがあるといけないので、テンプレート化しておき、直接エディタで置換して使うことにする。 PはX/Nであることが多いと思われるが、括弧をつけて、(X/N)として利用すること。
  UCB: (2*N*P+Z*Z+(Z*sqrt(Z*Z-1/N+4*N*P*(1-P)-(4*P-2))+1))/(2*(N+Z*Z)) 
  LCB: (2*N*P+Z*Z-(Z*sqrt(Z*Z-1/N+4*N*P*(1-P)+(4*P-2))+1))/(2*(N+Z*Z)) 

追記・修正

  • 2016/9/26: テンプレートのLCB, UCBが逆になっていた。CPCやCPAの場合逆転するので…というのは言い訳か。
  • 2016/12/12: ルートの中が、負になることがある。特にLCBの時。Zの値を√2以上にする必要がある。

最新の画像もっと見る

コメントを投稿

ブログ作成者から承認されるまでコメントは反映されません。