Prediction using rstanarm
postTraj.Rd
prediction of the posterior trajectory for longitudinal marker while using rstanarm
for Big data
Arguments
- model
fitted model object
- m
m for
posterior_traj
function- ids
value of id
- ...
other parameter option, see
posterior_traj
Examples
# \donttest{
##
library(survival)
library(dplyr)
fit6<-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.001029 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 10.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: 36.444 seconds (Warm-up)
#> Chain 1: 12.704 seconds (Sampling)
#> Chain 1: 49.148 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.000788 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 7.88 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: 37.351 seconds (Warm-up)
#> Chain 1: 21.636 seconds (Sampling)
#> Chain 1: 58.987 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.001172 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 11.72 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: 46.346 seconds (Warm-up)
#> Chain 1: 14.235 seconds (Sampling)
#> Chain 1: 60.581 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.000729 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 7.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: 39.819 seconds (Warm-up)
#> Chain 1: 12.569 seconds (Sampling)
#> Chain 1: 52.388 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.000815 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 8.15 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: 35.136 seconds (Warm-up)
#> Chain 1: 16.324 seconds (Sampling)
#> Chain 1: 51.46 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<-fit6,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'
##
# }