Description Usage Arguments Value Examples
Creates a basic prior distribution for the clustering model, assuming a unit prior covariance matrix for clusters in each dataset.
1 2 | generatePrior(datasets, distributions = "diagNormal",
globalConcentration = 0.1, localConcentration = 0.1)
|
datasets |
List of data matrices where each matrix represents a context-specific dataset. Each data matrix has the size N times M, where N is the number of data points and M is the dimensionality of the data. The full list of matrices has length C. The number of data points N must be the same for all data matrices. |
distributions |
Distribution of data in each dataset. Can be either a list of
length C where |
globalConcentration |
Prior concentration parameter for the global clusters. Small values of this parameter give larger prior probability to smaller number of clusters. |
localConcentration |
Prior concentration parameter for the local context-specific clusters. Small values of this parameter give larger prior probability to smaller number of clusters. |
Returns the prior object that can be used as an input for the contextCluster
function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Example with simulated data (see vignette for details)
nContexts <- 2
# Number of elements in each cluster
groupCounts <- c(50, 10, 40, 60)
# Centers of clusters
means <- c(-1.5,1.5)
testData <- generateTestData_2D(groupCounts, means)
datasets <- testData$data
# Generate the prior
fullDataDistributions <- rep('diagNormal', nContexts)
prior <- generatePrior(datasets, fullDataDistributions, 0.01, 0.1)
# Fit the model
# 1. specify number of clusters
clusterCounts <- list(global=10, context=c(3,3))
# 2. Run inference
# Number of iterations is just for demonstration purposes, use
# a larger number of iterations in practice!
results <- contextCluster(datasets, clusterCounts,
maxIter = 10, burnin = 5, lag = 1,
dataDistributions = 'diagNormal', prior = prior,
verbose = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.