BinomialModel: Binomial Model Construction

View source: R/BinomialModel.R

BinomialModelR Documentation

Binomial Model Construction

Description

Constructs and evaluates binomial logistic regression models using Lasso and Ridge regularization. This function processes the input data, scales features if specified, splits the data into training and testing sets based on a provided ratio, and then fits both Lasso and Ridge models. It optionally generates AUC plots for model evaluation. The results, along with the training dataset, are returned.

Usage

BinomialModel(
  x,
  y,
  seed = 123456,
  scale = TRUE,
  train_ratio = 0.7,
  nfold = 10,
  plot = TRUE,
  palette = "jama",
  cols = NULL
)

Arguments

x

A data.frame containing the sample ID and features, the first column must be the sample ID.

y

A data.frame where the first column is the sample ID and the second column is the outcome of each sample, which can be either numeric or a factor vector.

seed

An integer used to set the seed for random operations, default is 123456.

scale

A logical indicating whether the feature data 'x' should be scaled, default is TRUE.

train_ratio

A numeric value between 0 and 1 specifying the proportion of the dataset to be used for training, e.g., 0.7 means 70 percent of the data is used for training.

nfold

The number of folds to use for cross-validation in model fitting, default is 10.

plot

A logical indicating whether to generate and display AUC plots, default is TRUE.

palette

Optional, a string specifying the color palette. Default is "jama", which is applied if 'cols' is NULL.

cols

Optional, a vector of colors for the ROC curves. If NULL, default color palettes are applied based on the 'palette' parameter.

Value

A list containing the results of the Lasso and Ridge models, and the input training data. The list includes elements 'lasso_result', 'ridge_result', and 'train.x'.

Examples

data("imvigor210_sig", package = "IOBR")
data("imvigor210_pdata",package = "IOBR")
pdata_group <- imvigor210_pdata[imvigor210_pdata$BOR_binary!="NA", c("ID","BOR_binary")]
pdata_group$BOR_binary <- ifelse(pdata_group$BOR_binary == "R", 1, 0)
BinomialModel(x = imvigor210_sig, y = pdata_group, seed = 123456, scale = TRUE, train_ratio = 0.7, nfold = 10, plot = T)

IOBR/IOBR documentation built on Nov. 13, 2024, 5:22 a.m.