posteriorSimulation {CNPBayes} | R Documentation |
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.
posteriorSimulation(object, k) ## S4 method for signature 'MixtureModel' posteriorSimulation(object) ## S4 method for signature 'TrioBatchModel' posteriorSimulation(object)
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. |
An object of class 'MarginalModel' or 'BatchModel'
ggChains
for diagnosing convergence. See ggMixture
for plotting the model-based densities.
# 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)