Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

MCmultinomdirichlet

Monte Carlo Simulation from a Multinomial Likelihood with a Dirichlet Prior


Description

This function generates a sample from the posterior distribution of a multinomial likelihood with a Dirichlet prior.

Usage

MCmultinomdirichlet(y, alpha0, mc = 1000, ...)

Arguments

y

A vector of data (number of successes for each category).

alpha0

The vector of parameters of the Dirichlet prior.

mc

The number of Monte Carlo draws to make.

...

further arguments to be passed

Details

MCmultinomdirichlet directly simulates from the posterior distribution. This model is designed primarily for instructional use. π is the parameter of interest of the multinomial distribution. It is of dimension (d \times 1). We assume a conjugate Dirichlet prior:

π \sim \mathcal{D}irichlet(α_0)

y is a (d \times 1) vector of observed data.

Value

An mcmc object that contains the posterior sample. This object can be summarized by functions provided by the coda package.

See Also

Examples

## Not run: 
## Example from Gelman, et. al. (1995, p. 78)
posterior <- MCmultinomdirichlet(c(727,583,137), c(1,1,1), mc=10000)
bush.dukakis.diff <- posterior[,1] - posterior[,2]
cat("Pr(Bush > Dukakis): ",
   sum(bush.dukakis.diff > 0) / length(bush.dukakis.diff), "\n")
hist(bush.dukakis.diff)

## End(Not run)

MCMCpack

Markov Chain Monte Carlo (MCMC) Package

v1.5-0
GPL-3
Authors
Andrew D. Martin [aut], Kevin M. Quinn [aut], Jong Hee Park [aut,cre], Ghislain Vieilledent [ctb], Michael Malecki[ctb], Matthew Blackwell [ctb], Keith Poole [ctb], Craig Reed [ctb], Ben Goodrich [ctb], Ross Ihaka [cph], The R Development Core Team [cph], The R Foundation [cph], Pierre L'Ecuyer [cph], Makoto Matsumoto [cph], Takuji Nishimura [cph]
Initial release
2021-01-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.