Learn R Programming

lcmm (version 1.6.6)

dynpred: Computation of individual dynamic predictions from a joint latent class model

Description

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,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 p
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 tim
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% percen
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 :
  • preda 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.
  • newdataa data frame obtained from argument newdata containing time measurements and longitudinal observations used to compute the predictions

See Also

plot.dynpred,Jointlcmm,predictY,plot.predict

Examples

Run this code
data(data_Jointlcmm)

## 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_Jointlcmm,B = c(0.64, -0.62, 
0, 0, 0.52, 0.81, 0.41, 0.78, 0.1, 0.77, -0.05, 10.43, 11.3, -2.6, -0.52, 1.41, 
-0.05, 0.91, 0.05, 0.21, 1.5))

## 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_Jointlcmm[1:8,],draws=TRUE)

Run the code above in your browser using DataLab