Skip to contents

function for joint model in BIG DATA using rstanarm package

Usage

jmstanBig(
  dtlong,
  dtsurv,
  longm,
  survm,
  samplesize = 50,
  time_var,
  id,
  nchain = 1,
  refresh = 2000
)

Arguments

dtlong

longitudinal dataset, which contains id,visit time,longitudinal measurements along with various covariates

dtsurv

survival dataset corresponding to the longitudinal dataset, with survival status and survival time

longm

model for longitudinal response

survm

survival model

samplesize

sample size to divide the Big data

time_var

time variable in longitudinal model, included in the longitudinal data

id

name of id column in longitudinal dataset

nchain

number of chain for MCMC

refresh

refresh rate for MCMC chain

Value

returns a list containing various output which are useful for prediction.

References

Goodrich, B., et al. "rstanarm: Bayesian applied regression modeling via Stan. R package version 2.17. 4." Online< http://mc-stan. org (2018).

Author

Atanu Bhattacharjee, Bhrigu Kumar Rajbongshi and Gajendra Kumar Vishwakarma

Examples


 # \donttest{
##
library(survival)
library(dplyr)
fit3<-jmstanBig(dtlong=long2,dtsurv = surv2,longm=y~ x7+visit+(1|id),
survm=Surv(time,status)~x1+visit,samplesize=200,time_var='visit',id='id')
#> Fitting a univariate joint model.
#> 
#> Please note the warmup may be much slower than later iterations!
#> 
#> SAMPLING FOR MODEL 'jm' NOW (CHAIN 1).
#> Chain 1: 
#> Chain 1: Gradient evaluation took 0.003453 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 34.53 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1: 
#> Chain 1: 
#> Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 1: 
#> Chain 1:  Elapsed Time: 31.564 seconds (Warm-up)
#> Chain 1:                12.376 seconds (Sampling)
#> Chain 1:                43.94 seconds (Total)
#> Chain 1: 
#> Fitting a univariate joint model.
#> 
#> Please note the warmup may be much slower than later iterations!
#> 
#> SAMPLING FOR MODEL 'jm' NOW (CHAIN 1).
#> Chain 1: 
#> Chain 1: Gradient evaluation took 0.001135 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 11.35 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1: 
#> Chain 1: 
#> Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 1: 
#> Chain 1:  Elapsed Time: 34.623 seconds (Warm-up)
#> Chain 1:                20.453 seconds (Sampling)
#> Chain 1:                55.076 seconds (Total)
#> Chain 1: 
#> Fitting a univariate joint model.
#> 
#> Please note the warmup may be much slower than later iterations!
#> 
#> SAMPLING FOR MODEL 'jm' NOW (CHAIN 1).
#> Chain 1: 
#> Chain 1: Gradient evaluation took 0.000708 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 7.08 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1: 
#> Chain 1: 
#> Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 1: 
#> Chain 1:  Elapsed Time: 43.552 seconds (Warm-up)
#> Chain 1:                12.429 seconds (Sampling)
#> Chain 1:                55.981 seconds (Total)
#> Chain 1: 
#> Fitting a univariate joint model.
#> 
#> Please note the warmup may be much slower than later iterations!
#> 
#> SAMPLING FOR MODEL 'jm' NOW (CHAIN 1).
#> Chain 1: 
#> Chain 1: Gradient evaluation took 0.000829 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 8.29 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1: 
#> Chain 1: 
#> Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 1: 
#> Chain 1:  Elapsed Time: 38.4 seconds (Warm-up)
#> Chain 1:                12.474 seconds (Sampling)
#> Chain 1:                50.874 seconds (Total)
#> Chain 1: 
#> Fitting a univariate joint model.
#> 
#> Please note the warmup may be much slower than later iterations!
#> 
#> SAMPLING FOR MODEL 'jm' NOW (CHAIN 1).
#> Chain 1: 
#> Chain 1: Gradient evaluation took 0.001276 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 12.76 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1: 
#> Chain 1: 
#> Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 1: 
#> Chain 1:  Elapsed Time: 33.632 seconds (Warm-up)
#> Chain 1:                16.025 seconds (Sampling)
#> Chain 1:                49.657 seconds (Total)
#> Chain 1: 
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#tail-ess
P2<-postTraj(model<-fit3,m<-1,ids<-c(1,2,100))
pp1<-plot(P2$p1[[1]],plot_observed = TRUE)
#> `geom_smooth()` using formula = 'y ~ x'
#> `geom_smooth()` using formula = 'y ~ x'
pp2<-plot(P2$p1[[2]],plot_observed = TRUE)
#> `geom_smooth()` using formula = 'y ~ x'
#> `geom_smooth()` using formula = 'y ~ x'
pp3<-plot(P2$p1[[3]],plot_observed = TRUE)
#> `geom_smooth()` using formula = 'y ~ x'
#> `geom_smooth()` using formula = 'y ~ x'
##
# }