Learn R Programming

salso (version 0.3.53)

psm: 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)\) element is one if and only if elements \(i\) and \(j\) in the partition have the same cluster label. If multiple samples are provided (as rows of the x matrix), this function computes the \(n\)-by-\(n\) matrix whose \((i,j)\) element gives the relative frequency (i.e., estimated probability) that items \(i\) and \(j\) 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)

Value

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

Arguments

x

A \(B\)-by-\(n\) matrix, where each of the \(B\) rows represents a clustering of \(n\) items using cluster labels. For the \(b\)th clustering, items \(i\) and \(j\) 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.

Examples

Run this code
# For examples, use 'nCores=1' per CRAN rules, but in practice omit this.
data(iris.clusterings)
partition <- iris.clusterings[1,]
psmatrix <- psm(partition, nCores=1)
psmatrix[1:6, 1:6]

dim(iris.clusterings)
probs <- psm(iris.clusterings, nCores=1)
dim(probs)
probs[1:6, 1:6]

Run the code above in your browser using DataLab