en_kfold_model: en_kfold_model function

View source: R/enr functions.R

en_kfold_modelR Documentation

en_kfold_model function

Description

run kfold cross validated enr models (DOCUMENTATION COMING- CURRENT DOCUMENTATION INCORRECT)

Usage

en_kfold_model(
  ddata,
  response_var,
  iter = 10,
  k = 10,
  num_alpha = 20,
  seed = 123,
  fit_met = "accuracy",
  loo = FALSE,
  up_dn_samp = "none",
  eq_wt = FALSE,
  type_meas = "deviance",
  na_rm = TRUE,
  lr_cutoff = c(0.5),
  accuracy_modeling = FALSE
)

Arguments

ddata

data frame containing the data to be modeled

response_var

string identifying the name of the outcome variable

iter

the number of iterations to use

k

the number of folds to use

num_alpha

an integer of the number of alphas to consider. this will be split across 0 to 1. for example if '5' is given then alphas will go from 0 to 1 and will be num_alpha/iteration (i.e. 0, .2, .4, .6, .8, 1)

seed

the seed value for allowing results to be reproduced

fit_met

string indicating the fit metric to be used to evaluate model performance. options are c(accuracy, auroc, logloss, f1, ppv, npv, sens, spec, bal_acc)

loo

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

up_dn_samp

string indicating whether unbalanced classes should be balanced by having the smaller class upsampled to be the same size as the larger class or vice versa. can take the form 'upsamp', 'downsamp', and 'none' (default)

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

na_rm

boolean indicating whether missing values should be removed. default is TRUE

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

accuracy_modeling

switch determining if we need to break ties between optimal solutions

Examples

en_kfold_model()

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