Title: | Joint Model for Longitudinal and Multiple Time to Events Data |
---|---|
Description: | Provides model fitting, prediction, and plotting for joint models of longitudinal and multiple time-to-event data, including methods from Rizopoulos (2012) <doi:10.1201/b12208>. Useful for handling complex survival and longitudinal data in clinical research. |
Authors: | Atanu Bhattacharjee [aut, cre, ctb], Bhrigu Kumar Rajbongshi [aut, ctb], Gajendra K Vishwakarma [aut, ctb] |
Maintainer: | Atanu Bhattacharjee <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2025-03-12 05:33:49 UTC |
Source: | https://github.com/cran/JMbdirect |
Function for bootstrapped confidence interval
bootciJMCS(object, future_time)
bootciJMCS(object, future_time)
object |
fitted model |
future_time |
time sequence at which estimates are required |
Returns bootstraped confidence interval for model fitted through FastJM
JMbayes2
The function fits joint model for survival data with two events. It utilizes the JMbayes2 package for obtaining the model parameter estimates.
jmbB( dtlong, dtsurv, longm, survm, rd, timeVar, id, samplesize = NULL, BIGdata = FALSE, niter = 200, nburnin = 100, nchain = 1 )
jmbB( dtlong, dtsurv, longm, survm, rd, timeVar, id, samplesize = NULL, BIGdata = FALSE, niter = 200, nburnin = 100, nchain = 1 )
dtlong |
longitudinal data |
dtsurv |
survival data with two event status along with event time |
longm |
longitudinal model e.g. list(serBilir~drug * year,serBilir ~ drug * year) |
survm |
survival model e.g. list(Surv(years,status2)~drug,Surv(time_2,status_2)~drug+age) |
rd |
random effect component e.g. list(~year|id,~year|id) |
timeVar |
time variable |
id |
ID variable |
samplesize |
samplesize for bigdata |
BIGdata |
logical argument TRUE or FALSE |
niter |
number if iteration |
nburnin |
number of sample to burn |
nchain |
number of MCMC chain |
Estimated model parameters of Joint model with bidirectional survival data
Atanu Bhattacharjee, Bhrigu Kumar Rajbongshi and Gajendra Kumar Vishwakarma
Rizopoulos, D., G. Papageorgiou, and P. Miranda Afonso. "JMbayes2: extended joint models for longitudinal and time-to-event data." R package version 0.2-4 (2022).
Bhattacharjee, A., Rajbongshi, B. K., & Vishwakarma, G. K. (2024). jmBIG: enhancing dynamic risk prediction and personalized medicine through joint modeling of longitudinal and survival data in big routinely collected data. BMC Medical Research Methodology, 24(1), 172.
library(JMbayes2) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years,new_pbcid$time_2) new_pbcid } new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:100),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:100),] model_jmbBdirect<-jmbB(dtlong=pbc2_new,dtsurv =new_pbc2id, longm=list(serBilir~drug*year,serBilir~drug*year), survm=list(Surv(years,status2)~drug,Surv(time_2,status_2)~drug+age), rd=list(~year|id,~year|id), id='id',timeVar ='year') model_jmbBdirect
library(JMbayes2) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years,new_pbcid$time_2) new_pbcid } new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:100),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:100),] model_jmbBdirect<-jmbB(dtlong=pbc2_new,dtsurv =new_pbc2id, longm=list(serBilir~drug*year,serBilir~drug*year), survm=list(Surv(years,status2)~drug,Surv(time_2,status_2)~drug+age), rd=list(~year|id,~year|id), id='id',timeVar ='year') model_jmbBdirect
FastJM
The function fits joint model for survival data with two events. It utilizes the FastJM package for obtaining the model parameter estimates.
jmcsB( dtlong, dtsurv, longm, survm, rd, id, timeVar, BIGdata = FALSE, samplesize = 200 )
jmcsB( dtlong, dtsurv, longm, survm, rd, id, timeVar, BIGdata = FALSE, samplesize = 200 )
dtlong |
longitudinal data |
dtsurv |
survival data with two event status along with event time |
longm |
longitudinal model e.g. list(serBilir~drug * year,serBilir ~ drug * year) |
survm |
survival model e.g. list(Surv(years,status2)~drug,Surv(time_2,status_2)~drug+age) |
rd |
random effect component e.g. list(~year|id,~year|id) |
id |
ID variable |
timeVar |
time variable |
BIGdata |
logical argument TRUE or FALSE |
samplesize |
samplesize for bigdata |
Estimated model parameters of Joint model with bidirectional survival data
Atanu Bhattacharjee, Bhrigu Kumar Rajbongshi and Gajendra Kumar Vishwakarma
Li, Shanpeng, et al. "Efficient Algorithms and Implementation of a Semiparametric Joint Model for Longitudinal and Competing Risk Data: With Applications to Massive Biobank Data." Computational and Mathematical Methods in Medicine 2022 (2022).
Bhattacharjee, A., Rajbongshi, B. K., & Vishwakarma, G. K. (2024). jmBIG: enhancing dynamic risk prediction and personalized medicine through joint modeling of longitudinal and survival data in big routinely collected data. BMC Medical Research Methodology, 24(1), 172.
library(FastJM) library(JMbayes2) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years,new_pbcid$time_2) new_pbcid } new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:50),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:50),] model_jmcs<-jmcsB(dtlong=pbc2_new,dtsurv=new_pbc2id, longm=list(serBilir~drug*year, serBilir~drug*year), survm=list(Surv(years,status2)~drug, Surv(time_2,status_2)~drug+age), rd=list(~1|id,~1|id), id='id',timeVar='year') model_jmcs
library(FastJM) library(JMbayes2) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years,new_pbcid$time_2) new_pbcid } new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:50),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:50),] model_jmcs<-jmcsB(dtlong=pbc2_new,dtsurv=new_pbc2id, longm=list(serBilir~drug*year, serBilir~drug*year), survm=list(Surv(years,status2)~drug, Surv(time_2,status_2)~drug+age), rd=list(~1|id,~1|id), id='id',timeVar='year') model_jmcs
joineRML
The function fits joint model for survival data with two events. It utilizes the joineRML package for obtaining the model parameter estimates.
jmrmlB( dtlong, dtsurv, longm, survm, rd, timeVar, id, samplesize = 200, BIGdata = FALSE )
jmrmlB( dtlong, dtsurv, longm, survm, rd, timeVar, id, samplesize = 200, BIGdata = FALSE )
dtlong |
longitudinal data |
dtsurv |
survival data with two event status along with event time |
longm |
longitudinal model e.g. list(serBilir~drug * year,serBilir ~ drug * year) |
survm |
survival model e.g. list(Surv(years,status2)~drug,Surv(time_2,status_2)~drug+age) |
rd |
random effect component e.g. list(~year|id,~year|id) |
timeVar |
time variable |
id |
ID variable |
samplesize |
samplesize for bigdata |
BIGdata |
logical argument TRUE or FALSE |
Estimated model parameters of Joint model with bidirectional survival data
Atanu Bhattacharjee, Bhrigu Kumar Rajbongshi and Gajendra Kumar Vishwakarma
Hickey, Graeme L., et al. "joineRML: a joint model and software package for time-to-event and multivariate longitudinal outcomes." BMC medical research methodology 18 (2018): 1-14.
Bhattacharjee, A., Rajbongshi, B. K., & Vishwakarma, G. K. (2024). jmBIG: enhancing dynamic risk prediction and personalized medicine through joint modeling of longitudinal and survival data in big routinely collected data. BMC Medical Research Methodology, 24(1), 172.
## library(JMbayes2) library(joineRML) jmrmlBModel<-jmrmlB(dtlong=new_long2[new_long2$id%in%c(1:80),], dtsurv=new_surv2[new_surv2$id%in%c(1:80),], longm=list(y~x7+visit,y~x7+visit),survm=list(Surv(time,status)~x1+visit, Surv(time_2,status_2)~x1+visit),rd=list(~visit|id,~visit|id),id='id', timeVar='visit',samplesize=40,BIGdata=TRUE) jmrmlBModel ##
## library(JMbayes2) library(joineRML) jmrmlBModel<-jmrmlB(dtlong=new_long2[new_long2$id%in%c(1:80),], dtsurv=new_surv2[new_surv2$id%in%c(1:80),], longm=list(y~x7+visit,y~x7+visit),survm=list(Surv(time,status)~x1+visit, Surv(time_2,status_2)~x1+visit),rd=list(~visit|id,~visit|id),id='id', timeVar='visit',samplesize=40,BIGdata=TRUE) jmrmlBModel ##
rstanarm
The function fits joint model for survival data with two events. It utilizes the rstanarm package for obtaining the model parameter estimates.
jmstB( dtlong, dtsurv, longm, survm, timeVar, id, nchain = 1, refresh = 1000, BIGdata = FALSE, samplesize = 200 )
jmstB( dtlong, dtsurv, longm, survm, timeVar, id, nchain = 1, refresh = 1000, BIGdata = FALSE, samplesize = 200 )
dtlong |
longitudinal data |
dtsurv |
survival data with two event status along with event time |
longm |
longitudinal model e.g. list(serBilir~drug * year+(year|id),serBilir ~ drug * year+(year|id)) |
survm |
survival model e.g. list(Surv(years,status2)~drug,Surv(time_2,status_2)~drug+age) |
timeVar |
time variable |
id |
ID variable |
nchain |
number of MCMC chain |
refresh |
number of refresh sample |
BIGdata |
logical argument TRUE or FALSE |
samplesize |
samplesize for bigdata |
Estimated model parameters of Joint model with bidirectional survival data
Atanu Bhattacharjee, Bhrigu Kumar Rajbongshi and Gajendra Kumar Vishwakarma
Goodrich, B., et al. "rstanarm: Bayesian applied regression modeling via Stan. R package version 2.17. 4." Online< http://mc-stan. org (2018).
Bhattacharjee, A., Rajbongshi, B. K., & Vishwakarma, G. K. (2024). jmBIG: enhancing dynamic risk prediction and personalized medicine through joint modeling of longitudinal and survival data in big routinely collected data. BMC Medical Research Methodology, 24(1), 172.
## library(JMbayes2) library(rstanarm) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years, new_pbcid$time_2) new_pbcid } new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:50),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:50),] model_jmstBdirect<-jmstB( dtlong=pbc2_new, dtsurv = new_pbc2id, longm=list(serBilir~drug*year+(year|id),albumin~drug+year+(year|id)), survm=list(Surv(years,status2)~drug,Surv(time_2,status_2)~drug), timeVar="year", id='id', refresh=400, nchain=1) model_jmstBdirect ##
## library(JMbayes2) library(rstanarm) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years, new_pbcid$time_2) new_pbcid } new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:50),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:50),] model_jmstBdirect<-jmstB( dtlong=pbc2_new, dtsurv = new_pbc2id, longm=list(serBilir~drug*year+(year|id),albumin~drug+year+(year|id)), survm=list(Surv(years,status2)~drug,Surv(time_2,status_2)~drug), timeVar="year", id='id', refresh=400, nchain=1) model_jmstBdirect ##
A longitudinal dataset with single marker , with different numeric and categorical covariate
data(new_long2)
data(new_long2)
a tibble of 13 columns and 5639 observations,
id value for subjects
survival status
survival time
longitudinal marker
visit time of longitudinal measurements
different numeric and categorical variable
A survival dataset related the long2 dataset, with different numeric and categorical covariate
data(new_surv2)
data(new_surv2)
a tibble of 13 columns and 1000 observations,
id value for subjects
survival status
survival time
visit time of longitudinal measurements
different numeric and categorical variable
jmbB()
Prediction plot from jmbB()
## S3 method for class 'jmbB' plot(x, y, ...)
## S3 method for class 'jmbB' plot(x, y, ...)
x |
fitted model |
y |
newdata |
... |
others |
Returns prediction plot for the newdata using the model fitted through jmbB()
.
In the example code we use newdata as the data for ID 2 in the PBC2 dataset, it has follow up information till 8.832. Now suppose we want to look at the survival of ID 2 under joint model 1 after time 4 and for joint model 2 after time 9. For that we created the newdata as if the individual is followed till for a time period less than min(4,9).
## library(JMbayes2) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years,new_pbcid$time_2) new_pbcid } new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:100),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:100),] model_jmbBdirect<-jmbB(dtlong=pbc2_new,dtsurv = new_pbc2id, longm=list(serBilir ~ drug*year,serBilir ~ drug*year), survm=list(Surv(years,status2) ~ drug, Surv(time_2,status_2) ~ drug+age), rd=list(~year|id,~year|id), id='id',timeVar ='year') t0<-4 nd <- pbc2[pbc2$id %in% c(2), ] nd<-nd[nd$year<t0,] nd$status2<-0 nd$years<-t0 nd$time_2<-9 nd$status_2<-0 plot(model_jmbBdirect,nd) nd <- pbc2[pbc2$id %in% c(2), ] nd<-nd[nd$year<12,] nd$status2<-0 nd$years<-12 nd$time_2<-9 nd$status_2<-0 plot(model_jmbBdirect,nd) ##
## library(JMbayes2) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years,new_pbcid$time_2) new_pbcid } new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:100),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:100),] model_jmbBdirect<-jmbB(dtlong=pbc2_new,dtsurv = new_pbc2id, longm=list(serBilir ~ drug*year,serBilir ~ drug*year), survm=list(Surv(years,status2) ~ drug, Surv(time_2,status_2) ~ drug+age), rd=list(~year|id,~year|id), id='id',timeVar ='year') t0<-4 nd <- pbc2[pbc2$id %in% c(2), ] nd<-nd[nd$year<t0,] nd$status2<-0 nd$years<-t0 nd$time_2<-9 nd$status_2<-0 plot(model_jmbBdirect,nd) nd <- pbc2[pbc2$id %in% c(2), ] nd<-nd[nd$year<12,] nd$status2<-0 nd$years<-12 nd$time_2<-9 nd$status_2<-0 plot(model_jmbBdirect,nd) ##
jmcsB()
Prediction plot from jmcsB()
## S3 method for class 'jmcsB' plot(x, y, ...)
## S3 method for class 'jmcsB' plot(x, y, ...)
x |
fitted model object |
y |
newdata longitudinal |
... |
other |
Returns prediction plot for the newdata using the model fitted through jmcsB()
In the example code we use newdata as the data for ID 2 in the PBC2 dataset, it has follow up information till 8.832. Now suppose we want to look at the survival of ID 2 under joint model 1 after time 4 and for joint model 2 after time 9. For that we created the newdata as if the individual is followed till for a time period less than min(4,9).
library(JMbayes2) library(FastJM) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years,new_pbcid$time_2) new_pbcid} new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:50),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:50),] model_jmcs<-jmcsB(dtlong=pbc2_new,dtsurv = new_pbc2id, longm=list(serBilir~drug*year, serBilir~drug*year), survm=list(Surv(years,status2)~drug, Surv(time_2,status_2)~drug+age), rd=list(~1|id,~1|id), id='id',timeVar='year') t0<-4 nd<-pbc2[pbc2$id %in% c(2),] nd<-nd[nd$year<t0,] nd$status2<-0 nd$years<-t0 nd$time_2<-9 nd$status_2<-0 plot(x=model_jmcs,y=nd) ##
library(JMbayes2) library(FastJM) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years,new_pbcid$time_2) new_pbcid} new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:50),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:50),] model_jmcs<-jmcsB(dtlong=pbc2_new,dtsurv = new_pbc2id, longm=list(serBilir~drug*year, serBilir~drug*year), survm=list(Surv(years,status2)~drug, Surv(time_2,status_2)~drug+age), rd=list(~1|id,~1|id), id='id',timeVar='year') t0<-4 nd<-pbc2[pbc2$id %in% c(2),] nd<-nd[nd$year<t0,] nd$status2<-0 nd$years<-t0 nd$time_2<-9 nd$status_2<-0 plot(x=model_jmcs,y=nd) ##
jmrmlB()
Prediction plot from jmrmlB()
## S3 method for class 'jmrmlB' plot(x, y, ...)
## S3 method for class 'jmrmlB' plot(x, y, ...)
x |
fitted model object |
y |
newdata |
... |
others |
Returns prediction plot for the newdata using the model fitted through jmrmlB()
.
In the example code we use newdata as the data for ID 2 in the PBC2 dataset, it has follow up information till 8.832. Now suppose we want to look at the survival of ID 2 under joint model 1 after time 4 and for joint model 2 after time 9. For that we created the newdata as if the individual is followed till for a time period less than min(4,9).
## library(JMbayes2) library(joineRML) jmrmlBModel<-jmrmlB(dtlong=new_long2[new_long2$id<=400,], dtsurv=new_surv2[new_surv2$id<=400,], longm=list(y~x7+visit,y~x7+visit), survm=list(Surv(time,status)~x1+visit, Surv(time_2,status_2)~x1+visit), rd=list(~visit|id,~visit|id), id='id', timeVar='visit', samplesize=200, BIGdata=TRUE) t0<-6 ndBIG<-new_long2[new_long2$id==10,] ndBIG<-ndBIG[ndBIG$visit<t0,] ndBIG$status<-0 ndBIG$time<-t0 ndBIG$time_2<-10 ndBIG$status_2<-0 plot(jmrmlBModel,ndBIG) ##
## library(JMbayes2) library(joineRML) jmrmlBModel<-jmrmlB(dtlong=new_long2[new_long2$id<=400,], dtsurv=new_surv2[new_surv2$id<=400,], longm=list(y~x7+visit,y~x7+visit), survm=list(Surv(time,status)~x1+visit, Surv(time_2,status_2)~x1+visit), rd=list(~visit|id,~visit|id), id='id', timeVar='visit', samplesize=200, BIGdata=TRUE) t0<-6 ndBIG<-new_long2[new_long2$id==10,] ndBIG<-ndBIG[ndBIG$visit<t0,] ndBIG$status<-0 ndBIG$time<-t0 ndBIG$time_2<-10 ndBIG$status_2<-0 plot(jmrmlBModel,ndBIG) ##
jmstB()
Prediction plot from jmstB()
## S3 method for class 'jmstB' plot(x, y, ...)
## S3 method for class 'jmstB' plot(x, y, ...)
x |
fitted model object |
y |
newdata |
... |
others |
Returns prediction plot for the newdata using the model fitted through jmstB()
.
In the example code we use newdata as the data for ID 2 in the PBC2 dataset, it has follow up information till 8.832. Now suppose we want to look at the survival of ID 2 under joint model 1 after time 4 and for joint model 2 after time 9. For that we created the newdata as if the individual is followed till for a time period less than min(4,9).
## library(JMbayes2) library(rstanarm) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years,new_pbcid$time_2) new_pbcid } new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:50),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:50),] model_jmstBdirect<-jmstB( dtlong=pbc2_new, dtsurv = new_pbc2id, longm=list(serBilir ~ drug * year+(year|id),albumin~drug+year+(year|id)), survm=list(Surv(years,status2) ~ drug,Surv(time_2,status_2) ~ drug), timeVar="year", id='id', refresh=400, nchain=1) t0<-4 nd<-pbc2[pbc2$id %in% c(2), ] nd<-nd[nd$year<t0,] nd$status2<-0 nd$years<-t0 nd$time_2<-9 nd$status_2<-0 plot(x=model_jmstBdirect,y = nd) ##
## library(JMbayes2) library(rstanarm) st_pbcid<-function(){ new_pbcid<-pbc2.id new_pbcid$time_2<-rexp(n=nrow(pbc2.id),1/10) cen_time<-runif(nrow(pbc2.id),min(new_pbcid$time_2),max(new_pbcid$time_2)) status_2<-ifelse(new_pbcid$time_2<cen_time,1,0) new_pbcid$status_2<-status_2 new_pbcid$time_2<-ifelse(new_pbcid$time_2<cen_time,new_pbcid$time_2,cen_time) new_pbcid$time_2<-ifelse(new_pbcid$time_2<new_pbcid$years,new_pbcid$years,new_pbcid$time_2) new_pbcid } new_pbc2id<-st_pbcid() pbc2$status_2<-rep(new_pbc2id$status_2,times=data.frame(table(pbc2$id))$Freq) pbc2$time_2<-rep(new_pbc2id$time_2,times=data.frame(table(pbc2$id))$Freq) pbc2_new<-pbc2[pbc2$id%in%c(1:50),] new_pbc2id<-new_pbc2id[new_pbc2id$id%in%c(1:50),] model_jmstBdirect<-jmstB( dtlong=pbc2_new, dtsurv = new_pbc2id, longm=list(serBilir ~ drug * year+(year|id),albumin~drug+year+(year|id)), survm=list(Surv(years,status2) ~ drug,Surv(time_2,status_2) ~ drug), timeVar="year", id='id', refresh=400, nchain=1) t0<-4 nd<-pbc2[pbc2$id %in% c(2), ] nd<-nd[nd$year<t0,] nd$status2<-0 nd$years<-t0 nd$time_2<-9 nd$status_2<-0 plot(x=model_jmstBdirect,y = nd) ##
predict.jmbB
## S3 method for class 'jmbB' predict(object, newdata, ...)
## S3 method for class 'jmbB' predict(object, newdata, ...)
object |
fitted model |
newdata |
newdata |
... |
others |
Survival Prediction for newdata from model fitted through jmbB()
predict.jmcsB
## S3 method for class 'jmcsB' predict(object, newdata, ...)
## S3 method for class 'jmcsB' predict(object, newdata, ...)
object |
fitted model |
newdata |
newdata |
... |
others |
Survival Prediction for newdata from model fitted through
jmcsB()
predict.jmrmlB
## S3 method for class 'jmrmlB' predict(object, newdata, ...)
## S3 method for class 'jmrmlB' predict(object, newdata, ...)
object |
fitted model |
newdata |
newdata |
... |
others |
Survival Prediction for newdata from model fitted through jmrmlB()
predict.jmstB
## S3 method for class 'jmstB' predict(object, newdata, ...)
## S3 method for class 'jmstB' predict(object, newdata, ...)
object |
fitted model |
newdata |
newdata |
... |
others |
Survival Prediction for newdata from model fitted through
jmstB()
print method for class 'jmbB'
## S3 method for class 'jmbB' print(x, ...)
## S3 method for class 'jmbB' print(x, ...)
x |
fitted object |
... |
others |
prints table containing various parameter estimates, SE, P- value for both survival and longitudinal submodel, if the model is bayesian it includes their credible interval too.
print method for class 'jmcsB'
## S3 method for class 'jmcsB' print(x, ...)
## S3 method for class 'jmcsB' print(x, ...)
x |
fittedobject |
... |
others |
prints table containing various parameter estimates, SE, P- value for both survival and longitudinal submodel, if the model is bayesian it includes their credible interval too.
print method for class 'jmrmlB'
## S3 method for class 'jmrmlB' print(x, ...)
## S3 method for class 'jmrmlB' print(x, ...)
x |
fitted object |
... |
others |
prints table containing various parameter estimates, SE, P- value for both survival and longitudinal submodel, if the model is bayesian it includes their credible interval too.
print method for class 'jmstB'
## S3 method for class 'jmstB' print(x, ...)
## S3 method for class 'jmstB' print(x, ...)
x |
fitted object |
... |
others |
prints table containing various parameter estimates, SE, P- value for both survival and longitudinal submodel, if the model is bayesian it includes their credible interval too.