Folds | R Documentation |
Generates a list of n_folds
non-overlapping sets of observation IDs
(folds).
Folds(data, family = NULL, n_folds = 5)
data |
vector or matrix of data. In regression, this should be the outcome data. |
family |
type of regression model. This argument is defined as in
|
n_folds |
number of folds. |
For categorical outcomes (i.e. family
argument is set to
"binomial"
, "multinomial"
or "cox"
), the split is done
such that the proportion of observations from each of the categories in
each of the folds is representative of that of the full sample.
A list of length n_folds
with sets of non-overlapping
observation IDs.
# Splitting into 5 folds
simul <- SimulateRegression()
ids <- Folds(data = simul$ydata)
lapply(ids, length)
# Balanced folds with respect to a binary variable
simul <- SimulateRegression(family = "binomial")
ids <- Folds(data = simul$ydata, family = "binomial")
lapply(ids, FUN = function(x) {
table(simul$ydata[x, ])
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.