Create cross-validation training data sets.
create_folds.RdCreates 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
NAin 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:
dataThe training data set with left-out entries.held_outThe indices of all held-out regions.predict_onThe 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