Skip to contents

This function computes individual dynamic predictions and 95% confidence bands. Given a joint latent class model, a landmark time s, a horizon time t and measurements until time s, the predicted probability of event in the window [s,s+t] is calculated. Confidence bands can be provided using a Monte Carlo method.

Usage

dynpred(
  model,
  newdata,
  event = 1,
  landmark,
  horizon,
  var.time,
  fun.time = identity,
  na.action = 1,
  draws = FALSE,
  ndraws = 2000
)

Arguments

model

an object inheriting from class Jointlcmm.

newdata

a data frame containing the data from which predictions are computed. This data frame must contain all the model's covariates, the observations of the longitudinal and survival outcomes, the subject identifier and if necessary the variables specified in prior and TimeDepVar argumentsfrom Jointlcmm.

event

integer giving the event for which the prediction is to be calculated

landmark

a numeric vector containing the landmark times.

horizon

a numeric vector containing the horizon times.

var.time

a character indicating the time variable in newdata

fun.time

an optional function. This is only required if the time scales in the longitudinal part of the model and the survival part are different. In that case, fun.time is the function that translates the times from the longitudinal part into the time scale of the survival part. The default is the identity function which means that the two time scales are the same.

na.action

Integer indicating how NAs are managed. The default is 1 for 'na.omit'. The alternative is 2 for 'na.fail'. Other options such as 'na.pass' or 'na.exclude' are not implemented in the current version.

draws

optional boolean specifying whether median and confidence bands of the predicted values should be computed (TRUE). IF TRUE, a Monte Carlo approximation of the posterior distribution of the predicted values is computed and the median, 2.5% and 97.5% percentiles are given. Otherwise, the predicted values are computed at the point estimate. By default, draws=FALSE.

ndraws

if draws=TRUE, ndraws specifies the number of draws that should be generated to approximate the posterior distribution of the predicted values. By default, ndraws=2000.

Value

A list containing :

pred

a matrix with 4 columns if draws=FALSE and 6 columns if draws=TRUE, containing the subjects identifier, the landmark times, the horizon times, the predicted probability (if draws=FALSE) or the median, 2.5% and 97.5 % percentiles of the 'ndraws' probabilities calculated (if draws=TRUE). If a subject has no measurement before time s or if the event has already occured at time s, his probability is NA.

newdata

a data frame obtained from argument newdata containing time measurements and longitudinal observations used to compute the predictions

References

Proust-Lima, Sene, Taylor and Jacqmin-Gadda (2014). Joint latent class models of longitudinal and time-to-event data: a review. Statistical Methods in Medical Research 23, 74-90.

Author

Cecile Proust-Lima, Viviane Philipps

Examples



## Joint latent class model with 2 classes :
m32 <- Jointlcmm(Ydep1~Time*X1,mixture=~Time,random=~Time,subject="ID",
classmb=~X3,ng=2,survival=Surv(Tevent,Event)~X1+mixture(X2),
hazard="3-quant-splines",hazardtype="PH",data=data_lcmm,
B = c(0.641, -0.6217, 0, 0, 0.5045, 0.8115, -0.4316, 0.7798, 0.1027, 
0.7704, -0.0479, 10.4257, 11.2972, -2.5955, -0.5234, 1.4147, 
-0.05, 0.9124, 0.0501, 0.2138, 1.5027))

## Predictions at landmark 10 and 12 for horizon 3, 5 and 10 for two subjects :

dynpred(m32,landmark=c(10,12),horizon=c(3,5,10),var.time="Time",
fun.time=function(x){10*x},newdata=data_lcmm[1:8,])
#>       ID landmark horizon      pred
#>  [1,]  1       10       3 0.2329690
#>  [2,]  1       10       5 0.3788284
#>  [3,]  1       10      10 0.6368587
#>  [4,]  1       12       3 0.4250841
#>  [5,]  1       12       5 0.6318772
#>  [6,]  1       12      10 0.8845080
#>  [7,]  2       10       3 0.3278219
#>  [8,]  2       10       5 0.5266806
#>  [9,]  2       10      10 0.8370420
#> [10,]  2       12       3 0.4077001
#> [11,]  2       12       5 0.6157664
#> [12,]  2       12      10 0.8859773
# \dontrun{
dynpred(m32,landmark=c(10,12),horizon=c(3,5,10),var.time="Time",
fun.time=function(x){10*x},newdata=data_lcmm[1:8,],draws=TRUE,ndraws=2000)
#>       ID landmark horizon   pred_50  pred_2.5 pred_97.5
#>  [1,]  1       10       3 0.2358876 0.1773737 0.3214147
#>  [2,]  1       10       5 0.3830814 0.2903455 0.5149652
#>  [3,]  1       10      10 0.6438571 0.4967695 0.8297853
#>  [4,]  1       12       3 0.4183860 0.3178894 0.5383852
#>  [5,]  1       12       5 0.6248616 0.4990747 0.7529744
#>  [6,]  1       12      10 0.8823067 0.7868488 0.9499321
#>  [7,]  2       10       3 0.3224306 0.2433315 0.4282778
#>  [8,]  2       10       5 0.5191261 0.4078956 0.6519505
#>  [9,]  2       10      10 0.8359254 0.7270727 0.9194506
#> [10,]  2       12       3 0.4010582 0.3026248 0.5337415
#> [11,]  2       12       5 0.6097972 0.4823007 0.7511258
#> [12,]  2       12      10 0.8868189 0.7825965 0.9558910
# }