% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/PrognosticModel.R
\name{PrognosticModel}
\alias{PrognosticModel}
\title{Build Prognostic Models Using LASSO and Ridge Regression}
\usage{
PrognosticModel(
  x,
  y,
  scale = FALSE,
  seed = 123456,
  train_ratio = 0.7,
  nfold = 10,
  plot = TRUE,
  palette = "jama",
  cols = NULL
)
}
\arguments{
\item{x}{A matrix or data frame of predictor variables (features).}

\item{y}{A data frame of survival outcomes with two columns: survival time and event status.}

\item{scale}{Logical indicating whether to scale predictor variables. Default is `FALSE`.}

\item{seed}{Integer seed for random number generation to ensure reproducibility.
Default is `123456`.}

\item{train_ratio}{Numeric proportion of data for training (e.g., 0.7). Default is `0.7`.}

\item{nfold}{Integer number of folds for cross-validation. Default is `10`.}

\item{plot}{Logical indicating whether to plot ROC curves. Default is `TRUE`.}

\item{palette}{String specifying color palette. Default is `"jama"`.}

\item{cols}{Optional vector of colors for ROC curves. If `NULL`, uses default palette.}
}
\value{
A list containing:
\describe{
  \item{lasso_result}{Results from LASSO model including coefficients and AUC}
  \item{ridge_result}{Results from Ridge model including coefficients and AUC}
  \item{train.x}{Training data with sample IDs}
}
}
\description{
Prepares data, splits it into training and testing sets, and fits LASSO and Ridge
regression models for survival analysis. Evaluates model performance using
cross-validation and optionally generates time-dependent ROC curves for visual
assessment of predictive accuracy.
}
\examples{
if (requireNamespace("glmnet", quietly = TRUE) &&
  requireNamespace("survival", quietly = TRUE)) {
  library(survival)
  set.seed(123)
  # Create small example data (first column must be ID)
  x_sim <- as.data.frame(matrix(rnorm(100 * 5), 100, 5))
  colnames(x_sim) <- paste0("Sig", 1:5)
  x_sim$ID <- paste0("S", 1:100)
  x_sim <- x_sim[, c(6, 1:5)] # Move ID to first column

  y_sim <- data.frame(
    ID = paste0("S", 1:100),
    OS_days = rexp(100, 0.01),
    OS_status = rbinom(100, 1, 0.5)
  )
  prognostic_result <- PrognosticModel(
    x = x_sim, y = y_sim,
    scale = TRUE, seed = 123456,
    train_ratio = 0.7, nfold = 3, plot = FALSE
  )
  if (!is.null(prognostic_result)) head(prognostic_result)
}
}
\author{
Dongqiang Zeng
}
