Coxphnet: Regularised Transformation Models via Formulae

View source: R/tramnet_formula.R

CoxphnetR Documentation

Regularised Transformation Models via Formulae

Description

Penalized versions of the transformation models implemented in package tram, specified via a formula. These are convenience wrappers around tramnet, analogous to the corresponding functions Coxph, Colr, Lm, BoxCox, Lehmann and Survreg.

Usage

Coxphnet(
  formula,
  data,
  subset,
  weights,
  offset,
  na.action = na.omit,
  lambda,
  alpha,
  constraints = NULL,
  ...
)

Colrnet(
  formula,
  data,
  subset,
  weights,
  offset,
  na.action = na.omit,
  lambda,
  alpha,
  constraints = NULL,
  ...
)

Lmnet(
  formula,
  data,
  subset,
  weights,
  offset,
  na.action = na.omit,
  lambda,
  alpha,
  constraints = NULL,
  ...
)

BoxCoxnet(
  formula,
  data,
  subset,
  weights,
  offset,
  na.action = na.omit,
  lambda,
  alpha,
  constraints = NULL,
  ...
)

Lehmannnet(
  formula,
  data,
  subset,
  weights,
  offset,
  na.action = na.omit,
  lambda,
  alpha,
  constraints = NULL,
  ...
)

Survregnet(
  formula,
  data,
  subset,
  weights,
  offset,
  na.action = na.omit,
  lambda,
  alpha,
  constraints = NULL,
  ...
)

Arguments

formula

an object of class "formula", see tram

data

an optional data frame containing the variables in the model

subset

an optional vector specifying a subset of observations to be used in the fitting process

weights

an optional vector of case weights to be used in the fitting process

offset

an optional vector of offsets

na.action

a function which indicates what should happen when the data contain NAs

lambda

a positive penalty parameter for the whole penalty function

alpha

a mixing parameter (between zero and one) defining the fraction between absolute and quadratic penalty terms

constraints

an optional list containing a matrix of linear inequality contraints on the regression coefficients (on the original scale of the covariates) and a vector specifying the rhs of the inequality

...

additional arguments to the corresponding function in package tram, e.g., order, log_first or support

Details

The left-hand side of formula (including strata, as in y | s ~ x) defines the unpenalized baseline transformation, all terms on the right-hand side are penalized. The design matrix is obtained via model.matrix without intercept and its columns are scaled to unit variance. The scaling of the training data is stored and re-used whenever newdata is supplied to one of the methods, or in cvl_tramnet. Coefficients are reported on the original scale of the covariates, see coef.tramnet.

Not all combinations of error distribution and censoring type lead to objective functions that can be solved by CVXR; see the table in the tramnet vignette.

Value

An object of class "tramnet", see tramnet

Author(s)

Lucas Kook

Examples


if (require("survival") & require("TH.data")) {
  data("GBSG2", package = "TH.data")
  GBSG2$surv <- with(GBSG2, Surv(time, cens))
  fit <- Coxphnet(surv ~ horTh + age + tsize + pnodes, data = GBSG2,
                  lambda = 5, alpha = 1, log_first = TRUE)
  coef(fit)
  coef(fit, scaled = TRUE)
  predict(fit, newdata = GBSG2[1:5, ], type = "survivor", q = 1000)
}
data("cars")
fit <- Lmnet(dist ~ speed, data = cars, lambda = 1, alpha = 0)
coef(fit, as.lm = TRUE)


tramnet documentation built on Oct. 16, 2026, 5:07 p.m.