siegfried
siegfried

Reputation: 451

determine equal-tail credible interval

enter image description here

I have obtained the posterior density for part d: $2 theta^{-1}(1- theta)^{-1}$. How do I plot in R the distribution to find the l and u such that $F_{theta| x} (l) = 0.025$ and $F_{theta| x} (u) = 0.975$? (the equal-tail interval)

Upvotes: 0

Views: 1483

Answers (2)

Stéphane Laurent
Stéphane Laurent

Reputation: 84519

Your result is erroneous. By Bayes' theorem, the posterior density is proportional to p(theta)P(X=2|theta) = 1-theta. So we recognize the Beta distribution Beta(1,2). To graph it in R, you can do:

curve(dbeta(x, 1, 2), from = 0, to = 1)

Now the posterior equi-tailed credible interval is given by the quantiles of this distribution. In R:

qbeta(0.025, 1, 2) # lower bound
qbeta(0.975, 1, 2) # upper bound

If you don't know the Beta distribution, you can get these quantiles by elementary calculations. The integral of 1-theta on [0,1] is 1/2. So the posterior density is 2(1-theta) (it must integrate to one). So the posterior cumulative distribution function is 2(theta - theta²/2) = -theta² + 2theta. To get the p-quantile (with p=0.025 and p=0.975), you have to solve the equation -theta² + 2theta = p in theta. This a second-degree polynomial equation, easy to solve.

Upvotes: 2

Limey
Limey

Reputation: 12451

Finding the central 95% CI is actually easier than finding the 95% HPD. As you have the density (PDF), you also know the CDF. The lower and upper limits of the central 95% CI are given by CDF(l) = 0.025 and CRF(u) = 0.975.

Upvotes: 0

Related Questions