partition_factor: Partition the data for a (non-spatial) leave-one-factor-out...

Description Usage Arguments Value Note See Also Examples

View source: R/sperrorest_resampling.R

Description

partition_factor creates a represampling object, i.e. a set of sample indices defining cross-validation test and training sets.

Usage

1
2
partition_factor(data, coords = c("x", "y"), fac, return_factor = FALSE,
  repetition = 1)

Arguments

data

data.frame containing at least the columns specified by coords

coords

vector of length 2 defining the variables in data that contain the x and y coordinates of sample locations.

fac

either the name of a variable (column) in data, or a vector of type factor and length nrow(data) that contains the partitions to be used for defining training and test samples.

return_factor

if FALSE (default), return a represampling object; if TRUE (used internally by other sperrorest functions), return a list containing factor vectors (see Value)

repetition

numeric vector: cross-validation repetitions to be generated. Note that this is not the number of repetitions, but the indices of these repetitions. E.g., use repetition = c(1:100) to obtain (the 'first') 100 repetitions, and repetition = c(101:200) to obtain a different set of 100 repetitions.

Value

A represampling object, see also partition_cv for details.

Note

In this partitioning approach, all repetitions are identical and therefore pseudo-replications.

See Also

sperrorest, partition_cv, as.resampling.factor

Examples

1
2
3
4
5
6
7
8
9
data(ecuador)
# I don't recommend using this partitioning for cross-validation,
# this is only for demonstration purposes:
breaks <- quantile(ecuador$dem, seq(0, 1, length = 6))
ecuador$zclass <- cut(ecuador$dem, breaks, include.lowest = TRUE)
summary(ecuador$zclass)
parti <- partition_factor(ecuador, fac = 'zclass')
# plot(parti,ecuador)
summary(parti)

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