Learn R Programming

joineRmeta (version 0.1.2)

removeafter: Code to remove longitudinal information recorded after survival outcome

Description

This function is designed to remove any longitudinal information recorded after the survival time for each individual. If the survival event is not terminal, it is possible that longitudinal information is available in the data after the survival time, but it should not contribute to the joint analysis. This function takes and returns a jointdata object.

Usage

removeafter(data, longitudinal, survival, id, time)

Arguments

data

a jointdata object (see jointdata)

longitudinal

a character string denoting name of the variable holding the longitudinal outcome of interest.

survival

a character string denoting the name of the variable holding the survival time for the event of interest.

id

a character string denoting the name of the variable holding the id variable for the data.

time

a character string denoting the name of the variable holding the longitudinal time variable.

Value

a jointdata object, see jointdata

Details

This function removes any longitudinal information recorded for an individual after their survival time. A joint data object should have the id column as the first column in each of the survival, longitudinal and baseline datasets. In the survival dataset the second column should be the survival time and the third should be the censoring variable. In the longitudinal dataset, the second column should be longitudinal outcome, the third the longitudinal time variable and the remaining columns any other time varying covariates. The baseline dataset should have columns 2 and onwards containing time stationary covariates such as treatment group assignment or study membership.

This function does not need to be run on the results of the multi-study data simulation function simjointmeta, because the longitudinal data simulated under this function is already capped at the individual's survival time.

See Also

jointdata

Examples

Run this code
# NOT RUN {
 
# }
# NOT RUN {
 #the dataset simdat3 in this package contains joint data where longitudinal
 #data exists after individual's survival times.
 str(simdat3)

 #first this data needs to be changed to a jointdata object
 jointdat3<-tojointdata(longitudinal = simdat3$longitudinal,
                  survival = simdat3$survival, id = 'id', longoutcome = 'Y',
                  timevarying = c('time','ltime'), survtime = 'survtime',
                  cens = 'cens',time = 'time')

 #then additional data recorded after the survival time can be removed
 jointdat3.1<-removeafter(data = jointdat3, longitudinal = 'Y',
                  survival = 'survtime', id = 'id', time = 'time')

 #we can compare the two datasets to see the removed data
 str(jointdat3)
 str(jointdat3.1)
 
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab