psm {salso}R Documentation

Compute an Adjacency or Pairwise Similarity Matrix

Description

If only one sample is provided, this function computes an adjacency matrix, i.e., a binary matrix whose (i,j)(i,j) element is one if and only if elements ii and jj in the partition have the same cluster label. If multiple samples are provided (as rows of the x matrix), this function computes the nn-by-nn matrix whose (i,j)(i,j) element gives the relative frequency (i.e., estimated probability) that items ii and jj are in the same subset (i.e., cluster). This is the mean of the adjacency matrices of the provided samples.

Usage

psm(x, nCores = 0)

Arguments

x

A BB-by-nn matrix, where each of the BB rows represents a clustering of nn items using cluster labels. For the bbth clustering, items ii and jj are in the same cluster if x[b,i] == x[b,j].

nCores

The number of CPU cores to use, i.e., the number of simultaneous runs at any given time. A value of zero indicates to use all cores on the system.

Value

A nn-by-nn symmetric matrix whose (i,j)(i,j) element gives the relative frequency that that items ii and jj are in the same subset (i.e., cluster).

Examples

# For examples, use 'nCores=1' per CRAN rules, but in practice omit this.
data(iris.clusterings)
partition <- iris.clusterings[1,]
# R_CARGO \dontrun{
# R_CARGO # Example disabled since Cargo was not found when installing from source package.
# R_CARGO # You can still run the example if you install Cargo. Hint: cargo::install().
psm(partition, nCores=1)
# R_CARGO }

dim(iris.clusterings)
# R_CARGO \dontrun{
# R_CARGO # Example disabled since Cargo was not found when installing from source package.
# R_CARGO # You can still run the example if you install Cargo. Hint: cargo::install().
probs <- psm(iris.clusterings, nCores=1)
dim(probs)
probs[1:6, 1:6]
# R_CARGO }


[Package salso version 0.3.35 Index]