# 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)
# Sampling parameters
R <- 500
thin <- 10
n_chains <- 4
# MCMC samples and BIC vector
mcmc_lst <- runMCMCChains(X, n_chains, R, thin, batch_vec, "MVN",
initial_labels = labels,
fixed = fixed
)
# Plot the acceptance rate of each parameter in the 4 chains
plotAcceptanceRates(mcmc_lst)
Run the code above in your browser using DataLab