cv_model: Fit a 'cv_model'

Description Usage Arguments Details Value Examples

View source: R/cv-model-fit.R

Description

cv_model() fits a model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
cv_model(x, ...)

## Default S3 method:
cv_model(x, ...)

## S3 method for class 'data.frame'
cv_model(x, y, intercept = TRUE, ...)

## S3 method for class 'matrix'
cv_model(x, y, intercept = TRUE, ...)

## S3 method for class 'formula'
cv_model(formula, data, intercept = TRUE, ...)

## S3 method for class 'recipe'
cv_model(x, data, intercept = TRUE, ...)

Arguments

x

Depending on the context:

  • A data frame of predictors.

  • A matrix of predictors.

  • A recipe specifying a set of preprocessing steps created from recipes::recipe().

...

See Details

y

When x is a data frame or matrix, y is the outcome specified as:

  • A data frame with 1 numeric column.

  • A matrix with 1 numeric column.

  • A numeric vector.

intercept

Should intercept column be created? Default is TRUE.

formula

A formula specifying the outcome terms on the left-hand side, and the predictor terms on the right-hand side.

data

When a recipe or formula is used, data is specified as:

  • A data frame containing both the predictors and the outcome.

Details

Extra parameters using ... are forwarded to implementation function. These parameters are the following:

model_func

Model function. Default is lm_model. See also baseline_model

predict_func

Predict function. Default is generic_predict

perf_func

Model performance function. Default is performance_metrics

SESOI_lower

Function or numeric scalar. Default is SESOI_lower_func

SESOI_upper

Function or numeric scalar. Default is SESOI_upper_func

control

Control structure using model_control. The parameters used in cv_model are cv_folds, and cv_strata

na.rm

Should NAs be removed? Default is FALSE. This is forwarded to model_func, predict_func, perfr_func, SESOI_lower, and SESOI_upper

In summary, cv_model represents a wrapper function, that performs model_func within the cross-validation loop and provide it's predictive performance metrics using perf_func

Value

A bmbstats_cv_model object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data("vertical_jump_data")

m1 <- cv_model(
  `Post-test` ~ `Pre-test` * Group * `Squat 1RM`,
  vertical_jump_data,
  control = model_control(
    cv_repeats = 10,
    cv_folds = 3,
    cv_strata = vertical_jump_data$Group
  )
)

m1
plot(m1, "residuals")

mladenjovanovic/bmbstats documentation built on Aug. 5, 2020, 4:20 p.m.