Learn R Programming

bayess (version 1.4)

gibbsmean: Gibbs sampler on a mixture posterior distribution with unknown means

Description

This function implements a Gibbs sampler for a toy mixture problem (Chapter 6) with two Gaussian components and only the means unknown, so that likelihood and posterior surfaces can be drawn.

Usage

gibbsmean(p, datha, niter = 10^4)

Arguments

p
first component weight
datha
dataset to be modelled as a mixture
niter
number of Gibbs iterations

Value

Sample of $mu$'s as a matrix of size niter x 2

See Also

plotmix

Examples

Run this code
dat=plotmix(plottin=FALSE)$sample
simu=gibbsmean(0.7,dat,niter=100)
plot(simu,pch=19,cex=.5,col="sienna",xlab=expression(mu[1]),ylab=expression(mu[2]))

Run the code above in your browser using DataLab