This method allows to update an existing brmsfit object.
Usage
# S3 method for class 'brmsfit'
update(object, formula., newdata = NULL, recompile = NULL, ...)Arguments
- object
An object of class
brmsfit.- formula.
Changes to the formula; for details see
update.formulaandbrmsformula.- newdata
Optional
data.frameto update the model with new data. Data-dependent default priors will not be updated automatically.- recompile
Logical, indicating whether the Stan model should be recompiled. If
NULL(the default),updatetries to figure out internally, if recompilation is necessary. Setting it toFALSEwill cause all Stan code changing arguments to be ignored.- ...
Other arguments passed to
brm.
Details
When updating a brmsfit created with the cmdstanr
backend in a different R session, a recompilation will be triggered
because by default, cmdstanr writes the model executable to a
temporary directory. To avoid that, set option
"cmdstanr_write_stan_file_dir" to a nontemporary path of your choice
before creating the original brmsfit (see section 'Examples' below).
Examples
# \dontrun{
fit1 <- brm(time | cens(censored) ~ age * sex + disease + (1|patient),
data = kidney, family = gaussian("log"))
#> Compiling Stan program...
#> Start sampling
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 1).
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1:
#> Chain 1: Gradient evaluation took 2.8e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.28 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1:
#> Chain 1:
#> Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 1:
#> Chain 1: Elapsed Time: 0.08 seconds (Warm-up)
#> Chain 1: 0.049 seconds (Sampling)
#> Chain 1: 0.129 seconds (Total)
#> Chain 1:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 2).
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2:
#> Chain 2: Gradient evaluation took 1.8e-05 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.18 seconds.
#> Chain 2: Adjust your expectations accordingly!
#> Chain 2:
#> Chain 2:
#> Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 2:
#> Chain 2: Elapsed Time: 0.169 seconds (Warm-up)
#> Chain 2: 0.244 seconds (Sampling)
#> Chain 2: 0.413 seconds (Total)
#> Chain 2:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 3).
#> Chain 3:
#> Chain 3: Gradient evaluation took 1.9e-05 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.19 seconds.
#> Chain 3: Adjust your expectations accordingly!
#> Chain 3:
#> Chain 3:
#> Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 3: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 3:
#> Chain 3: Elapsed Time: 0.195 seconds (Warm-up)
#> Chain 3: 0.141 seconds (Sampling)
#> Chain 3: 0.336 seconds (Total)
#> Chain 3:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 4).
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4:
#> Chain 4: Gradient evaluation took 1.8e-05 seconds
#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.18 seconds.
#> Chain 4: Adjust your expectations accordingly!
#> Chain 4:
#> Chain 4:
#> Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 4:
#> Chain 4: Elapsed Time: 0.228 seconds (Warm-up)
#> Chain 4: 0.086 seconds (Sampling)
#> Chain 4: 0.314 seconds (Total)
#> Chain 4:
#> Warning: There were 3248 divergent transitions after warmup. See
#> https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 3 chains where the estimated Bayesian Fraction of Missing Information was low. See
#> https://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 5.75, indicating chains have not mixed.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#r-hat
#> 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
summary(fit1)
#> Warning: Inference for the model posterior has not converged (some Rhats are > 1.05). Be careful when analysing the results! We recommend running more iterations or setting stronger priors.
#> Warning: There were 3248 divergent transitions after warmup. Increasing adapt_delta above 0.8 may help. See http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
#> Family: gaussian
#> Links: mu = log
#> Formula: time | cens(censored) ~ age * sex + disease + (1 | patient)
#> Data: kidney (Number of observations: 76)
#> Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#> total post-warmup draws = 4000
#>
#> Multilevel Hyperparameters:
#> ~patient (Number of levels: 38)
#> Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept) 1.91 1.38 0.23 3.95 5.28 4 NA
#>
#> Regression Coefficients:
#> Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept 2.81 10.05 -14.53 9.43 5.76 4 4
#> age -0.60 0.31 -0.87 -0.07 5.76 4 NA
#> sexfemale -0.02 1.83 -1.93 1.90 5.42 4 NA
#> diseaseGN -0.31 1.48 -1.90 1.77 3.93 4 4
#> diseaseAN -1.31 0.70 -1.78 -0.11 5.16 4 NA
#> diseasePKD 0.03 0.44 -0.72 0.44 4.17 5 22
#> age:sexfemale 0.72 0.11 0.57 0.87 5.72 4 4
#>
#> Further Distributional Parameters:
#> Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sigma 2.38 0.96 1.60 4.01 5.51 4 NA
#>
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).
## remove effects of 'disease'
fit2 <- update(fit1, formula. = ~ . - disease)
#> Start sampling
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 1).
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1:
#> Chain 1: Gradient evaluation took 2.4e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.24 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1:
#> Chain 1:
#> Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 1:
#> Chain 1: Elapsed Time: 0.172 seconds (Warm-up)
#> Chain 1: 0.128 seconds (Sampling)
#> Chain 1: 0.3 seconds (Total)
#> Chain 1:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 2).
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2: Rejecting initial value:
#> Chain 2: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 2: Stan can't start sampling from this initial value.
#> Chain 2:
#> Chain 2: Gradient evaluation took 1.8e-05 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.18 seconds.
#> Chain 2: Adjust your expectations accordingly!
#> Chain 2:
#> Chain 2:
#> Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 2:
#> Chain 2: Elapsed Time: 0.075 seconds (Warm-up)
#> Chain 2: 0.048 seconds (Sampling)
#> Chain 2: 0.123 seconds (Total)
#> Chain 2:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 3).
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3: Rejecting initial value:
#> Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 3: Stan can't start sampling from this initial value.
#> Chain 3:
#> Chain 3: Gradient evaluation took 1.8e-05 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.18 seconds.
#> Chain 3: Adjust your expectations accordingly!
#> Chain 3:
#> Chain 3:
#> Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 3: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 3:
#> Chain 3: Elapsed Time: 0.168 seconds (Warm-up)
#> Chain 3: 0.423 seconds (Sampling)
#> Chain 3: 0.591 seconds (Total)
#> Chain 3:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 4).
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4: Rejecting initial value:
#> Chain 4: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 4: Stan can't start sampling from this initial value.
#> Chain 4:
#> Chain 4: Gradient evaluation took 1.9e-05 seconds
#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.19 seconds.
#> Chain 4: Adjust your expectations accordingly!
#> Chain 4:
#> Chain 4:
#> Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 4:
#> Chain 4: Elapsed Time: 0.073 seconds (Warm-up)
#> Chain 4: 0.048 seconds (Sampling)
#> Chain 4: 0.121 seconds (Total)
#> Chain 4:
#> Warning: There were 2510 divergent transitions after warmup. See
#> https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 2 chains where the estimated Bayesian Fraction of Missing Information was low. See
#> https://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is Inf, indicating chains have not mixed.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#r-hat
#> 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
summary(fit2)
#> Warning: Inference for the model posterior has not converged (some Rhats are > 1.05). Be careful when analysing the results! We recommend running more iterations or setting stronger priors.
#> Warning: There were 2510 divergent transitions after warmup. Increasing adapt_delta above 0.8 may help. See http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
#> Family: gaussian
#> Links: mu = log
#> Formula: time | cens(censored) ~ age + sex + (1 | patient) + age:sex
#> Data: kidney (Number of observations: 76)
#> Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#> total post-warmup draws = 4000
#>
#> Multilevel Hyperparameters:
#> ~patient (Number of levels: 38)
#> Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept) 2.08 1.69 0.41 4.62 12.76 4 NA
#>
#> Regression Coefficients:
#> Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept -28.30 39.42 -79.50 11.58 13.15 4 4
#> age 0.14 0.97 -0.93 1.45 13.15 4 NA
#> sexfemale 0.12 1.10 -1.08 1.77 9.40 4 NA
#> age:sexfemale 0.67 0.14 0.49 0.87 5.97 4 4
#>
#> Further Distributional Parameters:
#> Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sigma 4.91 2.23 2.00 7.54 5.97 4 11
#>
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).
## remove the group specific term of 'patient' and
## change the data (just take a subset in this example)
fit3 <- update(fit1, formula. = ~ . - (1|patient),
newdata = kidney[1:38, ])
#> The desired updates require recompiling the model
#> Compiling Stan program...
#> Start sampling
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 1).
#> Chain 1:
#> Chain 1: Gradient evaluation took 1.5e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.15 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1:
#> Chain 1:
#> Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 1:
#> Chain 1: Elapsed Time: 2.807 seconds (Warm-up)
#> Chain 1: 4.183 seconds (Sampling)
#> Chain 1: 6.99 seconds (Total)
#> Chain 1:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 2).
#> Chain 2:
#> Chain 2: Gradient evaluation took 9e-06 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.09 seconds.
#> Chain 2: Adjust your expectations accordingly!
#> Chain 2:
#> Chain 2:
#> Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 2:
#> Chain 2: Elapsed Time: 0.473 seconds (Warm-up)
#> Chain 2: 4.669 seconds (Sampling)
#> Chain 2: 5.142 seconds (Total)
#> Chain 2:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 3).
#> Chain 3:
#> Chain 3: Gradient evaluation took 9e-06 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.09 seconds.
#> Chain 3: Adjust your expectations accordingly!
#> Chain 3:
#> Chain 3:
#> Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 3: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 3:
#> Chain 3: Elapsed Time: 0.118 seconds (Warm-up)
#> Chain 3: 3.506 seconds (Sampling)
#> Chain 3: 3.624 seconds (Total)
#> Chain 3:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 4).
#> Chain 4:
#> Chain 4: Gradient evaluation took 1e-05 seconds
#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.1 seconds.
#> Chain 4: Adjust your expectations accordingly!
#> Chain 4:
#> Chain 4:
#> Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 4:
#> Chain 4: Elapsed Time: 2.502 seconds (Warm-up)
#> Chain 4: 4.447 seconds (Sampling)
#> Chain 4: 6.949 seconds (Total)
#> Chain 4:
#> Warning: There were 2598 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
#> https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
#> Warning: There were 2 chains where the estimated Bayesian Fraction of Missing Information was low. See
#> https://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 2.35, indicating chains have not mixed.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#r-hat
#> 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
summary(fit3)
#> Warning: Inference for the model posterior has not converged (some Rhats are > 1.05). Be careful when analysing the results! We recommend running more iterations or setting stronger priors.
#> Family: gaussian
#> Links: mu = log
#> Formula: time | cens(censored) ~ age + sex + disease + age:sex
#> Data: kidney[1:38, ] (Number of observations: 38)
#> Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#> total post-warmup draws = 4000
#>
#> Regression Coefficients:
#> Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept -53.42 104.09 -363.93 10.53 1.36 10 84
#> age -0.19 2.36 -6.37 3.72 1.28 20 40
#> sexfemale 58.96 104.12 -4.90 369.67 1.37 9 84
#> diseaseGN -4.92 14.60 -58.97 0.22 1.45 8 11
#> diseaseAN -177.68 382.81 -1335.14 -1.18 1.60 7 13
#> diseasePKD -157.22 403.90 -1606.74 0.07 1.93 6 20
#> age:sexfemale 0.19 2.36 -3.73 6.36 1.29 20 40
#>
#> Further Distributional Parameters:
#> Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sigma 109.56 38.01 1.48 154.88 1.47 8 11
#>
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).
## use another family and add population-level priors
fit4 <- update(fit1, family = weibull(), init = "0",
prior = set_prior("normal(0,5)"))
#> The desired updates require recompiling the model
#> Compiling Stan program...
#> Start sampling
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 1).
#> Chain 1:
#> Chain 1: Gradient evaluation took 3.5e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.35 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1:
#> Chain 1:
#> Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 1:
#> Chain 1: Elapsed Time: 1.368 seconds (Warm-up)
#> Chain 1: 0.555 seconds (Sampling)
#> Chain 1: 1.923 seconds (Total)
#> Chain 1:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 2).
#> Chain 2:
#> Chain 2: Gradient evaluation took 2.5e-05 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.25 seconds.
#> Chain 2: Adjust your expectations accordingly!
#> Chain 2:
#> Chain 2:
#> Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 2:
#> Chain 2: Elapsed Time: 1.476 seconds (Warm-up)
#> Chain 2: 0.557 seconds (Sampling)
#> Chain 2: 2.033 seconds (Total)
#> Chain 2:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 3).
#> Chain 3:
#> Chain 3: Gradient evaluation took 2.5e-05 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.25 seconds.
#> Chain 3: Adjust your expectations accordingly!
#> Chain 3:
#> Chain 3:
#> Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 3: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 3:
#> Chain 3: Elapsed Time: 1.398 seconds (Warm-up)
#> Chain 3: 0.556 seconds (Sampling)
#> Chain 3: 1.954 seconds (Total)
#> Chain 3:
#>
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 4).
#> Chain 4:
#> Chain 4: Gradient evaluation took 2.7e-05 seconds
#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.27 seconds.
#> Chain 4: Adjust your expectations accordingly!
#> Chain 4:
#> Chain 4:
#> Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 4:
#> Chain 4: Elapsed Time: 1.582 seconds (Warm-up)
#> Chain 4: 0.558 seconds (Sampling)
#> Chain 4: 2.14 seconds (Total)
#> Chain 4:
summary(fit4)
#> Family: weibull
#> Links: mu = log
#> Formula: time | cens(censored) ~ age * sex + disease + (1 | patient)
#> Data: kidney (Number of observations: 76)
#> Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#> total post-warmup draws = 4000
#>
#> Multilevel Hyperparameters:
#> ~patient (Number of levels: 38)
#> Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> sd(Intercept) 0.54 0.25 0.04 1.00 1.01 573 691
#>
#> Regression Coefficients:
#> Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> Intercept 2.88 0.93 1.13 4.74 1.00 2123 2676
#> age 0.02 0.02 -0.03 0.07 1.00 1703 2509
#> sexfemale 2.77 1.10 0.56 4.87 1.00 2106 2416
#> diseaseGN -0.27 0.50 -1.28 0.71 1.00 2531 2835
#> diseaseAN -0.57 0.47 -1.52 0.37 1.00 2509 2631
#> diseasePKD 0.75 0.72 -0.69 2.12 1.00 2285 2604
#> age:sexfemale -0.03 0.03 -0.08 0.02 1.00 1945 2244
#>
#> Further Distributional Parameters:
#> Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> shape 1.12 0.16 0.86 1.46 1.00 1251 2546
#>
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).
## to avoid a recompilation when updating a 'cmdstanr'-backend fit in a fresh
## R session, set option 'cmdstanr_write_stan_file_dir' before creating the
## initial 'brmsfit'
## CAUTION: the following code creates some files in the current working
## directory: two 'model_<hash>.stan' files, one 'model_<hash>(.exe)'
## executable, and one 'fit_cmdstanr_<some_number>.rds' file
set.seed(7)
fname <- paste0("fit_cmdstanr_", sample.int(.Machine$integer.max, 1))
options(cmdstanr_write_stan_file_dir = getwd())
fit_cmdstanr <- brm(rate ~ conc + state,
data = Puromycin,
backend = "cmdstanr",
file = fname)
# now restart the R session and run the following (after attaching 'brms')
set.seed(7)
fname <- paste0("fit_cmdstanr_", sample.int(.Machine$integer.max, 1))
fit_cmdstanr <- brm(rate ~ conc + state,
data = Puromycin,
backend = "cmdstanr",
file = fname)
upd_cmdstanr <- update(fit_cmdstanr,
formula. = rate ~ conc)
#> Start sampling
#> Running MCMC with 4 sequential chains...
#>
#> Chain 1 Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 2000 [ 5%] (Warmup)
#> Chain 1 Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 1 Iteration: 300 / 2000 [ 15%] (Warmup)
#> Chain 1 Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 1 Iteration: 500 / 2000 [ 25%] (Warmup)
#> Chain 1 Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 1 Iteration: 700 / 2000 [ 35%] (Warmup)
#> Chain 1 Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 1 Iteration: 900 / 2000 [ 45%] (Warmup)
#> Chain 1 Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 1 Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 1 Iteration: 1100 / 2000 [ 55%] (Sampling)
#> Chain 1 Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 1 Iteration: 1300 / 2000 [ 65%] (Sampling)
#> Chain 1 Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 1 Iteration: 1500 / 2000 [ 75%] (Sampling)
#> Chain 1 Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1700 / 2000 [ 85%] (Sampling)
#> Chain 1 Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1900 / 2000 [ 95%] (Sampling)
#> Chain 1 Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 1 finished in 0.0 seconds.
#> Chain 2 Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 2 Iteration: 100 / 2000 [ 5%] (Warmup)
#> Chain 2 Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 2 Iteration: 300 / 2000 [ 15%] (Warmup)
#> Chain 2 Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 2 Iteration: 500 / 2000 [ 25%] (Warmup)
#> Chain 2 Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 2 Iteration: 700 / 2000 [ 35%] (Warmup)
#> Chain 2 Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 2 Iteration: 900 / 2000 [ 45%] (Warmup)
#> Chain 2 Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 2 Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 2 Iteration: 1100 / 2000 [ 55%] (Sampling)
#> Chain 2 Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 2 Iteration: 1300 / 2000 [ 65%] (Sampling)
#> Chain 2 Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 2 Iteration: 1500 / 2000 [ 75%] (Sampling)
#> Chain 2 Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 2 Iteration: 1700 / 2000 [ 85%] (Sampling)
#> Chain 2 Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1900 / 2000 [ 95%] (Sampling)
#> Chain 2 Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 2 finished in 0.0 seconds.
#> Chain 3 Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 3 Iteration: 100 / 2000 [ 5%] (Warmup)
#> Chain 3 Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 3 Iteration: 300 / 2000 [ 15%] (Warmup)
#> Chain 3 Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 3 Iteration: 500 / 2000 [ 25%] (Warmup)
#> Chain 3 Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 3 Iteration: 700 / 2000 [ 35%] (Warmup)
#> Chain 3 Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 3 Iteration: 900 / 2000 [ 45%] (Warmup)
#> Chain 3 Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 3 Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 3 Iteration: 1100 / 2000 [ 55%] (Sampling)
#> Chain 3 Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 3 Iteration: 1300 / 2000 [ 65%] (Sampling)
#> Chain 3 Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 3 Iteration: 1500 / 2000 [ 75%] (Sampling)
#> Chain 3 Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 3 Iteration: 1700 / 2000 [ 85%] (Sampling)
#> Chain 3 Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 3 Iteration: 1900 / 2000 [ 95%] (Sampling)
#> Chain 3 Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 3 finished in 0.0 seconds.
#> Chain 4 Iteration: 1 / 2000 [ 0%] (Warmup)
#> Chain 4 Iteration: 100 / 2000 [ 5%] (Warmup)
#> Chain 4 Iteration: 200 / 2000 [ 10%] (Warmup)
#> Chain 4 Iteration: 300 / 2000 [ 15%] (Warmup)
#> Chain 4 Iteration: 400 / 2000 [ 20%] (Warmup)
#> Chain 4 Iteration: 500 / 2000 [ 25%] (Warmup)
#> Chain 4 Iteration: 600 / 2000 [ 30%] (Warmup)
#> Chain 4 Iteration: 700 / 2000 [ 35%] (Warmup)
#> Chain 4 Iteration: 800 / 2000 [ 40%] (Warmup)
#> Chain 4 Iteration: 900 / 2000 [ 45%] (Warmup)
#> Chain 4 Iteration: 1000 / 2000 [ 50%] (Warmup)
#> Chain 4 Iteration: 1001 / 2000 [ 50%] (Sampling)
#> Chain 4 Iteration: 1100 / 2000 [ 55%] (Sampling)
#> Chain 4 Iteration: 1200 / 2000 [ 60%] (Sampling)
#> Chain 4 Iteration: 1300 / 2000 [ 65%] (Sampling)
#> Chain 4 Iteration: 1400 / 2000 [ 70%] (Sampling)
#> Chain 4 Iteration: 1500 / 2000 [ 75%] (Sampling)
#> Chain 4 Iteration: 1600 / 2000 [ 80%] (Sampling)
#> Chain 4 Iteration: 1700 / 2000 [ 85%] (Sampling)
#> Chain 4 Iteration: 1800 / 2000 [ 90%] (Sampling)
#> Chain 4 Iteration: 1900 / 2000 [ 95%] (Sampling)
#> Chain 4 Iteration: 2000 / 2000 [100%] (Sampling)
#> Chain 4 finished in 0.0 seconds.
#>
#> All 4 chains finished successfully.
#> Mean chain execution time: 0.0 seconds.
#> Total execution time: 1.1 seconds.
#>
# }