Learn R Programming

viruslearner (version 0.0.2)

cd_fit: Fit and Evaluate Stacked Ensemble Model for CD4 Cell Count or Viral Load Outcome

Description

This function builds a stacked ensemble model using various preprocessing and modeling workflows.

Usage

cd_fit(
  outcome,
  traindata,
  viralvars,
  logbase,
  seed,
  repetitions,
  gridsize,
  testdata,
  predicted
)

Value

A tibble containing the root mean squared error (RMSE) and coefficient of determination (R2) metrics.

Arguments

outcome

The name of the outcome variable.

traindata

The training dataset used for building the ensemble.

viralvars

A vector of variable names representing viral variables.

logbase

The base for the logarithmic transformation in preprocessing.

seed

Seed for reproducibility.

repetitions

Number of repetitions for cross-validation.

gridsize

Number of grid points for hyperparameter tuning.

testdata

The test dataset for evaluating the ensemble.

predicted

Column name of the predicted variable in a regression tidy format.

Examples

Run this code
# \donttest{
library(baguette)
library(kernlab)
library(kknn)
library(ranger)
library(rules)
data("cd_train", package = "viruslearner")
data("cd_test", package = "viruslearner")
outcome <- "cd_2023"
traindata <- cd_train
viralvars <- c("vl_2019", "vl_2021", "vl_2022", "vl_2023")
logbase <- 10
seed <- 1501
repetitions <- 2
gridsize <- 1
testdata <- cd_test
predicted <- ".pred"
cd_fit(outcome, traindata, viralvars, logbase, seed, repetitions, gridsize, testdata, predicted)
# }

Run the code above in your browser using DataLab