posteriorSimulation-method: Run MCMC simulation.

Description Usage Arguments Value See Also Examples

Description

nStarts chains are run. b burnin iterations are run and then discarded. Next, s iterations are run in each train. The user can also specify an alternative number of components. The mode of the MCMC simulation is also calculated.

Usage

1
2
3
4
5
6
7
posteriorSimulation(object, k)

## S4 method for signature 'MixtureModel'
posteriorSimulation(object)

## S4 method for signature 'TrioBatchModel'
posteriorSimulation(object)

Arguments

object

see showMethods(posteriorSimulation)

k

The number of a priori components. This is optional and if not specified, the stored k model components are used. This parameters is useful for running multiple models of varying components.

Value

An object of class 'MarginalModel' or 'BatchModel'

See Also

ggChains for diagnosing convergence. See ggMixture for plotting the model-based densities.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Fit model with pre-specified number of components (k=3)
set.seed(123)
## specify small number of iterations so that the example runs quickly
mp <- McmcParams(iter=2, burnin=0, nStarts=3)
sb <- SingleBatchModelExample
mcmcParams(sb) <- mp
posteriorSimulation(sb)

# Run additional iterations, but set nStart = 0 so that the last value of the
# chain is the first value of the next chain
mcmcParams(sb) <- McmcParams(iter=5, nStarts=0, burnin=0)
posteriorSimulation(sb)

# Fit batch models of different sizes (k=1 and 2)
mb <- MultiBatchModelExample
mcmcParams(mb) <- mp
yy <- sample(y(mb), 300)
batches <- rep(1:3, length.out=length(yy))
mp <- McmcParams(iter=1000, burnin=500, thin=1, nStarts=4)
## Not run: 
  mlist <- gibbs(model="MB", k_range=c(1, 2), dat=yy, batches=batches)

## End(Not run)

CNPBayes documentation built on May 6, 2019, 4:06 a.m.