cv_predict: Calculate Cross-validated prediction performance metrics

View source: R/cv_validate.R

cv_predictR Documentation

Calculate Cross-validated prediction performance metrics

Description

This function calculates cross-validated prediction performance metrics

Usage

cv_predict(
  Formula,
  data,
  na.action = "na.fail",
  subset = NULL,
  hazard = c("weibull"),
  frailty = TRUE,
  model,
  knots_list = NULL,
  p0_vec = rep(4, 3),
  startVals = NULL,
  optim_method = if (tolower(hazard) %in% c("royston-parmar", "rp")) "BFGS" else
    "L-BFGS-B",
  n_folds,
  t_cutoff,
  t_start = 0,
  tol = 0.001,
  type = "marginal",
  gamma = 1,
  h3_tv,
  tv_knots,
  verbose = 0
)

Arguments

Formula

a Formula object, with the outcome on the left of a ~, and covariates on the right. It is of the form, time to non-terminal event + corresponding censoring indicator | time to terminal event + corresponding censoring indicator ~ covariates for h_1 | covariates for h_2 | covariates for h_3. For example, y_1 + delta_1 | y_2 + delta_2 ~ x_1 | x_2 | x_3.

data

a data.frame in which to interpret the variables named in Formula.

na.action

how NAs are treated. See model.frame.

subset

a specification of the rows to be used: defaults to all rows. See model.frame.

hazard

String specifying the form of the baseline hazard.

frailty

Boolean indicating whether a gamma distributed subject-specific frailty should be included. Currently this must be set to TRUE.

model

String specifying the transition assumption

knots_list

Used for hazard specifications besides Weibull, a list of three increasing sequences of integers, each corresponding to the knots for the flexible model on the corresponding transition baseline hazard. If NULL, will be created by get_default_knots_list.

p0_vec

vector of length three of integers indicating how many baseline hazard parameters should be specified for each of the three transition hazards. This input is only relevant when hazard is something other than "weibull" and is superceded by knots_list.

startVals

A numeric vector of parameter starting values, arranged as follows: the first k_1+k_2+k_3 elements correspond to the baseline hazard parameters, then the k_1+k_2+k_3+1 element corresponds to the gamma frailty log-variance parameter, then the lastq_1+q_2+q_3 elements correspond with the regression parameters. If set to NULL, will be generated automatically using get_start.

optim_method

a string naming which optim method should be used.

n_folds

Integer value specifying the number of partitions to divide the data into for cross validation

t_cutoff

Numeric vector indicating the time(s) to compute the risk profile.

t_start

Numeric scalar indicating the dynamic start time to compute the risk profile. Set to 0 by default.

tol

Numeric value for the tolerance of the numerical integration procedure.

type

String either indicating 'marginal' for population-averaged probabilities, or 'conditional' for probabilities computed at the specified gamma

gamma

Numeric value indicating the fixed level of the frailty assumed for predicted probabilities, if 'type' is set to 'conditional'

h3_tv

String indicating whether there is an effect of t1 on hazard 3.

tv_knots

for piecewise effect of t1 in h3, these are the knots at which the effect jumps

verbose

Numeric indicating the amount of intermediate information that should be printed during the cross-validation process. Larger numbers correspond to more printed information.

Value

if Xmat has only one row, and t_cutoff is a scalar, then returns a 4 element row matrix of probabilities. If Xmat has n rows, then returns an n by 4 matrix of probabilities. If Xmat has n rows and t_cutoff is a vector of length s, then returns an s by 4 by n array.


hreed7/SemiCompRisksPen documentation built on Dec. 15, 2024, 5:41 p.m.