This function predicts the risk of an event for new data using the landmark model fitted by fit_LME_landmark or fit_LOCF_landmark. The 'event' is defined as event for which event_status is 1.

# S3 method for landmark
predict(object, x_L, x_hor, newdata, cv_fold = NA, ...)

Arguments

object

Object inheriting the class landmark, this should be the output from either fit_LME_landmark or fit_LOCF_landmark. It should contain a list of landmark models corresponding to different landmark times x_L.

x_L

Numeric specifying the landmark time. This indicates which landmark model in object to use.

x_hor

Numeric specifying the horizon time. The function assesses the risk of event before this time.

newdata

Data frame containing new data to return the risk prediction of the event of interest. The data should be in in long format and the columns must contain the covariates and time variables that are used to fit the model. For the LME model this the variables predictors_LME, responses_LME, predictors_LME_time, and responses_LME_time. For the LOCF model this is covariates and covariates_time.

cv_fold

If cross validation is used to fit fit_LME_landmark or fit_LOCF_landmark, then the cross validation fold to use when making risk predictions needs to be specified.

...

Arguments passed on to riskRegression::predictRisk

Value

Data frame newdata updated to contained a new column event_prediction

Examples

library(Landmarking)
data(data_repeat_outcomes)
data_model_landmark_LOCF <-
  fit_LOCF_landmark(
    data_long = data_repeat_outcomes,
    x_L = c(60, 61),
    x_hor = c(65, 66),
    covariates =
      c("ethnicity", "smoking", "diabetes", "sbp_stnd", "tchdl_stnd"),
    covariates_time =
      c(rep("response_time_sbp_stnd", 4), "response_time_tchdl_stnd"),
    k = 10,
    individual_id = "id",
    event_time = "event_time",
    event_status = "event_status",
    survival_submodel = "cause_specific"
  )
#> Warning: 887 individuals have been removed from the model building as they are not in the risk set at landmark age 60
#> Warning: 745 individuals have been removed from the model building as they are not in the risk set at landmark age 61
#> [1] "Fitting longitudinal submodel, landmark age 60"
#> [1] "Complete, landmark age 60"
#> [1] "Fitting survival submodel, landmark age 60"
#> Warning: Loglik converged before variable  2,4 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  2 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  1,3,4 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  2 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  2 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  2 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  2 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  2 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  2 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  2 ; coefficient may be infinite. 
#> [1] "Complete, landmark age 60"
#> [1] "Fitting longitudinal submodel, landmark age 61"
#> [1] "Complete, landmark age 61"
#> [1] "Fitting survival submodel, landmark age 61"
#> Warning: Loglik converged before variable  1,3 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  1,3,4 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  1,3,4 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  1,3,4 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  1,3,4 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  1,3,4 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  1,3,4 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  1,3,4 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  1,3,4 ; coefficient may be infinite. 
#> Warning: Loglik converged before variable  1,3,4 ; coefficient may be infinite. 
#> [1] "Complete, landmark age 61"
 newdata <-
   rbind(
     data.frame(
       id = c(3001, 3001, 3001),
       response_time_sbp_stnd = c(57, 58, 59),
       smoking = c(0, 0, 0),
       diabetes = c(0, 0, 0),
       ethnicity = c("Indian", "Indian", "Indian"),
       sbp_stnd = c(0.45, 0.87, 0.85),
       tchdl_stnd = c(-0.7, 0.24, 0.3),
       response_time_tchdl_stnd = c(57, 58, 59)
     )
   )
 predict(object=data_model_landmark_LOCF,x_L=60,x_hor=62,newdata=newdata,cv_fold=1)
#>      id smoking diabetes ethnicity sbp_stnd tchdl_stnd event_prediction
#> 1: 3001       0        0    Indian     0.85        0.3       0.06472957