本書 "12.2 The model-comparison approach" の代わりに、Exercise 12.1 の演習とその解法を Solutions to Exercises in Doing Bayesian Data Analysis Second Edition から引用する。
[Purpose: To make sure you understand the Bayes' factors regarding a single coin in Figure 12.3 and Equation 12.4, including the Savage-Dickey methods.]
英文の方がわかりやすいので、全て引用した。日本語は要約意訳と補足説明。また、本課題の「まとめ」的な、最後の (H) から始めた。
(H) Which approach, model comparison or estimation, seems most informative? Why? Within the model-comparison approach, which prior, uninformed Haldane or mildly informed, seems most meaningful? Why?
モデル比較とパラメータ推定のどちらが有益か?その理由は?モデル比較で意味がある事前確率は次のどちらか、「情報なしの Haldane」か「そこそこの情報」?その訳は?
モデル比較とパラメータ推定のどちらが有益か?その理由は?モデル比較で意味がある事前確率は次のどちらか、「情報なしの Haldane」か「そこそこの情報」?その訳は?
Parameter estimation seems more informative than model comparison because estimation gives explicit information about the magnitude of the parameter that describes the data, while the BF only indicates which prior distribution (model index) gets more credibility without saying anything about the parameter magnitude.
パラメータ推定の方が、モデル比較より有益。理由は、パラメータ推定は、データを表現するパラメータの影響について、明確な情報を与える。一方 Bayes ファクターは、どちらの事前確率が「確からしい」かを示すだけ。
Within the model-comparison approach, the mildly-informed prior is more meaningful than the Haldane prior because the Haldane, despite being a mathematically motivated default prior, does not express a theoretically meaningful hypothesis in this case.
モデル比較において、「そこそこの情報をもつ事前確率」が「Haldane 事前確率」よりも意味がある。Haldane は理論的に意味のある仮説であることを示していないから。
パラメータ推定の方が、モデル比較より有益。理由は、パラメータ推定は、データを表現するパラメータの影響について、明確な情報を与える。一方 Bayes ファクターは、どちらの事前確率が「確からしい」かを示すだけ。
Within the model-comparison approach, the mildly-informed prior is more meaningful than the Haldane prior because the Haldane, despite being a mathematically motivated default prior, does not express a theoretically meaningful hypothesis in this case.
モデル比較において、「そこそこの情報をもつ事前確率」が「Haldane 事前確率」よりも意味がある。Haldane は理論的に意味のある仮説であることを示していないから。
Now, suppose we have a coin that is flipped 24 times and shows 7 heads.
観測データ:コイン投げで 24 回中 7 回が表。
(A) According to the spike null hypothesis, for which the only credible value of θ is 0.5, what is the probability of the data? Hint: It is θz (1 - θ)(n-z)
the spike null hypothesis である θ = 0.5 で、この観測データの確率は?
> z <- 7; N <- 24
> theta <- 0.5
> pDgTheta <- theta^z * (1-theta)^(N-z)
> print(pDgTheta)
[1] 5.960464e-08
(B) Verify the result of the previous part by approximating a spike prior with a narrow beta distribution. Use the BernBeta function with a beta(θ | 2000, 2000) prior.
狭い β 分布で spike 事前確率を近似して、(A) の結果を確認する
狭い β 分布で spike 事前確率を近似して、(A) の結果を確認する
> source("BernBeta.R")
> a <- 2000; b <- 2000
> openGraph(width=5, height=7)
> BernBeta(c(a,b), c(rep(0,N-z),rep(1,z)), ROPE=c(0.48,0.52), plotType="Bars", showCentTend="Mode", showHDI=TRUE, showpD=TRUE)
(A) の結果 5.960464e-08 に、p(D) = 6.02e-08 は近似している。
(C) Show the result when using a nearly Haldane prior. Include the resulting graph in your report. What is the value of p(D) for this prior? Compute and report the Bayes' factor of this prior relative to the spike (null) prior, using the formula p(D | Haldane) / p (D | null).
Haldane 事前確率の場合の p(D) は? また、spike (null) prior と比較した Bayes ファクターを算出せよ。
> a <- 0.01; b <- 0.01
> openGraph(width=5,height=7)
> BernBeta(c(a,b), c(rep(0,N-z),rep(1,z)), ROPE=c(0.48,0.52), plotType="Bars", showCentTend="Mode", showHDI=TRUE, showpD=TRUE)
# Bayes factor, Haldane/null
# 2.87e-09 from (C), 5.96e-08 from (A)
# 2.87e-09 from (C), 5.96e-08 from (A)
> print(2.87e-09 / 5.96e-08)
[1] 0.04815436
spike (null) prior が勝っている。
(D) Continuing with the Haldane prior from the previous part, compute the approximate Bayes' factor using the Savage-Dickey method. That is, compute and report the ratio of percentage of prior within the ROPE over percentage of posterior with the ROPE.
Savage-Dickey 法を使った Bayes ファクターの近似方法は
Savage-Dickey 法を使った Bayes ファクターの近似方法は
(事後確率 ROPE が分布に占める割合)/(事前確率 ROPE が分布に占める割合)
# From the graph using the Haldane prior, prior p in ROPE is 0.08%,
# and posterior p in ROPE is 1.67%.
# The ratio is
> 0.08 / 1.67
[1] 0.04790419
(C) の 0.04815436 に近似している。
(E) Suppose we have previous knowledge that in this application there tend to be more tails than heads. Show the result when using a mildly informed prior. Include the resulting graph in your report. What is the value of p(D) for this prior? Compute and report the Bayes' factor of this prior relative to the spike (null) prior, using the formula p(D | informed) / p (D | null).
「そこそこの情報」な事前確率の場合の p(D) は? また spike (null) prior と比較した Bayes ファクターを算出せよ。
> a <- 2; b <- 4
> openGraph(width=5,height=7)
> BernBeta(c(a,b), c(rep(0,N-z),rep(1,z)), ROPE=c(0.48,0.52), plotType="Bars", showCentTend="Mode", showHDI=TRUE, showpD=TRUE)
# Bayes factor, informed/null
> print(2.22e-07 / 5.96e-08)
[1] 3.724832
# Bayes factor, informed/null
# 2.22e-07 from (E), 5.96e-08 from (A)
> print(2.22e-07 / 5.96e-08)
[1] 3.724832
(F) Continuing with the mildly informed prior from the previous part, compute the approximate Bayes' factor using the Savage-Dickey method. That is, compute and report the ratio of percentage of prior within the ROPE over percentage of posterior with the ROPE.
# From the graph using the Haldane prior, prior p in ROPE is 5.0%,
# and posterior p in ROPE is 1.38%.
# The ratio is
> 5.0 / 1.38
[1] 3.623188
(E) の 3.724832 に近似している。
(G) Report the 95% HDIs when starting with the Haldane prior and the mildly informed prior. Are the HDIs very different? Were the Bayes' factors very different?
Haldane と「そこそこの情報」の事前確率における、事後確率の 95%HDI を求めよ。HDI に違いはあるか? Bayes ファクターの違いは?
Haldane と「そこそこの情報」の事前確率における、事後確率の 95%HDI を求めよ。HDI に違いはあるか? Bayes ファクターの違いは?
Haldane prior : 0.122 to 0.471
informed prior: 0.145 to 0.462
The posterior HDIs are not very different and both exclude the ROPE. The BFs, on the other hand, are very different and make opposite decisions.
HDI には大差なく、どちらも ROPE に含まれていない。一方、spike (null) prior と比較した Bayes ファクターでは逆の結果。
「『確かめる』ことは『違いの有無を見つける』こと」に続く。
「『確かめる』ことは『違いの有無を見つける』こと」に続く。
0 件のコメント:
コメントを投稿