View source: R/PrognosticModel.R
PrognosticModel | R Documentation |
This function prepares the data, splits it into training and testing sets, and then fits LASSO and Ridge regression models using the 'glmnet' package. It evaluates these models by calculating prognostic results and optionally plots ROC curves for each model. It is specifically tailored for survival analysis.
PrognosticModel(
x,
y,
scale = FALSE,
seed = 123456,
train_ratio = 0.7,
nfold = 10,
plot = TRUE,
palette = "jama",
cols = NULL
)
x |
A matrix or data frame of predictor variables. |
y |
A vector or data frame of survival outcomes, typically including time and status |
scale |
Logical, if TRUE, scales the predictor variables. |
seed |
Integer, a seed for random number generation to ensure reproducibility. |
train_ratio |
Numeric, the proportion of the data to use for training, e.g., 0.7 for 70 percent |
nfold |
Integer, the number of folds for cross-validation in model fitting. |
plot |
Logical, if TRUE, plots the ROC curves for the LASSO and Ridge models. |
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 from the LASSO and Ridge regression models, the training data, and optionally, the combined plot of ROC curves if 'plot' is TRUE.
data("imvigor210_sig", package = "IOBR")
data("imvigor210_pdata",package = "IOBR")
pdata_prog <- imvigor210_pdata %>% dplyr::select(ID, OS_days, OS_status) %>% mutate(OS_days = as.numeric(.$OS_days)) %>% mutate(OS_status = as.numeric(.$OS_status))
prognostic_result <- PrognosticModel(x = imvigor210_sig, y = pdata_prog, scale = T, seed = 123456, 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.