Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

criterion_methods

Registry for Criterion Methods


Description

A registry to manage methods to calculate a criterion value given data and a permutation.

Usage

list_criterion_methods(kind)
show_criterion_methods(kind)
get_criterion_method(kind, name)
set_criterion_method(kind, name, fun, description = NULL, merit = NA, ...)

Arguments

kind

the data type the method works on. For example, "dist", "matrix" or "array".

name

a short name for the method used to refer to the method in the function criterion().

fun

a function containing the method's code.

description

a description of the method. For example, a long name.

merit

a boolean indicating if the criterion measure is a merit (TRUE) or a loss (FALSE) measure.

...

further information that is stored for the method in the registry.

Details

All methods below are convenience methods for the registry named registry_criterion.

list_criterion_method() lists all available methods for a given data type (kind). The result is a vector of character strings with the short names of the methods.

show_criterion_method() shows all available methods for a given data type (kind) including a description.

get_criterion_method() returns information (including the implementing function) about a given method in form of an object of class "criterion_method".

With set_criterion_method() new criterion methods can be added by the user. The implementing function (fun) needs to have the formal arguments x, order, ..., where x is the data object, order is an object of class permutation_vector and ... can contain additional information for the method passed on from criterion(). The implementation has to return the criterion value as a scalar.

Author(s)

Michael Hahsler

Examples

## the registry
registry_criterion

## use the convenience functions
list_criterion_methods("dist")

show_criterion_methods("dist")

get_criterion_method("dist", "AR_d")

## define a new method

## a function that return sum of the diagonal elements
criterion_method_matrix_foo <- function(x, order, ...) {
if(!is.null(order)) x <- permute(x,order)
    sum(diag(x))
}

## set new method
set_criterion_method("matrix", "foo", criterion_method_matrix_foo, 
    "foo: a useless demo criterion", FALSE)

list_criterion_methods("matrix")

##use all criterion methods (including the new one)
criterion(matrix(1:9, ncol=3))

seriation

Infrastructure for Ordering Objects Using Seriation

v1.2-9
GPL-3
Authors
Michael Hahsler [aut, cre, cph], Christian Buchta [aut, cph], Kurt Hornik [aut, cph], Fionn Murtagh [ctb, cph], Michael Brusco [ctb, cph], Stephanie Stahl [ctb, cph], Hans-Friedrich Koehn [ctb, cph]
Initial release
2020-09-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.