Learn R Programming

bayess (version 1.4)

gibbsnorm: Gibbs sampler for a generic mixture posterior distribution

Description

This function implements the generic Gibbs sampler of Diebolt and Robert (1994) for producing a sample from the posterior distribution associated with a univariate mixture of $k$ normal components with all $3k-1$ parameters unknown.

Usage

gibbsnorm(niter, dat, mix)

Arguments

niter
number of iterations in the Gibbs sampler
dat
mixture sample
mix
list defined as mix=list(k=k,p=p,mu=mu,sig=sig), where k is an integer and the remaining entries are vectors of length k

Value

  • knumber of components (superfluous)
  • muGibbs sample of all mean parameters
  • sigGibbs sample of all variance parameters
  • pGibbs sample of all weight parameters
  • lopostsequence of log-likelihood values along Gibbs iterations

Details

Under conjugate priors on the means (normal distributions), variances (inverse gamma distributions), and weights (Dirichlet distribution), the full conditional distributions given the latent variables are directly available and can be used in a straightforward Gibbs sampler. This function is only the first step of the function gibbs, but it may be much faster as it avoids the computation of the evidence via Chib's approach.

References

Chib, S. (1995) Marginal likelihood from the Gibbs output.J. American Statist. Associ. 90, 1313-1321.

Diebolt, J. and Robert, C.P. (1992) Estimation of finite mixture distributions by Bayesian sampling. J. Royal Statist. Society 56, 363-375.

See Also

rdirichlet, gibbs

Examples

Run this code
data(datha)
datha=as.matrix(datha)
mix=list(k=3,mu=mean(datha),sig=var(datha))
res=gibbsnorm(10,datha,mix)
plot(res$p[,1],type="l",col="steelblue3",xlab="iterations",ylab="p")

Run the code above in your browser using DataLab