cvl_tramnet | R Documentation |
k-fold cross validation for "tramnet"
objects over a grid of
the tuning parameters based on out-of-sample log-likelihood.
cvl_tramnet(
object,
fold = 2,
lambda = 0,
alpha = 0,
folds = NULL,
fit_opt = FALSE
)
object |
Object of class |
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 |
Returns out-of-sample logLik and coefficient estimates for
corresponding folds and values of the hyper-parameters as an object of
class "cvl_tramnet"
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))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.