cv_core {stressor} | R Documentation |
Cross Validation Function
Description
This is the machinery to run cross validation. It subsets the test and train set based on the groups it receives.
Usage
cv_core(object, data, t_groups, ...)
Arguments
object |
Currently '"reg_sine", "reg_asym", "lm", "mlm_stressor"' objects are accepted. |
data |
A data.frame object that has the same formula that was fitted on the data. |
t_groups |
The groups for cross validation: standard cross validation, LOO cross_validation, or spatial cross validation. |
... |
Additional arguments that are passed to the predict function. |
Value
Either a vector of predictions for '"reg_sine", "reg_asym", "lm"' and a data frame for '"mlm_stressor"'.
Examples
# lm example
lm_test <- data_gen_lm(20)
lm <- lm(Y ~ ., lm_test)
cv(lm, lm_test, n_folds = 2)
lm_test <- data_gen_lm(20)
create_virtualenv()
mlm_lm <- mlm_regressor(Y ~ ., lm_test)
cv(mlm_lm, lm_test, n_folds = 2)
# Asymptotic example
asym_data <- data_gen_asym(10)
asym_fit <- reg_asym(Y ~ ., asym_data)
cv(asym_fit, asym_data, n_folds = 2)
# Sine example
sine_data <- data_gen_sine(10)
sine_fit <- reg_sine(Y ~ ., sine_data)
cv(sine_fit, sine_data, n_folds = 2)
[Package stressor version 0.2.0 Index]