partition_factor_cv
creates a represampling object,
i.e. a set of sample indices defining cross-validation test and
training sets, where partitions are obtained by resampling at the level of
groups of observations as defined by a given factor variable.
This can be used, for example, to resample agricultural data that is grouped
by fields, at the agricultural field level in order to preserve
spatial autocorrelation within fields.
partition_factor_cv(data, coords = c("x", "y"), fac, nfold = 10, repetition = 1, seed1 = NULL, return_factor = FALSE)
data |
|
---|---|
coords | vector of length 2 defining the variables in |
fac | either the name of a variable (column) in |
nfold | number of partitions (folds) in |
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 |
seed1 |
|
return_factor | if |
A represampling object, see also partition_cv for details.
In this partitioning approach, the number of factor levels in
fac
must be large enough for this factor-level resampling to make
sense.
sperrorest, partition_cv, partition_factor, as.resampling.factor