DualCP_LOSO: Perform leave-one-participant-out-cross-validation on a...

View source: R/summary_2rm_helpers.R

DualCP_LOSOR Documentation

Perform leave-one-participant-out-cross-validation on a two-regression algorithm

Description

Perform leave-one-participant-out-cross-validation on a two-regression algorithm

Usage

DualCP_LOSO(
  subject_var = "id",
  data,
  model,
  MET_var = "MET_RMR",
  activity_var = "Behavior",
  verbose = FALSE,
  trace = FALSE
)

fold(x, subject_var, data, model, MET_var, activity_var, trace)

get_cv_predictions(model, fold_data, cv_data)

get_fold_model(formula_string, fold_data, level = c("walkrun", "intermittent"))

get_classifications(
  data,
  model,
  numeric = TRUE,
  labels = c("SB", "walkrun", "intermittent")
)

Arguments

subject_var

character. Variable name that distinguishes between participants

data

the full data set to cross-validate

model

a TwoRegression object formed with fit_2rm on which to perform the cross-validation

MET_var

character. The outcome variable name (in metabolic equivalents)

activity_var

character. The variable name for the activity being performed

verbose

logical. Print updates?

trace

logical. Print information about each iteration?

x

character. The id to hold out

fold_data

the validation data set

cv_data

the holdout (i.e., cross-validation) data set

formula_string

character. Formula to apply in call to lm

level

character. Classification subset to include in call to lm

Value

A data frame with predictions obtained from leave-one-participant-out-cross-validation

Note

This function will not work for TwoRegression objects formed from previously-published research. The TwoRegression object needs to have more information than is available in those cases in order to perform cross-validation, and this is sensible, since there is no reason or way to re-perform cross-validation on an already-finalized algorithm.


TwoRegression documentation built on Sept. 5, 2022, 9:07 a.m.