add.distance: Add distance information to resampling objects

Description Usage Arguments Details Value See Also Examples

View source: R/sperrorest_misc.R

Description

Add distance information to resampling objects

Usage

1
2
3
4
5
6
7
add.distance(object, ...)

## S3 method for class 'resampling'
add.distance(object, data, coords = c("x", "y"), ...)

## S3 method for class 'represampling'
add.distance(object, ...)

Arguments

object

resampling or represampling object.

...

Additional arguments to dataset_distance and add.distance.resampling, respectively.

data

data.frame containing at least the columns specified by coords

coords

(ignored by partition_cv)

Details

Nearest-neighbour distances are calculated for each sample in the test set. These nrow(???$test) nearest-neighbour distances are then averaged. Aggregation methods other than mean can be chosen using the fun argument, which will be passed on to dataset_distance.

Value

A resampling or represampling object containing an additional. $distance component in each resampling object. The distance component is a single numeric value indicating, for each train / test pair, the (by default, mean) nearest-neighbour distance between the two sets.

See Also

dataset_distance represampling resampling

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(ecuador) # Muenchow et al. (2012), see ?ecuador
nsp.parti <- partition_cv(ecuador)
sp.parti <- partition_kmeans(ecuador)
nsp.parti <- add.distance(nsp.parti, ecuador)
sp.parti <- add.distance(sp.parti, ecuador)
# non-spatial partioning: very small test-training distance:
nsp.parti[[1]][[1]]$distance
# spatial partitioning: more substantial distance, depending on number of
# folds etc.
sp.parti[[1]][[1]]$distance

sperrorest documentation built on April 1, 2018, 12:27 p.m.