Learn R Programming

mdir (version 0.9.0)

callMixtureModel: Call mixture model

Description

Runs a MCMC chain of a Bayesian mixture model. Essentially a wrapper to allow more intuitive inputs for the single dataset case of MDI.

Usage

callMixtureModel(
  X,
  R,
  thin,
  type,
  K = 75,
  initial_labels = NULL,
  fixed = NULL,
  alpha = NULL,
  initial_labels_as_intended = FALSE,
  proposal_windows = NULL
)

Value

A named list containing the sampled partitions, component weights, and mass parameters, model fit measures and some details on the model call.

Arguments

X

Data to cluster. Matrix with the N items to cluster held in rows.

R

The number of iterations in the sampler.

thin

The factor by which the samples generated are thinned, e.g. if ``thin=50`` only every 50th sample is kept.

type

Character vector indicating density type to use. 'G' (Gaussian with diagonal covariance matrix) 'MVN' (multivariate normal), 'TAGM' (t-adjust Gaussian mixture), 'GP' (MVN with Gaussian process prior on the mean), 'TAGPM' (TAGM with GP prior on the mean), 'C' (categorical).

K

Integer indicating the number of components to include (the upper bound on the number of clusters).

initial_labels

Initial clustering. $N$-vector.

fixed

Which items are fixed in their initial label. $N$-vector.

alpha

The concentration parameter for the stick-breaking prior and the weights in the model.

initial_labels_as_intended

Logical indicating if the passed initial labels are as intended or should ``generateInitialLabels`` be called.

proposal_windows

List of the proposal windows for the Metropolis-Hastings sampling of Gaussian process hyperparameters. Each entry corresponds to a view. For views modelled using a Gaussian process, the first entry is the proposal window for the ampltiude, the second is for the length-scale and the third is for the noise. These are not used in other mixture types.

Examples

Run this code
N <- 100
X <- matrix(c(rnorm(N, 0, 1), rnorm(N, 3, 1)), ncol = 2, byrow = TRUE)

# This R is much too low for real applications
R <- 100
thin <- 5

alpha <- 1
K <- 10
type <- "MVN"

mcmc_out <- callMixtureModel(X, R, thin, type, K = K)

Run the code above in your browser using DataLab