get_loo_fun {xnet}R Documentation

Retrieve a loo function

Description

This function returns the correct function needed to perform one of the leave-one-out cross-validations. It's primarily meant for internal use but can be useful when doing simulations.

Usage

get_loo_fun(x, ...)

## S4 method for signature 'tskrrHeterogeneous'
get_loo_fun(
  x,
  exclusion = c("interaction", "row", "column", "both"),
  replaceby0 = FALSE
)

## S4 method for signature 'tskrrHomogeneous'
get_loo_fun(
  x,
  exclusion = c("edges", "vertices", "interaction", "both"),
  replaceby0 = FALSE
)

## S4 method for signature 'linearFilter'
get_loo_fun(x, replaceby0 = FALSE)

## S4 method for signature 'character'
get_loo_fun(
  x = c("tskrrHeterogeneous", "tskrrHomogeneous", "linearFilter"),
  ...
)

## S4 method for signature 'tskrrTune'
get_loo_fun(x, ...)

Arguments

x

a character value with the class or a tskrr or linearFilter object.

...

arguments passed to or from other methods.

exclusion

a character value with possible values "interaction", "row", "column", "both" for heterogeneous models, and "edges", "vertices", "interaction" or "both" for homogeneous models. Defaults to "interaction". See details.

replaceby0

a logical value indicating whether the interaction should be simply removed (FALSE) or replaced by 0 (TRUE).

Details

This function can be used to select the correct loo function in a simulation or tuning algorithm, based on the model object you created. Depending on its class, the returned functions will have different arguments, so you should only use this if you know what you're doing and after you checked the actual returned functions in loo_internal.

Using replaceby0 only makes sense if you only remove the interaction. In all other cases, this argument is ignored.

For the class tskrrHomogeneous, it doesn't make sense to remove rows or columns. If you chose this option, the function will throw an error. Removing edges corresponds to the setting "edges" or "interaction". Removing vertices corresponds to the setting "vertices" or "both". These terms can be used interchangeably.

For the class linearFilter it only makes sense to exclude the interaction (i.e., a single cell). Therefore you do not have an argument exclusion for that method.

For the classes tskrrTune and tskrrImpute, not specifying exclusion or replaceby0 returns the used loo function. If you specify either of them, it will use the method for the appropriate model and return a new loo function.

Value

a function taking the arguments y, and possibly pred for calculating the leave-one-out cross-validation. For class tskrrHeterogeneous, the returned function also has an argument Hk and Hg, representing the hat matrix for the rows and the columns respectively. For class tskrrHomogeneous, only the extra argument Hk is available. For class linearFilter, the extra argument is called alpha and takes the alpha vector of that model.

See Also

loo for carrying out a leave on out crossvalidation, and loo_internal for more information on the internal functions one retrieves with this one.


[Package xnet version 0.1.11 Index]