Learn R Programming

fangs (version 0.2.21)

compute_loss: Compute the FARO Loss Between Feature Allocations

Description

The FARO loss is computed between two feature allocations, each represented in binary matrix form.

Usage

compute_loss(Z1, Z2, a = 1, augmented = FALSE)

Value

The FARO loss as a scalar value if augmented = FALSE, otherwise, a list of 3 elements including the loss and the two column permutations.

Arguments

Z1

A feature allocation in binary matrix form, with items in the rows and features in the columns.

Z2

A feature allocation in binary matrix form, with items in the rows and features in the columns.

a

A numeric scalar for the cost parameter of generalized Hamming distance used in FARO loss. The other cost parameter, \(b\), is equal to \(2 - a\).

augmented

If TRUE, the column permutation (used by FARO loss to compare the feature allocations) is returned for each matrix.

References

D. B. Dahl, D. J. Johnson, R. J. Andros (2023), Comparison and Bayesian Estimation of Feature Allocations, Journal of Computational and Graphical Statistics, tools:::Rd_expr_doi("10.1080/10618600.2023.2204136").

Examples

Run this code
Z1 <- matrix(c(0,1,1,0,1,1,0,1,1,1,1,1), byrow=TRUE, nrow=6)
Z2 <- matrix(c(0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0), byrow=TRUE, nrow=6)
compute_loss(Z1,Z2)
x <- compute_loss(Z1,Z2,a=1,TRUE)
sum(cbind(Z1,0) != Z2)
sum(cbind(Z1,0)[,x$permutation1] != Z2)
sum(cbind(Z1,0) != Z2[,x$permutation2])

Run the code above in your browser using DataLab