Create cross-validation training data sets.
create_folds.Rd
Creates a list of training datasets each of which has certain entries of
remove_cols
replaced by NA
according to the type
of cross-validation.
If type = "LOO"
one entry of each training dataset is replaced by NA
,
if type = "SLOO"
one entry and the entries of the neighbours of the area
it corresponds to are replaced by NA
.
Usage
create_folds(sf, remove_cols = c("y"), type = "LOO")
Arguments
- sf
A simple features object with some geometry.
- remove_cols
A vector of named columns which are to have entries replaced by
NA
in the training data sets. Defaults toc("y")
.- type
One of
"LOO"
or"SLOO"
.
Value
A list of nrow(sf)
training set lists.
Each training set list contains:
data
The training data set with left-out entries.held_out
The indices of all held-out regions.predict_on
The indices of regions to be predicted upon.
Examples
create_folds(mw, remove_cols = c("y", "est"))
#> Error in remove_cols %in% names(sf): object 'mw' not found