en_kfold_accuracy: en_kfold_accuracy function

View source: R/enr functions.R

en_kfold_accuracyR Documentation

en_kfold_accuracy function

Description

This function calculates the cross validated accuracy of an enr model

Usage

en_kfold_accuracy(
  ddata,
  response_var,
  mod_alpha,
  mod_lambda = NULL,
  iter = 100,
  k = 10,
  seed = 123,
  loo = FALSE,
  eq_wt = FALSE,
  type_meas = "deviance",
  lr_cutoff = c(0.5)
)

Arguments

ddata

data frame containing the data to be modeled

response_var

string identifying the name of the outcome variable

mod_alpha

the alpha(s) value(s) to be checked. alpha is the ENR blending parameter that governs how much ridge regression (0) and lasso regression (1) will be used.

mod_lambda

the lambda(s) to be checked. lambda is the ENR penalty parameter for the ridge portion of the ENR

iter

the number of iterations to use

k

the number of folds to use

seed

the seed value for allowing results to be reproduced

loo

boolean indicating whether 'leave one out' cross validation should be used

eq_wt

boolean indicating whether the 0/1 classes should be balanced with weights. you may want to use this if there is a bad class imbalance

type_meas

the 'type measure' which is passed to cv.glmnet that governs its training penalty when tuning lambda. this should match arguments expected in cv.glmnet

lr_cutoff

vetor of cutoff values to test/tune for optimization. the default is 'c(.5)' which is to say 'equal distance from all classes' which is typical in standard analyses

Examples

en_kfold_accuracy()

clmacleod/highlandr documentation built on April 17, 2025, 3:30 a.m.