gibbsnorm | R Documentation |
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.
gibbsnorm(niter, dat, mix)
niter |
number of iterations in the Gibbs sampler |
dat |
mixture sample |
mix |
list defined as |
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.
k |
number of components (superfluous) |
mu |
Gibbs sample of all mean parameters |
sig |
Gibbs sample of all variance parameters |
p |
Gibbs sample of all weight parameters |
lopost |
sequence of log-likelihood values along Gibbs iterations |
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.
rdirichlet
, gibbs
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.