View source: R/BinomialModel.R
BinomialModel | R Documentation |
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.
BinomialModel(
x,
y,
seed = 123456,
scale = TRUE,
train_ratio = 0.7,
nfold = 10,
plot = TRUE,
palette = "jama",
cols = NULL
)
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. |
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'.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.