cvl_tramnet: Cross-validating tramnet models

View source: R/cvl_tramnet.R

cvl_tramnetR Documentation

Cross-validating tramnet models

Description

k-fold cross validation for "tramnet" objects over a grid of the tuning parameters based on out-of-sample log-likelihood.

Usage

cvl_tramnet(
  object,
  fold = 2,
  lambda = 0,
  alpha = 0,
  folds = NULL,
  fit_opt = FALSE
)

Arguments

object

Object of class "tramnet".

fold

Number of folds for cross validation.

lambda

Values for lambda to iterate over.

alpha

Values for alpha to iterate over.

folds

Manually specify folds for comparison with other methods.

fit_opt

If TRUE, returns the full model evaluated at optimal hyper-parameters

Value

Returns out-of-sample logLik and coefficient estimates for corresponding folds and values of the hyper-parameters as an object of class "cvl_tramnet"

Examples


set.seed(241068)
if (require("survival") & require("TH.data")) {
  data("GBSG2", package = "TH.data")
  X <- 1 * matrix(GBSG2$horTh == "yes", ncol = 1)
  colnames(X) <- "horThyes"
  GBSG2$surv <- with(GBSG2, Surv(time, cens))
  m <- Coxph(surv ~ 1, data = GBSG2, log_first = TRUE)
  mt <- tramnet(model = m, x = X, lambda = 0, alpha = 0)
  mc <- Coxph(surv ~ horTh, data = GBSG2)
  cvl_tramnet(mt, fold = 2, lambda = c(0, 1), alpha = c(0, 1))
}



tramnet documentation built on Nov. 4, 2023, 3 p.m.

Related to cvl_tramnet in tramnet...