continueChain {batchmix}R Documentation

Continue chain

Description

Continues sampling from a previous position for a given chain.

Usage

continueChain(mcmc_output, X, fixed, batch_vec, R, keep_old_samples = TRUE)

Arguments

mcmc_output

Chain to be continued.

X

Data to cluster as a matrix with the items to cluster held in rows.

fixed

The indicator vector for which labels are observed.

batch_vec

The vector of the batch labels for the data.

R

The number of iterations to run in this continuation (thinning factor is the same as initial chain).

keep_old_samples

Logical indicating if the original samples should be kept or only the new samples returned. Defaults to TRUE.

Value

A named list containing the sampled partitions, cluster and batch parameters, model fit measures and some details on the model call.

Examples


# Data in a matrix format
X <- matrix(c(rnorm(100, 0, 1), rnorm(100, 3, 1)), ncol = 2, byrow = TRUE)

# Initial labelling
labels <- c(
  rep(1, 10),
  sample(c(1, 2), size = 40, replace = TRUE),
  rep(2, 10),
  sample(c(1, 2), size = 40, replace = TRUE)
)

fixed <- c(rep(1, 10), rep(0, 40), rep(1, 10), rep(0, 40))

# Batch
batch_vec <- sample(seq(1, 5), replace = TRUE, size = 100)

# Density choice
type <- "MVT"

# Sampling parameters
R <- 1000
thin <- 50

# MCMC samples and BIC vector
mcmc_output <- runBatchMix(
  X,
  R,
  thin,
  batch_vec,
  type,
  initial_labels = labels,
  fixed = fixed
)

# Given an initial value for the parameters
mcmc_output <- continueChain(
  mcmc_output,
  X,
  fixed,
  batch_vec,
  R,
)


[Package batchmix version 2.1.0 Index]