Toggle snippet (168 lines)
$ guix shell -C r-minimal r-rstan -D r-minimal -- R
R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(rstan)
Loading required package: StanHeaders
Loading required package: ggplot2
code for methods in class "Rcpp_model_base" was not checked for suspicious field assignments (recommended package 'codetools' not available?)
code for methods in class "Rcpp_model_base" was not checked for suspicious field assignments (recommended package 'codetools' not available?)
code for methods in class "Rcpp_stan_fit" was not checked for suspicious field assignments (recommended package 'codetools' not available?)
code for methods in class "Rcpp_stan_fit" was not checked for suspicious field assignments (recommended package 'codetools' not available?)
rstan (Version 2.21.5, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
> scode <- "
parameters {
real y[2];
}
model {
y[1] ~ normal(0, 1);
y[2] ~ double_exponential(0, 2);
}
"
fit1 <- stan(model_code = scode, iter = 10, verbose = FALSE)
+ + + + + + + + >
fit1
code for methods in class "Rcpp_stan_fit4model139796fca_b524cd829fcb9f50f6761f2451b62eec" was not checked for suspicious field assignments (recommended package 'codetools' not available?)
code for methods in class "Rcpp_stan_fit4model139796fca_b524cd829fcb9f50f6761f2451b62eec" was not checked for suspicious field assignments (recommended package 'codetools' not available?)
SAMPLING FOR MODEL 'b524cd829fcb9f50f6761f2451b62eec' NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 6e-06 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1:
Chain 1:
Chain 1: WARNING: No variance estimation is
Chain 1: performed for num_warmup < 20
Chain 1:
Chain 1: Iteration: 1 / 10 [ 10%] (Warmup)
Chain 1: Iteration: 2 / 10 [ 20%] (Warmup)
Chain 1: Iteration: 3 / 10 [ 30%] (Warmup)
Chain 1: Iteration: 4 / 10 [ 40%] (Warmup)
Chain 1: Iteration: 5 / 10 [ 50%] (Warmup)
Chain 1: Iteration: 6 / 10 [ 60%] (Sampling)
Chain 1: Iteration: 7 / 10 [ 70%] (Sampling)
Chain 1: Iteration: 8 / 10 [ 80%] (Sampling)
Chain 1: Iteration: 9 / 10 [ 90%] (Sampling)
Chain 1: Iteration: 10 / 10 [100%] (Sampling)
Chain 1:
Chain 1: Elapsed Time: 0.000157 seconds (Warm-up)
Chain 1: 0.000123 seconds (Sampling)
Chain 1: 0.00028 seconds (Total)
Chain 1:
SAMPLING FOR MODEL 'b524cd829fcb9f50f6761f2451b62eec' NOW (CHAIN 2).
Chain 2:
Chain 2: Gradient evaluation took 3e-06 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.03 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2:
Chain 2:
Chain 2: WARNING: No variance estimation is
Chain 2: performed for num_warmup < 20
Chain 2:
Chain 2: Iteration: 1 / 10 [ 10%] (Warmup)
Chain 2: Iteration: 2 / 10 [ 20%] (Warmup)
Chain 2: Iteration: 3 / 10 [ 30%] (Warmup)
Chain 2: Iteration: 4 / 10 [ 40%] (Warmup)
Chain 2: Iteration: 5 / 10 [ 50%] (Warmup)
Chain 2: Iteration: 6 / 10 [ 60%] (Sampling)
Chain 2: Iteration: 7 / 10 [ 70%] (Sampling)
Chain 2: Iteration: 8 / 10 [ 80%] (Sampling)
Chain 2: Iteration: 9 / 10 [ 90%] (Sampling)
Chain 2: Iteration: 10 / 10 [100%] (Sampling)
Chain 2:
Chain 2: Elapsed Time: 0.000146 seconds (Warm-up)
Chain 2: 0.000132 seconds (Sampling)
Chain 2: 0.000278 seconds (Total)
Chain 2:
SAMPLING FOR MODEL 'b524cd829fcb9f50f6761f2451b62eec' NOW (CHAIN 3).
Chain 3:
Chain 3: Gradient evaluation took 6e-06 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3:
Chain 3:
Chain 3: WARNING: No variance estimation is
Chain 3: performed for num_warmup < 20
Chain 3:
Chain 3: Iteration: 1 / 10 [ 10%] (Warmup)
Chain 3: Iteration: 2 / 10 [ 20%] (Warmup)
Chain 3: Iteration: 3 / 10 [ 30%] (Warmup)
Chain 3: Iteration: 4 / 10 [ 40%] (Warmup)
Chain 3: Iteration: 5 / 10 [ 50%] (Warmup)
Chain 3: Iteration: 6 / 10 [ 60%] (Sampling)
Chain 3: Iteration: 7 / 10 [ 70%] (Sampling)
Chain 3: Iteration: 8 / 10 [ 80%] (Sampling)
Chain 3: Iteration: 9 / 10 [ 90%] (Sampling)
Chain 3: Iteration: 10 / 10 [100%] (Sampling)
Chain 3:
Chain 3: Elapsed Time: 0.000271 seconds (Warm-up)
Chain 3: 0.000253 seconds (Sampling)
Chain 3: 0.000524 seconds (Total)
Chain 3:
SAMPLING FOR MODEL 'b524cd829fcb9f50f6761f2451b62eec' NOW (CHAIN 4).
Chain 4:
Chain 4: Gradient evaluation took 5e-06 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4:
Chain 4:
Chain 4: WARNING: No variance estimation is
Chain 4: performed for num_warmup < 20
Chain 4:
Chain 4: Iteration: 1 / 10 [ 10%] (Warmup)
Chain 4: Iteration: 2 / 10 [ 20%] (Warmup)
Chain 4: Iteration: 3 / 10 [ 30%] (Warmup)
Chain 4: Iteration: 4 / 10 [ 40%] (Warmup)
Chain 4: Iteration: 5 / 10 [ 50%] (Warmup)
Chain 4: Iteration: 6 / 10 [ 60%] (Sampling)
Chain 4: Iteration: 7 / 10 [ 70%] (Sampling)
Chain 4: Iteration: 8 / 10 [ 80%] (Sampling)
Chain 4: Iteration: 9 / 10 [ 90%] (Sampling)
Chain 4: Iteration: 10 / 10 [100%] (Sampling)
Chain 4:
Chain 4: Elapsed Time: 0.00014 seconds (Warm-up)
Chain 4: 0.000132 seconds (Sampling)
Chain 4: 0.000272 seconds (Total)
Chain 4:
Warning message:
The largest R-hat is 1.07, indicating chains have not mixed.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#r-hat
> > Inference for Stan model: b524cd829fcb9f50f6761f2451b62eec.
4 chains, each with iter=10; warmup=5; thin=1;
post-warmup draws per chain=5, total post-warmup draws=20.
mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat
y[1] -0.02 0.20 1.02 -1.80 -0.68 -0.05 0.59 1.86 26 0.89
y[2] 2.06 0.49 1.81 -1.29 0.78 1.96 3.48 5.00 14 1.08
lp__ -1.65 0.17 0.85 -3.08 -2.20 -1.64 -1.01 -0.41 26 0.81
Samples were drawn using NUTS(diag_e) at Tue Jul 12 17:28:00 2022.
For each parameter, n_eff is a crude measure of effective sample size,
and Rhat is the potential scale reduction factor on split chains (at
convergence, Rhat=1).
>