validatr: Initialise validatr

Description Usage Arguments Details Value Examples

Description

Initialises a validatr object.

Usage

1
2
validatr(data, y, k = 10, ts = NULL, start = NULL, horizon = NULL,
  shift = NULL)

Arguments

data

data frame containing variables for modelling.

y

dependent variable name. Non-standard evaluation.

k

integer. Number of folds.

ts

time-series variable name. Non-standard evaluation.

start

numeric, date or POSIX object specifying the start date for time-series validation folds.

horizon

forecast horizon to evaluate.

shift

length of time to move forward for each new fold.

Details

The type of data being tested influences how the validatr and it's methods respond. The following types are supported:

The type of cross-validation and accuracy measures to be calculated are influenced by this parameter. For regression, k-fold cross-validation is carried out and requires the number of folds k to be specified. Leave one out cross-validation can easily be accomplished by setting k equal to the number of observations.

For time-series, time-series cross-validation takes place. This requires the start, horizon, shift and ts arguments to be specified:

If start is numeric, then horizon and shift are also numeric. If start is date or POSIX, then horizon and shift follow the same convention as for seq.Date and seq.POSIXt. Hence, they are a character string, containing one of "sec", "min", "hour", "day", "DSTday", "week", "month", "quarter" or "year".

Finally, classification carries out k-fold cross validation as well, but its accruacy measures will be different to regression.

Value

validatr returns an initial validatr object. This object contains cross validation folds and validation parameters.

Examples

1
2
3
validatr_obj <- validatr(iris, y = Sepal.Length, k = 5)
head(validatr_obj$folds[[5]]$train)
head(validatr_obj$folds[[5]]$validation)

camroach87/validatr documentation built on May 14, 2019, 2:41 p.m.