coin.spin: Function for Coin Spinning, Practical 11.1

Description Usage Arguments Details Value Author(s) References Examples

Description

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.

Usage

1
coin.spin(para, r = 0, n = 0, n.points = 199)

Arguments

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.

Details

This is provided simply so that readers spend less time typing. It is not intended to be robust and general code.

Value

x

Values of theta

y

Values of posterior density for theta

Author(s)

Anthony Davison (anthony.davison@epfl.ch)

References

Davison, A. C. (2003) Statistical Models. Cambridge University Press. Practical 11.1.

Examples

1
2
3
4
5
## 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)

SMPracticals documentation built on May 2, 2019, 11:12 a.m.