regsurv | R Documentation |
Regularized parametric survival modeling
regsurv(
prep,
penpars,
l1l2,
groups = NULL,
lambda.grid = NULL,
lambda.init = -6,
lambda.incr = 0.5,
force.nnhazards = TRUE,
print = FALSE,
maxit = 100L,
feastol = 1e-08,
...
)
prep |
an object of class survprep |
penpars |
numeric vector indicating penalized (1) and unpenalized (0) parameters. The order should follow the order the survprep model matrix |
l1l2 |
numeric vector indicating lasso (1 or TRUE) or ridge (0 or FALSE) penalty per parameter; order as for penpars |
groups |
list of groups of parameters for a group lasso penalty (e.g. a group of parameters related to a dummy coded multinomial variable or to spline basis columns). If specified, penpars and l1l2 should also be specified at the group level. |
lambda.grid |
a grid of lambda values may be specified manually here. Default behavior is to fit all models from lambda equal to exp(-6) (default) up to the moment where all lasso penalized parameters have disappeared and all the absolute value of all ridge penalized parameters is < 1e-2. |
lambda.init |
logarithm of the smallest lambda penalty in the grid. Defaults to -6. Only used when lambda.grid is NULL |
lambda.incr |
lambda increments taken from lambda.init (on the log scale); defaults to 0.5 |
force.nnhazards |
if TRUE, forces non-negative hazards / monotone non-decreasing cumulative hazards (only applicable for log cumulative hazard models) |
print |
if TRUE, prints progress (a line for each lambda for which the model was optimized) |
maxit |
(integer) the maximum number of iterations for the (ecos) solver, default 100L |
feastol |
the tolerance on the primal and dual residual, default 1e-8 |
... |
other parameters (only used by internal functions) |
an object of class regsurv
optimal |
TRUE when the optimization converged to an optimal value for each lambda |
lambda.grid |
grid of lambda values |
obj.value |
objective function values per lambda |
betahat |
matrix of model coefficients with different parameters in rows and a column per lambda value |
betahat.scaled |
matrix of model scaled coefficients with different parameters in rows and a column per lambda value. These scaled coefficients go with the scaled model matrices in prep |
num.iters |
number of iterations needed to reach the optimal solution (per lambda) |
solve.times |
solve times per lambda |
which.param |
includes 3 lists: the first with baseline model parameter indices, the second with main effect parameter indices, and the third with parameter indices for time-varying effect parameters |
penpars |
1 for parameters that were penalized, 0 otherwise |
l1l2 |
l1l2 as used to fit the model |
force.nnhazards |
force.nnhazards as used to fit the model |
survprep.id |
id that matches the id of survprep used to fit this model |
prep <- survprep(tte=simdata$eventtime,
delta=simdata$status,
X=as.matrix(simdata[ ,grep("x", names(simdata))]),
model.scale="loghazard",
time.scale="time",
spline.type="rcs",
ntimebasis=4,
qpoints=9)
# e.g. penalize all parameters but the intercept
# note that prep$which.param includes 3 lists: the first with baseline model parameters, the
# second with main effect parameters, and the third with parameters for time-varying effects
penpars <- c(rep(TRUE, length(prep$which.param[[1]])),
rep(TRUE, length(unlist(prep$which.param[2:3]))))
penpars[1] <- FALSE # do not penalize the intercept parameter
# and use ridge for baseline parameters and lasso for all other parameters
l1l2 <- c(rep(0, length(unlist(prep$which.param[1]))),
rep(1, length(unlist(prep$which.param[2:3]))))
# fit model over the default lambda grid
mod <- regsurv(prep, penpars, l1l2, print=TRUE)
plot(mod)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.