relabel_true_log: Relabel membership vector by minimizing KL-algorithm to true...

View source: R/RcppExports.R

relabel_true_logR Documentation

Relabel membership vector by minimizing KL-algorithm to true labels

Description

Relabels the membership vectors of a mixed membership model or mixed membership stochastic blockmodel, by minimizing the KL-divergence to a priori known true labels, where probabilities are entered on the log-scale.

Usage

relabel_true_log(
  lphi,
  lphi_true,
  renormalize = FALSE,
  nthreads = 0L,
  verbose = FALSE
)

Arguments

lphi

cube of length S, each slice of which is a matrix of dimension N times K, and where N is the number of individuals and K is the number of extreme types (or classes). Elements of lphi should be log-probabilities.

lphi_true

a N times K matrix containing the "true" values of latent-class/mixed-membership probabilities on the log-scale

renormalize

whether to renormalize the rows of lphi

nthreads

number of threads to use if OPENMP is enabled

verbose

if true, KL-divergence from true labels is calculated and printed before and after relabeling

Details

OpenMP is enabled if available. Due to overhead, the inner-most loop is parallelized only if the number of latent classes/types is larger than 3.

Value

Returns a Rcpp::List with two elements: 1) A arma::cube, permuted, of the same dimensions as phi but with the labels permuted; 2) perms is a S times K matrix containing the permutations necessary to produce permuted from phi (i.e., the mapping from phi to permuted)


baruuum/relabelKL documentation built on Feb. 1, 2024, 12:23 a.m.