Computes the total loss across all pairwise combinations of rows in a matrix.
Arguments
- x
A numeric vector, matrix, or data frame. If not a matrix, it will be coerced to one after applying the transformation function.
- fun
A function to compute the loss for each pairwise difference. The package supports the alignment loss (
alf) and the approximate L0 penalty (l0a), but users can provide custom functions as well.- trans
A transformation function to apply to
xbefore computing pairwise differences. Default isidentity(no transformation).- rescale
Either
"df"(default) to rescale the total loss by the degrees of freedom (number of rows - 1), or a numeric value (likely between 0 and 1) to multiply the total loss by.- ...
Additional arguments passed to the loss function
fun.
Details
The function works by:
Applying the transformation function
transto the inputxConverting the result to a matrix
Generating all possible pairwise combinations of row indices
Computing the difference between each pair of rows
Applying the loss function
funto each differenceSumming all the individual losses