## the registry
registry_criterion
# List all criterion calculation methods by type
list_criterion_methods()
# List methods for matrix
list_criterion_methods("matrix")
# get more description
list_criterion_methods("matrix", names_only = FALSE)
# get a specific method
get_criterion_method(kind = "dist", name = "AR_d")
# Define a new method (sum of the diagonal elements)
## 1. implement a function to calculate the measure
criterion_method_matrix_foo <- function(x, order, ...) {
if(!is.null(order)) x <- permute(x,order)
sum(diag(x))
}
## 2. Register new method
set_criterion_method("matrix", "DiagSum", criterion_method_matrix_foo,
description = "Calculated the sum of all diagonal entries", merit = FALSE)
list_criterion_methods("matrix")
get_criterion_method("matrix", "DiagSum")
## 3. use all criterion methods (including the new one)
criterion(matrix(1:9, ncol = 3))
Run the code above in your browser using DataLab