Skip to contents

Fits the specified survival model at the landmark times and up to the horizon times specified by the user

Usage

fit_survival(
  x,
  formula,
  landmarks,
  horizons,
  method,
  dynamic_covariates = c(),
  include_clusters = FALSE,
  censor_at_horizon = FALSE,
  validation_fold = 0,
  cause = 1
)

Arguments

x

An object of class LandmarkAnalysis.

formula

A formula to be used in survival sub-model fitting.

landmarks

Numeric vector of landmark times.

horizons

Vector of prediction horizons up to when the survival submodel is fitted.

method

Method for survival analysis: "survfit", "coxph" or "finegray". "finegray" fits a Fine-Gray model for the subdistribution hazard of cause, by transforming the data with finegray and fitting a weighted Cox model to the result; this requires @event_indicator to encode competing risks as 0 (censoring) plus one numeric code per competing cause.

dynamic_covariates

Vector of time-varying covariates to be used in the survival model.

include_clusters

Boolean indicating whether to propagate cluster membership to survival analysis.

censor_at_horizon

Boolean indicating whether to censor observations at horizon times

validation_fold

If positive, cross-validation fold where model is fitted. If 0 (default), model fitting is performed on the complete dataset.

cause

Only used when method = "finegray". Numeric code (in @event_indicator) of the cause of interest whose subdistribution hazard is modelled; competing events are coded as any other non-zero, non-cause value. Defaults to 1.

Value

An object of class LandmarkAnalysis.

Details

Mathematical formulation

This function estimates the conditional probability of survival to horizon \(s+w\), conditioned on having survived to the landmark time, \(s\), that is $$\pi_i(s+w \vert s) = P(T_i > s+w \vert T_i \ge s, \bar{x}_i(s)), $$ where \(i\) denotes an individual's index, \(T_i\) is the time to event outcome for individual \(i\) and \(\bar{x}_i(s)\) are the covariates observed for individual \(i\), including the observed history of dynamic covariates.