coin.spin | R Documentation |
This function computes the posterior distribution of the success probability theta when a coin is spun on its edge (or tossed), when the prior density for that probability is a mixture of beta densities.
coin.spin(para, r = 0, n = 0, n.points = 199)
para |
A matrix with 3 columns and k rows, where k is the number of components of the mixture. The first column contains the probabilities, and the next two the shape parameters a and b for the components. |
r |
Number of successes |
n |
Number of trials |
n.points |
The number of values of theta, equally-spaced between 0 and 1. |
This is provided simply so that readers spend less time typing. It is not intended to be robust and general code.
x |
Values of theta |
y |
Values of posterior density for theta |
Anthony Davison (anthony.davison@epfl.ch
)
Davison, A. C. (2003) Statistical Models. Cambridge University Press. Practical 11.1.
## From Practical 11.1:
para <- matrix( c(0.5, 10, 20, 0.5, 20, 10), nrow=2, ncol=3, byrow=TRUE)
prior <- coin.spin(para)
plot(prior, xlab="theta",ylab="PDF", type="l",ylim=c(0,6))
post <- coin.spin(para, r=4, n=10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.