opt_colpermB: Get optimal column permutation of a matrix B to match the...

View source: R/simulate.R

opt_colpermBR Documentation

Get optimal column permutation of a matrix B to match the matrix A

Description

Useful in simulations where the posterior sampling relabels the classes, which is equivalent and cannot be told apart by the likelihood only.

Usage

opt_colpermB(A, B)

Arguments

A

a matrix (e.g., truth)

B

another matrix (e.g., estimated); A and B must have the same dimensions; B's columns may be permutated to best match those of A.

Value

a permutation of columns of B (represented by a permuted 1:ncol(A))

Examples


A <- matrix(c(1,2,3,4,5,6),nrow=2,ncol=3)
B <- A[,c(2,1,3)]
opt_colpermB(A,B) # should expect c(2,1,3)

zhenkewu/lotR documentation built on April 24, 2022, 2:36 a.m.