diff --git a/NEWS.md b/NEWS.md index 79d1205d..6f56b0cf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,6 +19,9 @@ * Add support/tests for exposing functions with tuples by @andrjohns in #860 * Add support/tests for exporting functions with complex types by @andrjohns in #861 * Add option for installing from release archive by @andrjohns in #866 +* Improve Pathfinder doc by @avehtari in #875 +* Rename `jacobian_adjustment` argument to `jacobian` by @jgabry in #879 +* Fix get_cmdstan_flags('STANCFLAGS') in recursive make by @pearsonca in #881 # cmdstanr 0.6.1 diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html new file mode 100644 index 00000000..ce8b14b1 --- /dev/null +++ b/docs/CONTRIBUTING.html @@ -0,0 +1,162 @@ + +
This outlines how to propose a change to cmdstanr and is based on similar instructions for tidyverse packages, including the contributing guidelines generated by usethis::use_tidy_contributing()
.
You can fix typos, spelling mistakes, or grammatical errors in the documentation directly using the GitHub web interface, as long as the changes are made in the source file. This generally means you’ll need to edit roxygen2 comments in an .R
, not a .Rd
file. You can find the .R
file that generates the .Rd
by reading the comment in the first line.
If you want to make a bigger change, it’s a good idea to first file an issue and make sure someone from the team agrees that it’s needed. If you’ve found a bug, please file an issue that illustrates the bug with a minimal reproducible example (see e.g. the tidyverse reprex instructions). The tidyverse guide on how to create a great issue has more advice.
+If you are new to creating pull requests here are some tips. Using the functions from the usethis
package is not required but can be helpful if this process is new to you.
Fork the package and clone onto your computer. If you haven’t done this before, we recommend using usethis::create_from_github("stan-dev/cmdstanr", fork = TRUE)
.
Install all development dependencies with devtools::install_dev_deps()
, and then make sure the package passes R CMD check by running devtools::check()
. If R CMD check doesn’t pass cleanly, it’s a good idea to ask for help before continuing.
Create a Git branch for your pull request (PR). We recommend using usethis::pr_init("brief-description-of-change")
.
Make your changes, commit to git, and then create a PR by running usethis::pr_push()
, and following the prompts in your browser. The title of your PR should briefly describe the change. The body of your PR should contain Fixes #issue-number
.
For user-facing changes, add a bullet to the top of NEWS.md
(i.e. just below the first header). Follow the style already used in NEWS.md
.
New code should attempt to follow the style used in the package. When in doubt follow the tidyverse style guide.
We use roxygen2, with Markdown syntax, for documentation.
We use testthat for unit tests. Contributions with test cases included are easier to accept.
Please note that the cmdstanr project follows the Stan project’s Code of Conduct. By contributing to this project you agree to abide by its terms.
+For the latest information on the checks performed in pedantic mode -see the Pedantic +see the Pedantic mode chapter in the Stan Reference Manual.
Pedantic mode is available when compiling the model or when using the
separate $check_syntax()
method of a
@@ -278,7 +278,7 @@
mod_pedantic <- cmdstan_model(stan_file_pedantic, pedantic = TRUE) -Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/model-131d863015ed4.stan', line 11, column 14: A +Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/model-74281eb75594.stan', line 11, column 14: A poisson distribution is given parameter lambda as a rate parameter (argument 1), but lambda was not constrained to be strictly positive. Warning: The parameter lambda has no priors. This means either no prior is @@ -288,7 +288,7 @@
argument to thePedantic checkpedantic
$check_syntax()
method.mod_pedantic$check_syntax(pedantic = TRUE) -Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/model_febb1e69c7387a0e64cf13583e078104.stan', line 11, column 14: A +Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/model_febb1e69c7387a0e64cf13583e078104.stan', line 11, column 14: A poisson distribution is given parameter lambda as a rate parameter (argument 1), but lambda was not constrained to be strictly positive. Warning: The parameter lambda has no priors. This means either no prior is @@ -305,7 +305,7 @@
Pedantic check mod_pedantic <- cmdstan_model(stan_file_pedantic, compile = FALSE) mod_pedantic$check_syntax(pedantic = TRUE) -Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/model_febb1e69c7387a0e64cf13583e078104.stan', line 11, column 14: A +Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/model_febb1e69c7387a0e64cf13583e078104.stan', line 11, column 14: A poisson distribution is given parameter lambda as a rate parameter (argument 1), but lambda was not constrained to be strictly positive. Warning: The parameter lambda has no priors. This means either no prior is @@ -495,10 +495,10 @@
Default temporary files
-fit$output_files()
+[1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/bernoulli-202311081035-1-36f995.csv" -[2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/bernoulli-202311081035-2-36f995.csv" -[3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/bernoulli-202311081035-3-36f995.csv" -[4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/bernoulli-202311081035-4-36f995.csv"
[1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/bernoulli-202312131009-1-37e810.csv" +[2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/bernoulli-202312131009-2-37e810.csv" +[3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/bernoulli-202312131009-3-37e810.csv" +[4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/bernoulli-202312131009-4-37e810.csv"
These files will be lost if you end your R session or if you remove the
@@ -510,8 +510,8 @@fit
object and force (or wait for) garbage collection.Default temporary filesrm(fit) gc()
+Ncells 1260600 67.4 2436292 130.2 NA 2436292 130.2 +Vcells 2212085 16.9 8388608 64.0 32768 3459642 26.4used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) -Ncells 1249060 66.8 2424964 129.6 NA 2424964 129.6 -Vcells 2192048 16.8 8388608 64.0 32768 3407356 26.0
file.exists(files)
[1] FALSE FALSE FALSE FALSE
@@ -561,14 +561,14 @@ After we call a method that requires the draws then if we reexamine @@ -623,14 +623,14 @@
For models with many parameters, transformed parameters, or generated @@ -688,7 +688,7 @@
fit <- mod$sample(data = data_list, save_latent_dynamics = TRUE)
fit$latent_dynamics_files()
[1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/bernoulli-diagnostic-202311081035-1-460fca.csv"
-[2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/bernoulli-diagnostic-202311081035-2-460fca.csv"
-[3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/bernoulli-diagnostic-202311081035-3-460fca.csv"
-[4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/bernoulli-diagnostic-202311081035-4-460fca.csv"
+[1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/bernoulli-diagnostic-202312131009-1-425883.csv"
+[2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/bernoulli-diagnostic-202312131009-2-425883.csv"
+[3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/bernoulli-diagnostic-202312131009-3-425883.csv"
+[4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/bernoulli-diagnostic-202312131009-4-425883.csv"
# read one of the files in
x <- utils::read.csv(fit$latent_dynamics_files()[1], comment.char = "#")
head(x)
lp__ accept_stat__ stepsize__ treedepth__ n_leapfrog__ divergent__
-1 -6.84314 0.979774 0.874237 1 3 0
-2 -7.10483 0.971803 0.874237 2 3 0
-3 -6.85492 1.000000 0.874237 1 1 0
-4 -6.81455 0.951680 0.874237 2 3 0
-5 -6.90994 0.917527 0.874237 2 3 0
-6 -6.75277 1.000000 0.874237 1 3 0
- energy__ theta p_theta g_theta
-1 6.84887 -0.814342 0.139388 0.683591
-2 7.10784 -0.558031 -0.101020 1.368040
-3 7.03534 -0.797632 0.782091 0.726389
-4 7.12956 -0.860038 1.033420 0.567976
-5 7.27609 -0.730035 -1.114150 0.902245
-6 6.87890 -1.033970 -0.653912 0.147785
+1 -9.73111 1.000000 0.932232 2 3 0
+2 -6.75346 1.000000 0.932232 1 3 0
+3 -8.48107 0.665681 0.932232 1 3 0
+4 -7.74234 1.000000 0.932232 1 1 0
+5 -6.82333 1.000000 0.932232 2 3 0
+6 -6.82333 0.784555 0.932232 1 3 0
+ energy__ theta p_theta g_theta
+1 10.97150 0.3939970 -2.155610 4.166930
+2 9.05119 -1.0295100 -2.933880 0.158161
+3 8.61284 0.0530292 0.702591 3.159050
+4 8.45793 -0.2148440 1.637290 2.357940
+5 7.76204 -1.3633100 1.875250 -0.555575
+6 8.04989 -1.3633100 -2.143570 -0.555575
The column lp__
is also provided via
fit$draws()
, and the columns accept_stat__
,
stepsize__
, treedepth__
,
@@ -818,13 +818,13 @@
theta p_theta g_theta
-1 -0.814342 0.139388 0.683591
-2 -0.558031 -0.101020 1.368040
-3 -0.797632 0.782091 0.726389
-4 -0.860038 1.033420 0.567976
-5 -0.730035 -1.114150 0.902245
-6 -1.033970 -0.653912 0.147785
+ theta p_theta g_theta
+1 0.3939970 -2.155610 4.166930
+2 -1.0295100 -2.933880 0.158161
+3 0.0530292 0.702591 3.159050
+4 -0.2148440 1.637290 2.357940
+5 -1.3633100 1.875250 -0.555575
+6 -1.3633100 -2.143570 -0.555575
Our model has a single parameter theta
and the three
columns above correspond to theta
in the
unconstrained space (theta
on the constrained
@@ -872,16 +872,16 @@
Running make \
- /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/model-131d8d6680cc \
+ /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/model-742871ce8467 \
"STANCFLAGS += --name='bernoulli_model'"
--- Translating Stan model to C++ code ---
-bin/stanc --name='bernoulli_model' --o=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/model-131d8d6680cc.hpp /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/model-131d8d6680cc.stan
+bin/stanc --name='bernoulli_model' --o=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/model-742871ce8467.hpp /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/model-742871ce8467.stan
--- Compiling, linking C++ code ---
-clang++ -Wno-deprecated-declarations -Wno-deprecated-declarations -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.4.0 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -DBOOST_DISABLE_ASSERTS -c -include-pch stan/src/stan/model/model_header_13_0.hpp.gch -x c++ -o /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/model-131d8d6680cc.o /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/model-131d8d6680cc.hpp
-clang++ -Wno-deprecated-declarations -Wno-deprecated-declarations -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.4.0 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -DBOOST_DISABLE_ASSERTS -Wl,-L,"/Users/jgabry/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/jgabry/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/lib/tbb" /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/model-131d8d6680cc.o src/cmdstan/main.o -Wl,-L,"/Users/jgabry/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/jgabry/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/lib/tbb" stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_kinsol.a stan/lib/stan_math/lib/tbb/libtbb.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc_proxy.dylib -o /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/model-131d8d6680cc
-rm -f /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/model-131d8d6680cc.o
+clang++ -Wno-deprecated-declarations -Wno-deprecated-declarations -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.4.0 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -DBOOST_DISABLE_ASSERTS -c -include-pch stan/src/stan/model/model_header_13_0.hpp.gch -x c++ -o /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/model-742871ce8467.o /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/model-742871ce8467.hpp
+clang++ -Wno-deprecated-declarations -Wno-deprecated-declarations -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.4.0 -I stan/lib/stan_math/lib/boost_1.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -DBOOST_DISABLE_ASSERTS -Wl,-L,"/Users/jgabry/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/jgabry/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/lib/tbb" /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/model-742871ce8467.o src/cmdstan/main.o -Wl,-L,"/Users/jgabry/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/jgabry/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/lib/tbb" stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_kinsol.a stan/lib/stan_math/lib/tbb/libtbb.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc_proxy.dylib -o /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/model-742871ce8467
+rm -f /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/model-742871ce8467.o
fit <- mod$sample(
data = data_list,
@@ -891,11 +891,11 @@ Troubleshooting and debugging)
Running MCMC with 1 chain...
-Running ./bernoulli 'id=1' random 'seed=2046085541' data \
- 'file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/standata-131d874013405.json' \
+Running ./bernoulli 'id=1' random 'seed=90958316' data \
+ 'file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/standata-742874baeb02.json' \
output \
- 'file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/bernoulli-202311081036-1-2ef601.csv' \
- 'profile_file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpT1Jbvd/bernoulli-profile-202311081036-1-0c4891.csv' \
+ 'file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/bernoulli-202312131009-1-4db120.csv' \
+ 'profile_file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpXOnqh8/bernoulli-profile-202312131009-1-1c1f83.csv' \
'method=sample' 'num_samples=100' 'num_warmup=100' 'save_warmup=0' \
'algorithm=hmc' 'engine=nuts' adapt 'engaged=1'
Chain 1 method = sample (Default)
@@ -925,19 +925,19 @@ Troubleshooting and debuggingSampler diagnostic warnings a
suffers from divergences.
fit_with_warning <- cmdstanr_example("schools")
-Warning: 124 of 4000 (3.0%) transitions ended with a divergence.
-See https://mc-stan.org/misc/warnings for details.
-Warning: 1 of 4 chains had an E-BFMI less than 0.2.
+Chain 4 Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
+Chain 4 Exception: normal_lpdf: Scale parameter is 0, but must be positive! (in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmpl3ZPjU/model-76ac71f3c1fe.stan', line 14, column 2 to column 41)
+Chain 4 If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
+Chain 4 but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.
+Chain 4
+Warning: 149 of 4000 (4.0%) transitions ended with a divergence.
See https://mc-stan.org/misc/warnings for details.
After fitting there is a warning about divergences. We can also
regenerate this warning message later using
fit$diagnostic_summary()
.
-
+
diagnostics <- fit_with_warning$diagnostic_summary()
-Warning: 124 of 4000 (3.0%) transitions ended with a divergence.
-See https://mc-stan.org/misc/warnings for details.
-Warning: 1 of 4 chains had an E-BFMI less than 0.2.
+Warning: 149 of 4000 (4.0%) transitions ended with a divergence.
See https://mc-stan.org/misc/warnings for details.
-
+
print(diagnostics)
$num_divergent
-[1] 3 12 97 12
+[1] 11 54 32 52
$num_max_treedepth
[1] 0 0 0 0
$ebfmi
-[1] 0.20 0.29 0.29 0.43
-
+[1] 0.40 0.36 0.37 0.30
+
# number of divergences reported in warning is the sum of the per chain values
sum(diagnostics$num_divergent)
-[1] 124
+[1] 149
CmdStan’s diagnose utility
@@ -543,7 +544,7 @@ Create a stanfit
object
+
stanfit <- rstan::read_stan_csv(fit$output_files())
@@ -561,26 +562,26 @@ Optimization$optimize()
.
-
+
fit_mle <- mod$optimize(data = data_list, seed = 123)
Initial log joint probability = -9.51104
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
6 -5.00402 0.000103557 2.55661e-07 1 1 9
Optimization terminated normally:
Convergence detected: relative gradient magnitude is below tolerance
-Finished in 0.1 seconds.
-
+Finished in 0.2 seconds.
+
fit_mle$print() # includes lp__ (log prob calculated by Stan program)
variable estimate
lp__ -5.00
theta 0.20
-
+
fit_mle$mle("theta")
theta
0.2
Here’s a plot comparing the penalized MLE to the posterior
distribution of theta
.
-
+
@@ -591,7 +592,7 @@ OptimizationMaximum
Likelihood Estimation section of the CmdStan User’s Guide for more
details.
-
+
fit_map <- mod$optimize(
data = data_list,
jacobian = TRUE,
@@ -620,7 +621,7 @@ Laplace Approximationmode
argument. If mode
is omitted then
optimization will be run internally before taking draws from the normal
approximation.
-
+
fit_laplace <- mod$laplace(
mode = fit_map,
draws = 4000,
@@ -636,11 +637,11 @@ Laplace Approximation
-
+
fit_laplace$print("theta")
variable mean median sd mad q5 q95
theta 0.27 0.25 0.12 0.12 0.10 0.50
-
+
mcmc_hist(fit_laplace$draws("theta"), binwidth = 0.025)
@@ -651,7 +652,7 @@ Variational (ADVI)$variational()
method. For details on the ADVI algorithm see the CmdStan
User’s Guide.
-
+
fit_vb <- mod$variational(
data = data_list,
seed = 123,
@@ -662,8 +663,8 @@ Variational (ADVI)Variational (ADVI)
+
fit_vb$print("theta")
variable mean median sd mad q5 q95
theta 0.27 0.25 0.12 0.12 0.10 0.49
-
+
mcmc_hist(fit_vb$draws("theta"), binwidth = 0.025)
@@ -696,7 +697,7 @@ Variational (Pathfinder)CmdStan
User’s Guide. Pathfinder is run using the $pathfinder()
method.
-
+
fit_pf <- mod$pathfinder(
data = data_list,
seed = 123,
@@ -720,7 +721,7 @@ Variational (Pathfinder)
-
+
fit_pf$print("theta")
variable mean median sd mad q5 q95
theta 0.25 0.24 0.12 0.12 0.08 0.47
@@ -728,22 +729,22 @@ Variational (Pathfinder)
-
+
mcmc_hist(fit_pf$draws("theta"), binwidth = 0.025) +
ggplot2::labs(subtitle = "Approximate posterior from pathfinder") +
ggplot2::xlim(0, 1)
-
+
mcmc_hist(fit_vb$draws("theta"), binwidth = 0.025) +
ggplot2::labs(subtitle = "Approximate posterior from variational") +
ggplot2::xlim(0, 1)
-
+
mcmc_hist(fit_laplace$draws("theta"), binwidth = 0.025) +
ggplot2::labs(subtitle = "Approximate posterior from Laplace") +
ggplot2::xlim(0, 1)
-
+
mcmc_hist(fit$draws("theta"), binwidth = 0.025) +
ggplot2::labs(subtitle = "Posterior from MCMC") +
ggplot2::xlim(0, 1)
@@ -767,7 +768,7 @@ Saving fitted model objects
+
fit$save_object(file = "fit.RDS")
# can be read back in using readRDS
@@ -779,7 +780,7 @@ Saving fitted model objects$save_object()
and replace saveRDS
with the much faster
qsave()
function from the qs
package.
-
+
# Load CmdStan output files into the fitted model object.
fit$draws() # Load posterior draws into the object.
try(fit$sampler_diagnostics(), silent = TRUE) # Load sampler diagnostics.
@@ -795,7 +796,7 @@ Saving fitted model objects
+
# Load posterior draws into the fitted model object and omit other output.
fit$draws()
@@ -828,8 +829,8 @@ Advantages of RStanDeveloping
+CRAN. (Note: As of 2023, this can mostly be achieved with CmdStanR as
+well. See Developing
using CmdStanR.)
Avoids use of R6 classes, which may result in more familiar
syntax for many R users.
diff --git a/docs/articles/posterior.html b/docs/articles/posterior.html
index 783351c1..bf1156f8 100644
--- a/docs/articles/posterior.html
+++ b/docs/articles/posterior.html
@@ -147,80 +147,82 @@ Summary statistics
fit <- cmdstanr::cmdstanr_example("schools", method = "sample")
-Warning: 191 of 4000 (5.0%) transitions ended with a divergence.
+Warning: 411 of 4000 (10.0%) transitions ended with a divergence.
See https://mc-stan.org/misc/warnings for details.
-
+Warning: 1 of 4 chains had an E-BFMI less than 0.2.
+See https://mc-stan.org/misc/warnings for details.
+
fit$summary()
- variable mean median sd mad q5 q95
-1 lp__ -57.917364 -58.126700 5.227350 5.348035 -66.0514450 -47.99920
-2 mu 6.421661 6.560445 3.994261 3.728717 -0.1207198 13.16044
-3 tau 5.211890 4.447485 3.457118 3.180740 1.0590100 12.09968
-4 theta[1] 9.159825 8.066620 6.731183 5.516199 0.1858543 21.43202
-5 theta[2] 6.750832 6.740980 5.320603 4.835678 -1.7502315 15.66325
-6 theta[3] 5.564623 5.963075 6.485297 5.310451 -5.2589090 15.65180
-7 theta[4] 6.506969 6.552735 5.753473 4.933870 -2.8831600 15.96813
-8 theta[5] 4.602639 4.969540 5.596007 4.792030 -5.1313190 13.08000
-9 theta[6] 5.451744 5.604770 5.781909 4.976021 -4.4380795 14.88214
-10 theta[7] 9.105948 8.421645 6.077003 5.363817 0.4464001 20.13298
-11 theta[8] 6.904986 6.666570 6.591653 5.244594 -3.4154830 18.00026
- rhat ess_bulk ess_tail
-1 1.037320 87.01265 18.13542
-2 1.019548 741.86144 1129.22230
-3 1.041517 74.40670 16.64168
-4 1.012043 615.84853 1757.06290
-5 1.008696 1279.50483 2218.60618
-6 1.002604 1345.71326 1786.80529
-7 1.010044 1291.76655 1900.28317
-8 1.008882 1209.92612 1848.18547
-9 1.034876 1464.53969 1882.25434
-10 1.008780 554.66658 1685.21958
-11 1.034006 1102.79917 1784.94313
+ variable mean median sd mad q5 q95
+1 lp__ -55.581147 -56.536200 7.135791 7.809299 -66.108490 -44.17410
+2 mu 6.053657 5.516030 3.777403 3.597633 -0.119312 12.18247
+3 tau 4.456447 3.456865 3.641807 3.645828 0.778481 11.91315
+4 theta[1] 8.436941 7.287125 6.350694 4.628344 0.249281 20.38983
+5 theta[2] 6.522999 5.993620 5.308671 4.494072 -1.760367 15.64359
+6 theta[3] 5.147676 4.349235 6.014958 5.082679 -5.803791 14.17618
+7 theta[4] 6.189408 5.541310 5.578086 4.501730 -2.557880 15.63053
+8 theta[5] 4.669689 4.952550 5.338198 4.271882 -5.029484 12.96141
+9 theta[6] 5.123046 4.853110 5.623562 4.579796 -4.797084 13.70336
+10 theta[7] 8.283195 7.324155 5.703079 4.912514 1.112880 18.94623
+11 theta[8] 6.499894 5.594240 6.114406 4.839688 -2.747390 16.75831
+ rhat ess_bulk ess_tail
+1 1.348190 9.585696 NA
+2 1.094243 190.870204 910.104440
+3 1.305410 10.562073 4.833756
+4 1.037209 205.819798 1097.512010
+5 1.234963 615.265251 1158.714996
+6 1.270209 429.358164 1118.125260
+7 1.060915 288.566093 1331.398737
+8 1.265317 356.169676 1352.544578
+9 1.281493 482.412281 1311.140711
+10 1.041368 75.113061 938.699910
+11 1.069623 436.937773 1068.232198
By default all variables are summaries with the follow functions:
-
+
posterior::default_summary_measures()
[1] "mean" "median" "sd" "mad" "quantile2"
To change the variables summarized, we use the variables argument
-
+
fit$summary(variables = c("mu", "tau"))
- variable mean median sd mad q5 q95 rhat
-1 mu 6.421661 6.560445 3.994261 3.728717 -0.1207198 13.16044 1.019548
-2 tau 5.211890 4.447485 3.457118 3.180740 1.0590100 12.09968 1.041517
- ess_bulk ess_tail
-1 741.8614 1129.22230
-2 74.4067 16.64168
+ variable mean median sd mad q5 q95 rhat
+1 mu 6.053657 5.516030 3.777403 3.597633 -0.119312 12.18247 1.094243
+2 tau 4.456447 3.456865 3.641807 3.645828 0.778481 11.91315 1.305410
+ ess_bulk ess_tail
+1 190.87020 910.104440
+2 10.56207 4.833756
We can additionally change which functions are used
-
+
fit$summary(variables = c("mu", "tau"), mean, sd)
variable mean sd
-1 mu 6.421661 3.994261
-2 tau 5.211890 3.457118
+1 mu 6.053657 3.777403
+2 tau 4.456447 3.641807
To summarize all variables with non-default functions, it is
necessary to set explicitly set the variables argument, either to
NULL
or the full vector of variable names.
-
+
fit$metadata()$model_params
[1] "lp__" "mu" "tau" "theta[1]" "theta[2]" "theta[3]"
[7] "theta[4]" "theta[5]" "theta[6]" "theta[7]" "theta[8]"
-
+
fit$summary(variables = NULL, "mean", "median")
variable mean median
-1 lp__ -57.917364 -58.126700
-2 mu 6.421661 6.560445
-3 tau 5.211890 4.447485
-4 theta[1] 9.159825 8.066620
-5 theta[2] 6.750832 6.740980
-6 theta[3] 5.564623 5.963075
-7 theta[4] 6.506969 6.552735
-8 theta[5] 4.602639 4.969540
-9 theta[6] 5.451744 5.604770
-10 theta[7] 9.105948 8.421645
-11 theta[8] 6.904986 6.666570
+1 lp__ -55.581147 -56.536200
+2 mu 6.053657 5.516030
+3 tau 4.456447 3.456865
+4 theta[1] 8.436941 7.287125
+5 theta[2] 6.522999 5.993620
+6 theta[3] 5.147676 4.349235
+7 theta[4] 6.189408 5.541310
+8 theta[5] 4.669689 4.952550
+9 theta[6] 5.123046 4.853110
+10 theta[7] 8.283195 7.324155
+11 theta[8] 6.499894 5.594240
Summary functions can be specified by character string, function, or
using a formula (or anything else supported by
rlang::as_function()
). If these arguments are named, those
names will be used in the tibble output. If the summary results are
named they will take precedence.
-
+
my_sd <- function(x) c(My_SD = sd(x))
fit$summary(
c("mu", "tau"),
@@ -230,45 +232,45 @@ Summary statistics~quantile(.x, probs = c(0.1, 0.9)),
Minimum = function(x) min(x)
)
- variable MEAN median My_SD 10% 90% Minimum
-1 mu 6.421661 6.560445 3.994261 1.488318 11.54665 -15.442700
-2 tau 5.211890 4.447485 3.457118 1.488050 10.02499 0.822982
+ variable MEAN median My_SD 10% 90% Minimum
+1 mu 6.053657 5.516030 3.777403 1.565533 10.863700 -8.554010
+2 tau 4.456447 3.456865 3.641807 0.778481 9.666494 0.774844
Arguments to all summary functions can also be specified with
.args
.
-
+
- variable 2.5% 5% 95% 97.5%
-1 mu -1.441798 -0.1207198 13.16044 14.63687
-2 tau 0.822982 1.0590100 12.09968 13.78430
+ variable 2.5% 5% 95% 97.5%
+1 mu -1.614829 -0.119312 12.18247 13.54298
+2 tau 0.778481 0.778481 11.91315 13.43694
The summary functions are applied to the array of sample values, with
dimension iter_sampling
xchains
.
-
+
fit$summary(variables = NULL, dim, colMeans)
variable dim.1 dim.2 1 2 3 4
-1 lp__ 1000 4 -59.408601 -58.175641 -58.144473 -55.940741
-2 mu 1000 4 6.689529 6.327474 6.548562 6.121077
-3 tau 1000 4 6.015816 5.271415 5.222288 4.338039
-4 theta[1] 1000 4 10.309827 9.010128 9.089769 8.229576
-5 theta[2] 1000 4 6.940841 6.642238 6.917915 6.502333
-6 theta[3] 1000 4 5.378242 5.517793 5.881470 5.480988
-7 theta[4] 1000 4 6.732677 6.458448 6.658988 6.177763
-8 theta[5] 1000 4 4.460429 4.316417 4.822090 4.811620
-9 theta[6] 1000 4 5.567601 5.449356 5.743810 5.046207
-10 theta[7] 1000 4 9.872239 9.168575 9.143428 8.239549
-11 theta[8] 1000 4 6.985384 6.844136 7.146715 6.643711
+1 lp__ 1000 4 -56.698590 -58.592226 -56.911658 -50.122112
+2 mu 1000 4 6.836467 6.338743 6.214918 4.824501
+3 tau 1000 4 4.751132 5.540196 4.617587 2.916872
+4 theta[1] 1000 4 9.139180 9.470688 8.631066 6.506831
+5 theta[2] 1000 4 7.088238 6.756565 6.691301 5.555891
+6 theta[3] 1000 4 6.087235 5.430155 5.208329 3.864985
+7 theta[4] 1000 4 6.963234 6.883517 6.322756 4.588127
+8 theta[5] 1000 4 5.312623 4.530775 4.623091 4.212267
+9 theta[6] 1000 4 5.778286 4.999767 5.497782 4.216348
+10 theta[7] 1000 4 9.354323 9.367796 8.483796 5.926863
+11 theta[8] 1000 4 7.269928 7.165762 6.670007 4.893880
For this reason users may have unexpected results if they use
stats::var()
directly, as it will return a covariance
matrix. An alternative is the distributional::variance()
function, which can also be accessed via
posterior::variance()
.
-
+
variable posterior::variance ~var(as.vector(.x))
-1 mu 15.95412 15.95412
-2 tau 11.95166 11.95166
+1 mu 14.26877 14.26877
+2 tau 13.26276 13.26276
Summary functions need not be numeric, but these won’t work with
$print()
.
-
+
strict_pos <- function(x) if (all(x > 0)) "yes" else "no"
fit$summary(variables = NULL, "Strictly Positive" = strict_pos)
variable Strictly Positive
@@ -283,7 +285,7 @@ Summary statistics
+
# fit$print(variables = NULL, "Strictly Positive" = strict_pos)
For more information, see posterior::summarise_draws()
,
which is called by $summary()
.
@@ -297,49 +299,49 @@ Extracting posterior draws/samplesdraws_array
and
draws_df
formats, but the posterior
package supports other useful formats as well.
-
+
# default is a 3-D draws_array object from the posterior package
# iterations x chains x variables
draws_arr <- fit$draws() # or format="array"
str(draws_arr)
- 'draws_array' num [1:1000, 1:4, 1:11] -57.1 -58.5 -56 -57.2 -58.5 ...
+ 'draws_array' num [1:1000, 1:4, 1:11] -61.7 -60.5 -61.8 -60.5 -66.8 ...
- attr(*, "dimnames")=List of 3
..$ iteration: chr [1:1000] "1" "2" "3" "4" ...
..$ chain : chr [1:4] "1" "2" "3" "4"
..$ variable : chr [1:11] "lp__" "mu" "tau" "theta[1]" ...
-
+
# draws x variables data frame
draws_df <- fit$draws(format = "df")
str(draws_df)
draws_df [4,000 × 14] (S3: draws_df/draws/tbl_df/tbl/data.frame)
- $ lp__ : num [1:4000] -57.1 -58.5 -56 -57.2 -58.5 ...
- $ mu : num [1:4000] 9.17 4.62 11.15 5.67 5.37 ...
- $ tau : num [1:4000] 2.8 4.94 2.62 5.14 7.06 ...
- $ theta[1] : num [1:4000] 17.589 0.16 18.328 0.237 1.688 ...
- $ theta[2] : num [1:4000] 8.55 10.22 8.37 9.18 9.6 ...
- $ theta[3] : num [1:4000] 10.75 6.36 10.37 9.1 8.14 ...
- $ theta[4] : num [1:4000] 10.85 3.4 12.92 6.16 6.3 ...
- $ theta[5] : num [1:4000] 11 2.25 11.42 2.25 2.76 ...
- $ theta[6] : num [1:4000] 9.55 8.19 9.94 6.84 4.9 ...
- $ theta[7] : num [1:4000] 6.58 14.62 9.12 6.07 5.08 ...
- $ theta[8] : num [1:4000] 11.31 6.14 10.26 4.92 7.66 ...
+ $ lp__ : num [1:4000] -61.7 -60.5 -61.8 -60.5 -66.8 ...
+ $ mu : num [1:4000] 8.86 6.18 9.7 4.97 5.16 ...
+ $ tau : num [1:4000] 5.6 8.77 7.58 7.37 11.97 ...
+ $ theta[1] : num [1:4000] 16.716 14.062 6.67 6.25 -0.404 ...
+ $ theta[2] : num [1:4000] 4.377 6.173 15.608 0.638 10.449 ...
+ $ theta[3] : num [1:4000] 11.59 9.27 11.11 3.74 13.42 ...
+ $ theta[4] : num [1:4000] 13.68 12.51 7.77 6.48 10.16 ...
+ $ theta[5] : num [1:4000] -0.877 1.959 7.197 2.097 3.229 ...
+ $ theta[6] : num [1:4000] -5.02 -4.95 5.66 5.24 14.26 ...
+ $ theta[7] : num [1:4000] 13.38 17.44 13.69 6.65 13.77 ...
+ $ theta[8] : num [1:4000] 10.46 5.48 -6.15 20.92 31.79 ...
$ .chain : int [1:4000] 1 1 1 1 1 1 1 1 1 1 ...
$ .iteration: int [1:4000] 1 2 3 4 5 6 7 8 9 10 ...
$ .draw : int [1:4000] 1 2 3 4 5 6 7 8 9 10 ...
-
+
print(draws_df)
# A draws_df: 1000 iterations, 4 chains, and 11 variables
- lp__ mu tau theta[1] theta[2] theta[3] theta[4] theta[5]
-1 -57 9.17 2.8 17.59 8.5 10.75 10.8 11.0
-2 -58 4.62 4.9 0.16 10.2 6.36 3.4 2.3
-3 -56 11.15 2.6 18.33 8.4 10.37 12.9 11.4
-4 -57 5.67 5.1 0.24 9.2 9.10 6.2 2.3
-5 -59 5.37 7.1 1.69 9.6 8.14 6.3 2.8
-6 -59 0.64 4.4 6.20 6.6 0.44 4.1 2.4
-7 -53 7.85 3.0 6.58 6.7 8.34 7.4 6.7
-8 -54 8.05 3.9 7.66 6.5 4.54 7.1 8.3
-9 -54 6.80 3.3 7.75 8.5 1.37 6.6 9.4
-10 -59 5.09 5.8 0.40 9.4 -1.92 13.0 2.4
+ lp__ mu tau theta[1] theta[2] theta[3] theta[4] theta[5]
+1 -62 8.9 5.6 16.7 4.38 11.6 13.676 -0.88
+2 -61 6.2 8.8 14.1 6.17 9.3 12.515 1.96
+3 -62 9.7 7.6 6.7 15.61 11.1 7.770 7.20
+4 -60 5.0 7.4 6.3 0.64 3.7 6.477 2.10
+5 -67 5.2 12.0 -0.4 10.45 13.4 10.162 3.23
+6 -63 11.1 7.9 24.6 11.68 18.8 -1.606 3.79
+7 -61 14.7 6.1 28.9 11.15 15.3 6.780 9.95
+8 -63 13.4 5.7 13.7 21.03 7.2 20.051 12.99
+9 -64 16.0 8.3 20.2 2.65 11.3 19.000 3.51
+10 -59 2.9 4.5 4.2 11.37 2.5 -0.057 6.30
# ... with 3990 more draws, and 3 more variables
# ... hidden reserved variables {'.chain', '.iteration', '.draw'}
To convert an existing draws object to a different format use the
diff --git a/docs/articles/profiling.html b/docs/articles/profiling.html
index 613e6d86..dfbed9b1 100644
--- a/docs/articles/profiling.html
+++ b/docs/articles/profiling.html
@@ -250,11 +250,11 @@
Accessing the profiling info
fit$profiles()
[[1]]
name thread_id total_time forward_time reverse_time chain_stack
-1 likelihood 0x10cc54e00 0.76348000 0.62696000 0.13652000 51132
-2 priors 0x10cc54e00 0.00513667 0.00296958 0.00216709 34088
+1 likelihood 0x118759e00 0.69970800 0.57529800 0.12441000 51468
+2 priors 0x118759e00 0.00446571 0.00270154 0.00176417 34312
no_chain_stack autodiff_calls no_autodiff_calls
-1 34105044 17044 1
-2 34088 17044 1
+1 34329156 17156 1
+2 34312 17156 1
The total_time
column is the total time spent inside a
given profile statement. It is clear that the vast majority of time is
spent in the likelihood function.
@@ -297,11 +297,11 @@ Comparing to a faster versio
fit_glm$profiles()
[[1]]
name thread_id total_time forward_time reverse_time chain_stack
-1 likelihood 0x115a87e00 0.39845200 0.39713500 0.00131726 49845
-2 priors 0x115a87e00 0.00381033 0.00234721 0.00146311 33230
+1 likelihood 0x106ce4e00 0.38400000 0.38264800 0.00135175 52203
+2 priors 0x106ce4e00 0.00356564 0.00237053 0.00119511 34802
no_chain_stack autodiff_calls no_autodiff_calls
-1 16615 16615 1
-2 33230 16615 1
+1 17401 17401 1
+2 34802 17401 1
We can see from the total_time
column that this is much
faster than the previous model.
@@ -324,7 +324,7 @@ Per-gradient timings, and memory
profile_chain_1 <- fit$profiles()[[1]]
per_gradient_timing <- profile_chain_1$total_time/profile_chain_1$autodiff_calls
print(per_gradient_timing) # two elements for the two profile statements in the model
-[1] 4.479465e-05 3.013770e-07
+[1] 4.078503e-05 2.603002e-07
Accessing and saving the profile files
@@ -335,7 +335,7 @@ Accessing and saving the profile
$profile_files()
.
fit$profile_files()
-[1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI4doTK/model_6580008f67848265f3dfd0e7ae3b0600-profile-202311081036-1-4a8018.csv"
+[1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpJRtaoq/model_6580008f67848265f3dfd0e7ae3b0600-profile-202312131010-1-95e407.csv"
These can be saved to a more permanent location with the
$save_profile_files()
method.
diff --git a/docs/index.html b/docs/index.html
index cc3f7698..1e06b71e 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -156,7 +156,7 @@ Goals
A clean interface to Stan services so that CmdStanR can keep up with Stan releases.
R code that doesn’t interface directly with C++, only calls compiled executables.
Modularity: CmdStanR runs Stan’s algorithms and lets downstream modules do the analysis.
-Flexible BSD-3 license.
+Flexible BSD-3 license.
@@ -191,7 +191,7 @@ License
CmdStanR, like CmdStan and the core Stan C++ code, is licensed under the following licenses:
-- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
+- Code: BSD 3-clause (https://opensource.org/license/bsd-3-clause/)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
@@ -216,6 +216,12 @@ License
+
+Community
+
+
Citation
diff --git a/docs/news/index.html b/docs/news/index.html
index 64016e37..f702a044 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -123,6 +123,9 @@ Other improvements and bug fixes
Add support/tests for exposing functions with tuples by @andrjohns in #860
Add support/tests for exporting functions with complex types by @andrjohns in #861
Add option for installing from release archive by @andrjohns in #866
+Improve Pathfinder doc by @avehtari in #875
+Rename jacobian_adjustment
argument to jacobian
by @jgabry in #879
+Fix get_cmdstan_flags(‘STANCFLAGS’) in recursive make by @pearsonca in #881
@@ -312,7 +315,7 @@ Bug fixes
New features
-CSV reading is now faster by using data.table::fread()
. (#318)
+CSV reading is now faster by using data.table::fread()
. (#318)
install_cmdstan()
gains argument version
for specifying which version of CmdStan to install. (#300, #308)
New function check_cmdstan_toolchain()
that checks if the appropriate toolchains are available. (#289)
$sample()
method for CmdStanModel objects gains argument chain_ids
for specifying custom chain IDs. (#319)
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index 2af8a222..14ff6a17 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -8,7 +8,7 @@ articles:
posterior: posterior.html
profiling: profiling.html
r-markdown: r-markdown.html
-last_built: 2023-11-08T17:25Z
+last_built: 2023-12-13T17:00Z
urls:
reference: https://mc-stan.org/cmdstanr/reference
article: https://mc-stan.org/cmdstanr/articles
diff --git a/docs/reference/CmdStanDiagnose.html b/docs/reference/CmdStanDiagnose.html
index 18388338..e0d66d56 100644
--- a/docs/reference/CmdStanDiagnose.html
+++ b/docs/reference/CmdStanDiagnose.html
@@ -138,10 +138,10 @@ Examples
# retrieve the gradients
test$gradients()
#> param_idx value model finite_diff error
-#> 1 0 0.797265 -8.06234 -8.06234 -9.72013e-09
-#> 2 1 0.216729 -15.64540 -15.64540 1.12721e-08
-#> 3 2 -0.207005 -4.61097 -4.61097 -5.25634e-09
-#> 4 3 1.118110 -6.60883 -6.60883 -2.24051e-08
+#> 1 0 -1.501560 34.56550 34.56550 4.58586e-08
+#> 2 1 -1.199130 1.69981 1.69981 -1.08299e-09
+#> 3 2 1.255420 -23.66640 -23.66640 -2.23140e-08
+#> 4 3 -0.452023 12.80740 12.80740 -8.57077e-09
# }
diff --git a/docs/reference/CmdStanGQ.html b/docs/reference/CmdStanGQ.html
index 28c7f7a4..6506d9af 100644
--- a/docs/reference/CmdStanGQ.html
+++ b/docs/reference/CmdStanGQ.html
@@ -177,7 +177,7 @@ Examples
#>
#> All 4 chains finished successfully.
#> Mean chain execution time: 0.0 seconds.
-#> Total execution time: 0.6 seconds.
+#> Total execution time: 0.7 seconds.
#>
# stan program for standalone generated quantities
diff --git a/docs/reference/CmdStanModel.html b/docs/reference/CmdStanModel.html
index a309a128..6b2ba8d7 100644
--- a/docs/reference/CmdStanModel.html
+++ b/docs/reference/CmdStanModel.html
@@ -333,7 +333,7 @@ Examples
#> 6 -5.00402 0.000103557 2.55661e-07 1 1 9
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
-#> Finished in 0.1 seconds.
+#> Finished in 0.2 seconds.
fit_optim$summary()
#> # A tibble: 2 × 2
#> variable estimate
@@ -341,12 +341,12 @@ Examples
#> 1 lp__ -5.00
#> 2 theta 0.2
-# Run 'optimize' again with 'jacobian=TRUE' and then draw from laplace approximation
+# Run 'optimize' again with 'jacobian=TRUE' and then draw from Laplace approximation
# to the posterior
fit_optim <- mod$optimize(data = my_data_file, jacobian = TRUE)
-#> Initial log joint probability = -6.94684
+#> Initial log joint probability = -6.92942
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 4 -6.74802 0.000319208 6.44211e-05 0.9206 0.9206 7
+#> 4 -6.74802 0.000269426 5.11368e-05 0.9249 0.9249 7
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
#> Finished in 0.1 seconds.
@@ -377,11 +377,11 @@ Examples
#> Finished in 0.1 seconds.
fit_laplace$summary()
#> # A tibble: 3 × 7
-#> variable mean median sd mad q5 q95
-#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -7.23 -6.96 0.692 0.298 -8.50 -6.75
-#> 2 lp_approx__ -0.490 -0.226 0.691 0.313 -1.88 -0.00180
-#> 3 theta 0.267 0.249 0.122 0.119 0.102 0.497
+#> variable mean median sd mad q5 q95
+#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 lp__ -7.22 -6.97 0.652 0.296 -8.51 -6.75
+#> 2 lp_approx__ -0.492 -0.223 0.677 0.302 -1.91 -0.00222
+#> 3 theta 0.265 0.246 0.120 0.122 0.0952 0.484
# Run 'variational' method to use ADVI to approximate posterior
fit_vb <- mod$variational(data = stan_data, seed = 123)
@@ -450,6 +450,53 @@ Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
+# Run 'pathfinder' again with more paths, fewer draws per path,
+# better covariance approximation, and fewer LBFGSs iterations
+fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40,
+ history_size=50, max_lbfgs_iters=100)
+#> Path [1] :Initial log joint density = -6.860971
+#> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 4 -6.748e+00 7.999e-04 6.710e-06 1.000e+00 1.000e+00 101 -6.266e+00 -6.266e+00
+#> Path [1] :Best Iter: [2] ELBO (-6.159468) evaluations: (101)
+#> Path [2] :Initial log joint density = -15.050783
+#> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 2.035e-03 6.058e-05 1.000e+00 1.000e+00 126 -6.231e+00 -6.231e+00
+#> Path [2] :Best Iter: [2] ELBO (-6.179167) evaluations: (126)
+#> Path [3] :Initial log joint density = -12.609181
+#> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.519e-03 3.222e-05 1.000e+00 1.000e+00 126 -6.224e+00 -6.224e+00
+#> Path [3] :Best Iter: [3] ELBO (-6.177380) evaluations: (126)
+#> Path [4] :Initial log joint density = -7.551395
+#> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.242e-04 5.362e-07 1.000e+00 1.000e+00 126 -6.267e+00 -6.267e+00
+#> Path [4] :Best Iter: [4] ELBO (-6.163367) evaluations: (126)
+#> Path [5] :Initial log joint density = -7.623161
+#> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.410e-04 6.577e-07 1.000e+00 1.000e+00 126 -6.242e+00 -6.242e+00
+#> Path [5] :Best Iter: [5] ELBO (-6.241791) evaluations: (126)
+#> Path [6] :Initial log joint density = -12.604877
+#> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.517e-03 3.214e-05 1.000e+00 1.000e+00 126 -6.220e+00 -6.220e+00
+#> Path [6] :Best Iter: [4] ELBO (-6.150438) evaluations: (126)
+#> Path [7] :Initial log joint density = -6.754804
+#> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 3 -6.748e+00 1.079e-03 3.589e-05 1.000e+00 1.000e+00 76 -6.230e+00 -6.230e+00
+#> Path [7] :Best Iter: [2] ELBO (-6.228353) evaluations: (76)
+#> Path [8] :Initial log joint density = -6.839688
+#> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 4 -6.748e+00 6.089e-04 4.257e-06 1.000e+00 1.000e+00 101 -6.279e+00 -6.279e+00
+#> Path [8] :Best Iter: [3] ELBO (-6.230942) evaluations: (101)
+#> Path [9] :Initial log joint density = -7.590990
+#> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.335e-04 6.020e-07 1.000e+00 1.000e+00 126 -6.260e+00 -6.260e+00
+#> Path [9] :Best Iter: [4] ELBO (-6.210494) evaluations: (126)
+#> Path [10] :Initial log joint density = -11.878141
+#> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.194e-03 2.066e-05 1.000e+00 1.000e+00 126 -6.255e+00 -6.255e+00
+#> Path [10] :Best Iter: [2] ELBO (-6.222876) evaluations: (126)
+#> Total log probability function evaluations:1310
+#> Finished in 0.1 seconds.
+
# Specifying initial values as a function
fit_mcmc_w_init_fun <- mod$sample(
data = stan_data,
@@ -516,7 +563,7 @@ Examples
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.0 seconds.
-#> Total execution time: 0.4 seconds.
+#> Total execution time: 0.3 seconds.
#>
fit_optim_w_init_list <- mod$optimize(
data = stan_data,
diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png
index 6823093a..17a35806 100644
Binary files a/docs/reference/Rplot001.png and b/docs/reference/Rplot001.png differ
diff --git a/docs/reference/as_draws.CmdStanMCMC.html b/docs/reference/as_draws.CmdStanMCMC.html
index 40958e24..ab9c18ec 100644
--- a/docs/reference/as_draws.CmdStanMCMC.html
+++ b/docs/reference/as_draws.CmdStanMCMC.html
@@ -158,41 +158,41 @@ Examples
#>
#> chain
#> iteration 1 2 3 4
-#> 1 -66 -68 -66 -65
-#> 2 -65 -67 -65 -66
-#> 3 -68 -66 -65 -66
-#> 4 -68 -65 -65 -67
-#> 5 -67 -64 -65 -67
+#> 1 -66 -67 -65 -67
+#> 2 -65 -65 -64 -67
+#> 3 -66 -66 -65 -64
+#> 4 -65 -65 -65 -66
+#> 5 -67 -67 -66 -65
#>
#> , , variable = alpha
#>
#> chain
#> iteration 1 2 3 4
-#> 1 0.44 0.414 0.71 0.46
-#> 2 0.30 -0.045 0.44 0.17
-#> 3 0.65 0.397 0.14 0.55
-#> 4 0.29 0.644 0.47 0.54
-#> 5 0.53 0.435 0.48 0.20
+#> 1 0.37 0.0232 0.30 0.19
+#> 2 0.35 0.1359 0.50 0.56
+#> 3 0.39 0.0021 0.22 0.42
+#> 4 0.42 0.2264 0.22 0.21
+#> 5 0.30 0.6367 0.19 0.24
#>
#> , , variable = beta[1]
#>
#> chain
#> iteration 1 2 3 4
-#> 1 -0.91 -0.17 -0.50 -0.59
-#> 2 -0.57 -0.97 -0.78 -0.65
-#> 3 -0.90 -0.28 -0.38 -0.43
-#> 4 -1.20 -0.58 -0.92 -1.04
-#> 5 -0.59 -0.74 -0.70 -0.98
+#> 1 -0.21 -0.70 -0.87 -0.93
+#> 2 -0.42 -0.81 -0.58 -0.38
+#> 3 -1.01 -0.83 -0.81 -0.49
+#> 4 -0.95 -0.45 -0.67 -1.03
+#> 5 -0.16 -0.96 -0.73 -0.89
#>
#> , , variable = beta[2]
#>
#> chain
-#> iteration 1 2 3 4
-#> 1 0.088 -0.192 -0.43 -0.621
-#> 2 -0.515 -0.088 -0.35 -0.591
-#> 3 -0.031 -0.444 -0.11 0.017
-#> 4 -0.653 -0.229 -0.37 0.066
-#> 5 -0.345 -0.277 -0.13 -0.678
+#> iteration 1 2 3 4
+#> 1 -0.3841 0.08 -0.574 -0.73
+#> 2 -0.2843 -0.27 -0.376 0.12
+#> 3 -0.0223 -0.13 -0.065 -0.11
+#> 4 0.0016 -0.28 -0.100 -0.29
+#> 5 -0.5327 -0.66 -0.644 -0.16
#>
#> # ... with 995 more iterations, and 101 more variables
@@ -200,70 +200,71 @@ Examples
posterior::as_draws_rvars(fit)
#> # A draws_rvars: 1000 iterations, 4 chains, and 4 variables
#> $lp__: rvar<1000,4>[1] mean ± sd:
-#> [1] -66 ± 1.5
+#> [1] -66 ± 1.4
#>
#> $alpha: rvar<1000,4>[1] mean ± sd:
-#> [1] 0.38 ± 0.22
+#> [1] 0.37 ± 0.22
#>
#> $beta: rvar<1000,4>[3] mean ± sd:
-#> [1] -0.67 ± 0.26 -0.27 ± 0.23 0.69 ± 0.27
+#> [1] -0.66 ± 0.25 -0.27 ± 0.23 0.67 ± 0.26
#>
#> $log_lik: rvar<1000,4>[100] mean ± sd:
-#> [1] -0.517 ± 0.098 -0.401 ± 0.152 -0.501 ± 0.223 -0.448 ± 0.154
-#> [5] -1.185 ± 0.289 -0.590 ± 0.195 -0.640 ± 0.126 -0.278 ± 0.135
-#> [9] -0.693 ± 0.170 -0.742 ± 0.238 -0.279 ± 0.127 -0.494 ± 0.244
-#> [13] -0.659 ± 0.215 -0.363 ± 0.176 -0.279 ± 0.108 -0.275 ± 0.087
-#> [17] -1.593 ± 0.288 -0.479 ± 0.107 -0.232 ± 0.076 -0.113 ± 0.080
-#> [21] -0.211 ± 0.089 -0.568 ± 0.149 -0.330 ± 0.140 -0.136 ± 0.067
-#> [25] -0.454 ± 0.123 -1.517 ± 0.342 -0.306 ± 0.123 -0.445 ± 0.083
-#> [29] -0.725 ± 0.232 -0.696 ± 0.191 -0.487 ± 0.164 -0.423 ± 0.109
-#> [33] -0.409 ± 0.130 -0.064 ± 0.052 -0.587 ± 0.189 -0.325 ± 0.132
-#> [37] -0.700 ± 0.231 -0.312 ± 0.151 -0.180 ± 0.111 -0.681 ± 0.128
-#> [41] -1.133 ± 0.258 -0.932 ± 0.200 -0.416 ± 0.265 -1.175 ± 0.185
-#> [45] -0.360 ± 0.118 -0.580 ± 0.131 -0.303 ± 0.131 -0.324 ± 0.082
-#> [49] -0.319 ± 0.079 -1.285 ± 0.333 -0.289 ± 0.094 -0.832 ± 0.142
-#> [53] -0.401 ± 0.131 -0.373 ± 0.143 -0.384 ± 0.139 -0.321 ± 0.192
-#> [57] -0.658 ± 0.119 -0.951 ± 0.363 -1.364 ± 0.348 -0.976 ± 0.158
-#> [61] -0.542 ± 0.097 -0.871 ± 0.318 -0.116 ± 0.075 -0.901 ± 0.250
-#> [65] -2.026 ± 0.610 -0.508 ± 0.138 -0.276 ± 0.082 -1.061 ± 0.237
-#> [69] -0.435 ± 0.083 -0.641 ± 0.235 -0.613 ± 0.214 -0.464 ± 0.177
-#> [73] -1.489 ± 0.374 -0.948 ± 0.198 -1.136 ± 0.394 -0.374 ± 0.140
-#> [77] -0.878 ± 0.139 -0.491 ± 0.174 -0.765 ± 0.194 -0.539 ± 0.200
-#> [81] -0.163 ± 0.102 -0.223 ± 0.145 -0.343 ± 0.080 -0.275 ± 0.092
-#> [85] -0.130 ± 0.075 -1.132 ± 0.322 -0.822 ± 0.126 -0.780 ± 0.249
-#> [89] -1.283 ± 0.323 -0.261 ± 0.137 -0.387 ± 0.133 -1.501 ± 0.352
-#> [93] -0.737 ± 0.221 -0.318 ± 0.087 -0.388 ± 0.112 -1.573 ± 0.284
-#> [97] -0.432 ± 0.100 -1.053 ± 0.383 -0.693 ± 0.143 -0.392 ± 0.096
+#> [1] -0.518 ± 0.099 -0.405 ± 0.147 -0.501 ± 0.220 -0.451 ± 0.153
+#> [5] -1.173 ± 0.276 -0.592 ± 0.185 -0.640 ± 0.123 -0.280 ± 0.135
+#> [9] -0.693 ± 0.163 -0.740 ± 0.234 -0.283 ± 0.124 -0.500 ± 0.241
+#> [13] -0.655 ± 0.206 -0.364 ± 0.175 -0.282 ± 0.106 -0.278 ± 0.087
+#> [17] -1.582 ± 0.288 -0.481 ± 0.107 -0.235 ± 0.076 -0.115 ± 0.079
+#> [21] -0.215 ± 0.088 -0.570 ± 0.144 -0.332 ± 0.140 -0.139 ± 0.067
+#> [25] -0.456 ± 0.121 -1.513 ± 0.345 -0.309 ± 0.120 -0.447 ± 0.083
+#> [29] -0.722 ± 0.227 -0.694 ± 0.189 -0.489 ± 0.157 -0.427 ± 0.106
+#> [33] -0.412 ± 0.126 -0.065 ± 0.052 -0.585 ± 0.184 -0.327 ± 0.135
+#> [37] -0.700 ± 0.227 -0.314 ± 0.150 -0.182 ± 0.110 -0.681 ± 0.126
+#> [41] -1.124 ± 0.248 -0.928 ± 0.195 -0.412 ± 0.267 -1.169 ± 0.185
+#> [45] -0.362 ± 0.119 -0.583 ± 0.128 -0.307 ± 0.129 -0.327 ± 0.084
+#> [49] -0.322 ± 0.079 -1.286 ± 0.334 -0.291 ± 0.096 -0.833 ± 0.144
+#> [53] -0.404 ± 0.127 -0.373 ± 0.143 -0.388 ± 0.134 -0.322 ± 0.195
+#> [57] -0.658 ± 0.117 -0.951 ± 0.353 -1.351 ± 0.337 -0.975 ± 0.159
+#> [61] -0.542 ± 0.099 -0.876 ± 0.314 -0.119 ± 0.075 -0.901 ± 0.247
+#> [65] -1.995 ± 0.581 -0.511 ± 0.134 -0.279 ± 0.083 -1.057 ± 0.233
+#> [69] -0.438 ± 0.083 -0.638 ± 0.235 -0.609 ± 0.207 -0.463 ± 0.169
+#> [73] -1.476 ± 0.363 -0.944 ± 0.194 -1.139 ± 0.389 -0.376 ± 0.140
+#> [77] -0.875 ± 0.136 -0.489 ± 0.174 -0.764 ± 0.190 -0.545 ± 0.196
+#> [81] -0.165 ± 0.100 -0.226 ± 0.138 -0.346 ± 0.081 -0.278 ± 0.091
+#> [85] -0.132 ± 0.075 -1.120 ± 0.315 -0.822 ± 0.127 -0.773 ± 0.237
+#> [89] -1.270 ± 0.314 -0.263 ± 0.136 -0.388 ± 0.129 -1.484 ± 0.335
+#> [93] -0.738 ± 0.218 -0.321 ± 0.088 -0.391 ± 0.110 -1.562 ± 0.280
+#> [97] -0.433 ± 0.102 -1.052 ± 0.372 -0.693 ± 0.139 -0.393 ± 0.098
#>
posterior::as_draws_list(fit)
#> # A draws_list: 1000 iterations, 4 chains, and 105 variables
#>
#> [chain = 1]
#> $lp__
-#> [1] -66 -65 -68 -68 -67 -66 -65 -66 -67 -66
+#> [1] -66 -65 -66 -65 -67 -65 -65 -64 -67 -69
#>
#> $alpha
-#> [1] 0.44 0.30 0.65 0.29 0.53 0.53 0.47 0.38 0.32 0.51
+#> [1] 0.373 0.355 0.389 0.419 0.300 0.178 0.629 0.288 0.016 -0.075
#>
#> $`beta[1]`
-#> [1] -0.91 -0.57 -0.90 -1.20 -0.59 -0.51 -0.36 -0.19 -1.17 -1.02
+#> [1] -0.21 -0.42 -1.01 -0.95 -0.16 -0.51 -0.69 -0.67 -0.74 -0.71
#>
#> $`beta[2]`
-#> [1] 0.088 -0.515 -0.031 -0.653 -0.345 -0.646 -0.154 -0.488 -0.013 0.034
+#> [1] -0.3841 -0.2843 -0.0223 0.0016 -0.5327 -0.3040 -0.3392 -0.2792 0.0976
+#> [10] 0.1916
#>
#>
#> [chain = 2]
#> $lp__
-#> [1] -68 -67 -66 -65 -64 -65 -65 -64 -65 -65
+#> [1] -67 -65 -66 -65 -67 -67 -67 -64 -68 -66
#>
#> $alpha
-#> [1] 0.414 -0.045 0.397 0.644 0.435 0.266 0.415 0.369 0.229 0.185
+#> [1] 0.0232 0.1359 0.0021 0.2264 0.6367 0.7152 0.4707 0.3940 0.0634 0.4544
#>
#> $`beta[1]`
-#> [1] -0.17 -0.97 -0.28 -0.58 -0.74 -0.48 -0.83 -0.72 -0.44 -0.58
+#> [1] -0.70 -0.81 -0.83 -0.45 -0.96 -0.34 -1.17 -0.57 -0.62 -0.62
#>
#> $`beta[2]`
-#> [1] -0.192 -0.088 -0.444 -0.229 -0.277 -0.314 0.046 -0.240 -0.080 -0.090
+#> [1] 0.08 -0.27 -0.13 -0.28 -0.66 -0.57 -0.21 -0.20 -0.47 -0.67
#>
#> # ... with 990 more iterations, and 2 more chains, and 101 more variables
# }
diff --git a/docs/reference/cmdstan_model.html b/docs/reference/cmdstan_model.html
index 9385aa48..a94e571b 100644
--- a/docs/reference/cmdstan_model.html
+++ b/docs/reference/cmdstan_model.html
@@ -358,12 +358,12 @@ Examples
#> 1 lp__ -5.00
#> 2 theta 0.2
-# Run 'optimize' again with 'jacobian=TRUE' and then draw from laplace approximation
+# Run 'optimize' again with 'jacobian=TRUE' and then draw from Laplace approximation
# to the posterior
fit_optim <- mod$optimize(data = my_data_file, jacobian = TRUE)
-#> Initial log joint probability = -6.79903
+#> Initial log joint probability = -17.5452
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 3 -6.74802 0.00379849 4.77236e-05 0.9516 0.9516 6
+#> 5 -6.74802 0.00115356 2.90728e-05 1 1 8
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
#> Finished in 0.1 seconds.
@@ -394,11 +394,11 @@ Examples
#> Finished in 0.1 seconds.
fit_laplace$summary()
#> # A tibble: 3 × 7
-#> variable mean median sd mad q5 q95
-#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -7.22 -6.97 0.659 0.305 -8.52 -6.75
-#> 2 lp_approx__ -0.481 -0.224 0.662 0.308 -1.84 -0.00186
-#> 3 theta 0.272 0.252 0.121 0.122 0.103 0.502
+#> variable mean median sd mad q5 q95
+#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 lp__ -7.27 -7.00 0.705 0.338 -8.72 -6.75
+#> 2 lp_approx__ -0.527 -0.251 0.714 0.340 -2.02 -0.00142
+#> 3 theta 0.270 0.251 0.126 0.125 0.0959 0.509
# Run 'variational' method to use ADVI to approximate posterior
fit_vb <- mod$variational(data = stan_data, seed = 123)
@@ -407,8 +407,8 @@ Examples
#> This procedure has not been thoroughly tested and may be unstable
#> or buggy. The interface is subject to change.
#> ------------------------------------------------------------
-#> Gradient evaluation took 6e-06 seconds
-#> 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.
+#> Gradient evaluation took 5e-06 seconds
+#> 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds.
#> Adjust your expectations accordingly!
#> Begin eta adaptation.
#> Iteration: 1 / 250 [ 0%] (Adaptation)
@@ -467,6 +467,53 @@ Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
+# Run 'pathfinder' again with more paths, fewer draws per path,
+# better covariance approximation, and fewer LBFGSs iterations
+fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40,
+ history_size=50, max_lbfgs_iters=100)
+#> Path [1] :Initial log joint density = -11.515672
+#> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.064e-03 1.692e-05 1.000e+00 1.000e+00 126 -6.254e+00 -6.254e+00
+#> Path [1] :Best Iter: [3] ELBO (-6.213658) evaluations: (126)
+#> Path [2] :Initial log joint density = -9.189304
+#> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 3.749e-04 3.327e-06 1.000e+00 1.000e+00 126 -6.289e+00 -6.289e+00
+#> Path [2] :Best Iter: [4] ELBO (-6.214534) evaluations: (126)
+#> Path [3] :Initial log joint density = -13.270061
+#> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.767e-03 4.305e-05 1.000e+00 1.000e+00 126 -6.276e+00 -6.276e+00
+#> Path [3] :Best Iter: [3] ELBO (-6.225363) evaluations: (126)
+#> Path [4] :Initial log joint density = -6.748213
+#> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 2 -6.748e+00 1.004e-02 7.315e-05 1.000e+00 1.000e+00 51 -6.200e+00 -6.200e+00
+#> Path [4] :Best Iter: [2] ELBO (-6.200114) evaluations: (51)
+#> Path [5] :Initial log joint density = -7.368682
+#> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 5.377e-04 9.870e-07 1.000e+00 1.000e+00 126 -6.276e+00 -6.276e+00
+#> Path [5] :Best Iter: [3] ELBO (-6.167297) evaluations: (126)
+#> Path [6] :Initial log joint density = -9.465368
+#> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 4.613e-04 4.599e-06 1.000e+00 1.000e+00 126 -6.238e+00 -6.238e+00
+#> Path [6] :Best Iter: [3] ELBO (-6.185454) evaluations: (126)
+#> Path [7] :Initial log joint density = -6.856712
+#> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 4 -6.748e+00 1.028e-04 1.386e-05 9.452e-01 9.452e-01 101 -6.242e+00 -6.242e+00
+#> Path [7] :Best Iter: [3] ELBO (-6.159687) evaluations: (101)
+#> Path [8] :Initial log joint density = -7.085030
+#> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 4 -6.748e+00 3.058e-03 6.268e-05 1.000e+00 1.000e+00 101 -6.221e+00 -6.221e+00
+#> Path [8] :Best Iter: [4] ELBO (-6.221460) evaluations: (101)
+#> Path [9] :Initial log joint density = -7.443992
+#> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 9.951e-05 3.747e-07 1.000e+00 1.000e+00 126 -6.228e+00 -6.228e+00
+#> Path [9] :Best Iter: [2] ELBO (-6.206717) evaluations: (126)
+#> Path [10] :Initial log joint density = -6.751684
+#> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 3 -6.748e+00 5.950e-04 1.461e-05 1.000e+00 1.000e+00 76 -6.209e+00 -6.209e+00
+#> Path [10] :Best Iter: [3] ELBO (-6.209430) evaluations: (76)
+#> Total log probability function evaluations:1235
+#> Finished in 0.1 seconds.
+
# Specifying initial values as a function
fit_mcmc_w_init_fun <- mod$sample(
data = stan_data,
diff --git a/docs/reference/cmdstanr-package.html b/docs/reference/cmdstanr-package.html
index 6e29914b..072311bb 100644
--- a/docs/reference/cmdstanr-package.html
+++ b/docs/reference/cmdstanr-package.html
@@ -291,7 +291,7 @@ Examples
#> [1] 0 0
#>
#> $ebfmi
-#> [1] 1.0 1.3
+#> [1] 1.017555 1.250490
#>
# Get posterior draws
@@ -364,12 +364,12 @@ Examples
#> 1 lp__ -5.00
#> 2 theta 0.2
-# Run 'optimize' again with 'jacobian=TRUE' and then draw from laplace approximation
+# Run 'optimize' again with 'jacobian=TRUE' and then draw from Laplace approximation
# to the posterior
fit_optim <- mod$optimize(data = my_data_file, jacobian = TRUE)
-#> Initial log joint probability = -7.20447
+#> Initial log joint probability = -18.9282
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 4 -6.74802 0.00428356 0.000109727 1 1 7
+#> 5 -6.74802 0.00032939 4.62604e-06 1 1 8
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
#> Finished in 0.1 seconds.
@@ -397,14 +397,14 @@ Examples
#> iteration: 1700
#> iteration: 1800
#> iteration: 1900
-#> Finished in 0.2 seconds.
+#> Finished in 0.1 seconds.
fit_laplace$summary()
#> # A tibble: 3 × 7
#> variable mean median sd mad q5 q95
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -7.23 -6.96 0.694 0.287 -8.53 -6.75
-#> 2 lp_approx__ -0.493 -0.211 0.714 0.286 -1.87 -0.00222
-#> 3 theta 0.264 0.248 0.120 0.120 0.0954 0.491
+#> 1 lp__ -7.23 -6.97 0.683 0.304 -8.57 -6.75
+#> 2 lp_approx__ -0.496 -0.225 0.743 0.305 -1.91 -0.00217
+#> 3 theta 0.264 0.247 0.120 0.119 0.0967 0.492
# Run 'variational' method to use ADVI to approximate posterior
fit_vb <- mod$variational(data = stan_data, seed = 123)
@@ -473,6 +473,53 @@ Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
+# Run 'pathfinder' again with more paths, fewer draws per path,
+# better covariance approximation, and fewer LBFGSs iterations
+fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40,
+ history_size=50, max_lbfgs_iters=100)
+#> Path [1] :Initial log joint density = -12.637372
+#> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.531e-03 3.268e-05 1.000e+00 1.000e+00 126 -6.214e+00 -6.214e+00
+#> Path [1] :Best Iter: [5] ELBO (-6.213940) evaluations: (126)
+#> Path [2] :Initial log joint density = -11.196746
+#> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 9.877e-04 1.507e-05 1.000e+00 1.000e+00 126 -6.283e+00 -6.283e+00
+#> Path [2] :Best Iter: [4] ELBO (-6.223987) evaluations: (126)
+#> Path [3] :Initial log joint density = -10.337120
+#> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 7.410e-04 9.634e-06 1.000e+00 1.000e+00 126 -6.236e+00 -6.236e+00
+#> Path [3] :Best Iter: [2] ELBO (-6.179583) evaluations: (126)
+#> Path [4] :Initial log joint density = -12.005851
+#> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.253e-03 2.257e-05 1.000e+00 1.000e+00 126 -6.159e+00 -6.159e+00
+#> Path [4] :Best Iter: [5] ELBO (-6.159209) evaluations: (126)
+#> Path [5] :Initial log joint density = -11.377707
+#> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.032e-03 1.614e-05 1.000e+00 1.000e+00 126 -6.206e+00 -6.206e+00
+#> Path [5] :Best Iter: [2] ELBO (-6.202552) evaluations: (126)
+#> Path [6] :Initial log joint density = -7.049866
+#> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 4 -6.748e+00 2.694e-03 5.075e-05 1.000e+00 1.000e+00 101 -6.203e+00 -6.203e+00
+#> Path [6] :Best Iter: [4] ELBO (-6.203218) evaluations: (101)
+#> Path [7] :Initial log joint density = -9.219130
+#> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 3.841e-04 3.455e-06 1.000e+00 1.000e+00 126 -6.185e+00 -6.185e+00
+#> Path [7] :Best Iter: [5] ELBO (-6.185156) evaluations: (126)
+#> Path [8] :Initial log joint density = -17.192426
+#> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.354e-03 3.651e-05 1.000e+00 1.000e+00 126 -6.204e+00 -6.204e+00
+#> Path [8] :Best Iter: [4] ELBO (-6.168586) evaluations: (126)
+#> Path [9] :Initial log joint density = -9.491732
+#> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 4.697e-04 4.731e-06 1.000e+00 1.000e+00 126 -6.247e+00 -6.247e+00
+#> Path [9] :Best Iter: [3] ELBO (-6.220590) evaluations: (126)
+#> Path [10] :Initial log joint density = -6.750036
+#> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 3 -6.748e+00 3.322e-04 6.069e-06 1.000e+00 1.000e+00 76 -6.214e+00 -6.214e+00
+#> Path [10] :Best Iter: [2] ELBO (-6.188430) evaluations: (76)
+#> Total log probability function evaluations:1335
+#> Finished in 0.1 seconds.
+
# Specifying initial values as a function
fit_mcmc_w_init_fun <- mod$sample(
data = stan_data,
@@ -488,7 +535,7 @@ Examples
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.0 seconds.
-#> Total execution time: 0.7 seconds.
+#> Total execution time: 0.3 seconds.
#>
fit_mcmc_w_init_fun_2 <- mod$sample(
data = stan_data,
@@ -517,7 +564,7 @@ Examples
#>
#> [[2]]
#> [[2]]$theta
-#> [1] 0.33
+#> [1] 0.3333333
#>
#>
@@ -539,7 +586,7 @@ Examples
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.0 seconds.
-#> Total execution time: 0.5 seconds.
+#> Total execution time: 0.3 seconds.
#>
fit_optim_w_init_list <- mod$optimize(
data = stan_data,
diff --git a/docs/reference/cmdstanr_example.html b/docs/reference/cmdstanr_example.html
index babf2ce0..8d377b8f 100644
--- a/docs/reference/cmdstanr_example.html
+++ b/docs/reference/cmdstanr_example.html
@@ -187,18 +187,18 @@ Examples
fit_logistic_mcmc <- cmdstanr_example("logistic", chains = 2)
fit_logistic_mcmc$summary()
#> # A tibble: 105 × 10
-#> variable mean median sd mad q5 q95 rhat ess_bulk
-#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -66.1 -65.7 1.53 1.26 -69.1 -64.3 1.00 1090.
-#> 2 alpha 0.373 0.371 0.223 0.215 0.0169 0.729 1.00 1944.
-#> 3 beta[1] -0.678 -0.676 0.260 0.261 -1.11 -0.265 1.00 1936.
-#> 4 beta[2] -0.276 -0.274 0.234 0.239 -0.674 0.0978 1.00 1841.
-#> 5 beta[3] 0.684 0.681 0.268 0.270 0.270 1.13 1.00 2070.
-#> 6 log_lik[1] -0.518 -0.509 0.102 0.101 -0.694 -0.366 0.999 1983.
-#> 7 log_lik[2] -0.398 -0.380 0.149 0.143 -0.665 -0.194 1.00 2108.
-#> 8 log_lik[3] -0.501 -0.461 0.228 0.210 -0.939 -0.204 1.00 1995.
-#> 9 log_lik[4] -0.446 -0.428 0.157 0.148 -0.740 -0.226 1.00 1806.
-#> 10 log_lik[5] -1.18 -1.15 0.285 0.286 -1.67 -0.754 1.00 2253.
+#> variable mean median sd mad q5 q95 rhat ess_bulk
+#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 lp__ -66.0 -65.6 1.45 1.20 -68.7 -64.3 1.00 934.
+#> 2 alpha 0.384 0.386 0.218 0.218 0.0341 0.748 1.00 1959.
+#> 3 beta[1] -0.667 -0.661 0.247 0.248 -1.08 -0.273 1.00 1840.
+#> 4 beta[2] -0.275 -0.273 0.231 0.231 -0.662 0.114 1.00 1954.
+#> 5 beta[3] 0.687 0.685 0.271 0.269 0.254 1.13 1.00 2212.
+#> 6 log_lik[1] -0.515 -0.509 0.101 0.0967 -0.698 -0.360 1.00 2038.
+#> 7 log_lik[2] -0.402 -0.380 0.150 0.140 -0.673 -0.195 1.00 2565.
+#> 8 log_lik[3] -0.498 -0.467 0.223 0.212 -0.922 -0.201 1.00 2174.
+#> 9 log_lik[4] -0.449 -0.430 0.154 0.148 -0.731 -0.232 0.999 1785.
+#> 10 log_lik[5] -1.19 -1.17 0.283 0.281 -1.69 -0.772 1.00 2119.
#> # ℹ 95 more rows
#> # ℹ 1 more variable: ess_tail <dbl>
@@ -211,7 +211,7 @@ Examples
#> 2 alpha 0.364
#> 3 beta[1] -0.632
#> 4 beta[2] -0.259
-#> 5 beta[3] 0.649
+#> 5 beta[3] 0.648
#> 6 log_lik[1] -0.515
#> 7 log_lik[2] -0.394
#> 8 log_lik[3] -0.469
@@ -222,18 +222,18 @@ Examples
fit_logistic_vb <- cmdstanr_example("logistic", method = "variational")
fit_logistic_vb$summary()
#> # A tibble: 106 × 7
-#> variable mean median sd mad q5 q95
-#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -66.5 -66.1 1.98 1.74 -70.5 -64.4
-#> 2 lp_approx__ -2.01 -1.63 1.53 1.27 -5.07 -0.341
-#> 3 alpha 0.305 0.311 0.248 0.234 -0.116 0.716
-#> 4 beta[1] -0.623 -0.633 0.230 0.239 -0.987 -0.255
-#> 5 beta[2] -0.377 -0.369 0.263 0.258 -0.821 0.0339
-#> 6 beta[3] 0.681 0.671 0.291 0.288 0.215 1.16
-#> 7 log_lik[1] -0.565 -0.558 0.118 0.108 -0.766 -0.383
-#> 8 log_lik[2] -0.412 -0.388 0.172 0.156 -0.740 -0.186
-#> 9 log_lik[3] -0.641 -0.589 0.294 0.280 -1.22 -0.265
-#> 10 log_lik[4] -0.389 -0.367 0.145 0.134 -0.662 -0.190
+#> variable mean median sd mad q5 q95
+#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 lp__ -66.5 -66.0 1.82 1.62 -69.9 -64.3
+#> 2 lp_approx__ -1.96 -1.62 1.41 1.19 -4.62 -0.318
+#> 3 alpha 0.503 0.492 0.219 0.222 0.144 0.876
+#> 4 beta[1] -0.582 -0.568 0.301 0.288 -1.10 -0.0916
+#> 5 beta[2] -0.278 -0.275 0.185 0.183 -0.592 0.0118
+#> 6 beta[3] 0.688 0.696 0.301 0.307 0.211 1.18
+#> 7 log_lik[1] -0.480 -0.475 0.0981 0.0994 -0.648 -0.332
+#> 8 log_lik[2] -0.466 -0.443 0.190 0.185 -0.836 -0.197
+#> 9 log_lik[3] -0.470 -0.443 0.195 0.188 -0.838 -0.209
+#> 10 log_lik[4] -0.495 -0.480 0.152 0.148 -0.776 -0.277
#> # ℹ 96 more rows
print_example_program("schools")
@@ -254,23 +254,23 @@ Examples
#> target += normal_lpdf(y | theta, sigma);
#> }
fit_schools_mcmc <- cmdstanr_example("schools")
-#> Warning: 91 of 4000 (2.0%) transitions ended with a divergence.
+#> Warning: 146 of 4000 (4.0%) transitions ended with a divergence.
#> See https://mc-stan.org/misc/warnings for details.
fit_schools_mcmc$summary()
#> # A tibble: 11 × 10
#> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -57.8 -58.2 5.50 5.71 -66.3 -48.3 1.04 151. 248.
-#> 2 mu 6.47 6.50 4.26 4.17 -1.05 13.3 1.01 464. 141.
-#> 3 tau 5.22 4.49 3.59 3.40 0.984 12.2 1.04 115. 122.
-#> 4 theta[1] 9.21 8.56 7.05 6.14 -1.40 21.8 1.01 427. 239.
-#> 5 theta[2] 6.77 6.75 5.62 5.20 -2.79 15.9 1.01 718. 443.
-#> 6 theta[3] 5.35 5.83 6.82 5.87 -6.13 15.5 1.01 1103. 1908.
-#> 7 theta[4] 6.84 6.85 5.86 5.44 -2.42 16.6 1.01 923. 2076.
-#> 8 theta[5] 4.64 4.91 5.62 5.40 -4.88 13.4 1.01 775. 1603.
-#> 9 theta[6] 5.51 5.70 6.05 5.48 -4.39 15.1 1.01 639. 1878.
-#> 10 theta[7] 8.94 8.42 6.14 5.47 -0.805 19.6 1.02 272. 164.
-#> 11 theta[8] 7.08 6.94 6.75 5.70 -3.52 18.0 1.01 969. 1764.
+#> 1 lp__ -58.4 -58.5 5.06 5.42 -66.4 -50.2 1.02 139. 71.0
+#> 2 mu 6.36 6.39 4.24 4.27 -0.684 13.0 1.01 487. 345.
+#> 3 tau 5.42 4.61 3.53 3.33 1.25 12.3 1.02 136. 67.5
+#> 4 theta[1] 9.11 8.41 7.20 6.29 -1.35 21.8 1.01 774. 601.
+#> 5 theta[2] 6.65 6.69 5.88 5.59 -2.86 16.2 1.01 1011. 2093.
+#> 6 theta[3] 5.38 5.61 6.74 6.18 -5.83 15.9 1.01 863. 1953.
+#> 7 theta[4] 6.59 6.59 6.01 5.73 -2.94 16.6 1.01 946. 2109.
+#> 8 theta[5] 4.37 4.72 5.66 5.51 -5.63 12.8 1.01 745. 2276.
+#> 9 theta[6] 5.28 5.49 5.96 5.60 -4.99 14.6 1.01 879. 1751.
+#> 10 theta[7] 9.06 8.65 6.17 5.72 -0.151 20.1 1.01 678. 1072.
+#> 11 theta[8] 6.91 6.84 6.86 6.09 -4.10 17.8 1.01 939. 2286.
print_example_program("schools_ncp")
#> data {
@@ -295,36 +295,35 @@ Examples
fit_schools_ncp_mcmc <- cmdstanr_example("schools_ncp")
fit_schools_ncp_mcmc$summary()
#> # A tibble: 19 × 10
-#> variable mean median sd mad q5 q95 rhat ess_bulk
-#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -46.9 -46.6 2.47 2.39 -51.5 -43.5 1.00 1443.
-#> 2 mu 6.50 6.57 4.25 4.13 -0.446 13.4 1.00 2941.
-#> 3 tau 4.78 3.91 3.74 3.46 0.374 12.1 1.00 1743.
-#> 4 theta_raw[1] 0.372 0.381 0.989 0.951 -1.28 1.97 1.00 3537.
-#> 5 theta_raw[2] 0.0565 0.0620 0.915 0.928 -1.45 1.53 1.00 4450.
-#> 6 theta_raw[3] -0.148 -0.163 0.938 0.932 -1.65 1.40 1.00 3407.
-#> 7 theta_raw[4] 0.00702 0.00718 0.937 0.912 -1.55 1.53 1.00 3544.
-#> 8 theta_raw[5] -0.264 -0.271 0.896 0.870 -1.70 1.23 1.00 3495.
-#> 9 theta_raw[6] -0.148 -0.157 0.950 0.938 -1.68 1.43 1.00 4517.
-#> 10 theta_raw[7] 0.351 0.374 0.924 0.876 -1.23 1.82 1.00 3596.
-#> 11 theta_raw[8] 0.0685 0.0540 0.960 0.970 -1.52 1.64 1.00 3657.
-#> 12 theta[1] 8.96 8.30 6.79 5.56 -0.975 21.5 1.00 3374.
-#> 13 theta[2] 6.90 6.72 5.56 5.25 -2.07 16.0 1.00 4663.
-#> 14 theta[3] 5.58 5.91 6.35 5.42 -5.10 15.2 1.00 3392.
-#> 15 theta[4] 6.67 6.72 6.02 5.40 -2.96 16.2 1.00 3971.
-#> 16 theta[5] 4.81 5.19 5.50 5.21 -4.81 12.9 1.00 4119.
-#> 17 theta[6] 5.55 5.86 5.93 5.29 -4.38 14.7 1.00 4010.
-#> 18 theta[7] 8.73 8.24 5.88 5.28 -0.0503 19.3 1.00 3955.
-#> 19 theta[8] 7.01 6.84 6.39 5.49 -3.28 17.9 1.00 3861.
-#> # ℹ 1 more variable: ess_tail <dbl>
+#> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail
+#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 lp__ -46.9 -4.66e+1 2.49 2.36 -51.6 -43.6 1.00 1229. 1844.
+#> 2 mu 6.43 6.46e+0 4.08 3.93 -0.238 13.1 1.00 2985. 2197.
+#> 3 tau 4.74 4.03e+0 3.70 3.41 0.334 11.9 1.00 1724. 1496.
+#> 4 theta_r… 0.351 3.53e-1 0.979 0.955 -1.26 1.96 1.00 3404. 2385.
+#> 5 theta_r… 0.0484 6.67e-2 0.924 0.913 -1.49 1.53 1.00 3680. 2435.
+#> 6 theta_r… -0.131 -1.50e-1 0.962 0.938 -1.71 1.50 1.00 3067. 2557.
+#> 7 theta_r… 0.0221 5.18e-3 0.919 0.905 -1.49 1.59 1.00 3748. 2583.
+#> 8 theta_r… -0.273 -3.14e-1 0.931 0.892 -1.77 1.34 1.00 4139. 2891.
+#> 9 theta_r… -0.157 -1.57e-1 0.930 0.929 -1.69 1.36 1.00 3560. 2797.
+#> 10 theta_r… 0.363 4.01e-1 0.924 0.911 -1.15 1.87 1.00 3687. 2941.
+#> 11 theta_r… 0.0558 7.25e-2 0.951 0.924 -1.55 1.65 1.00 4077. 2555.
+#> 12 theta[1] 8.85 8.09e+0 6.85 5.77 -0.638 21.2 1.00 2994. 2531.
+#> 13 theta[2] 6.79 6.75e+0 5.59 5.01 -2.46 15.9 1.00 4593. 3367.
+#> 14 theta[3] 5.40 5.88e+0 6.64 5.63 -5.94 15.5 1.00 3448. 3181.
+#> 15 theta[4] 6.65 6.62e+0 5.69 5.09 -2.25 16.0 1.00 4537. 3155.
+#> 16 theta[5] 4.78 5.06e+0 5.54 5.26 -4.69 13.2 1.00 3996. 3191.
+#> 17 theta[6] 5.44 5.63e+0 5.97 5.29 -4.66 14.8 1.00 3934. 2877.
+#> 18 theta[7] 8.83 8.37e+0 5.98 5.56 0.141 19.4 1.00 4104. 3336.
+#> 19 theta[8] 6.89 6.73e+0 6.34 5.33 -3.03 17.1 1.00 3988. 3025.
# optimization fails for hierarchical model
cmdstanr_example("schools", "optimize", quiet = FALSE)
-#> Initial log joint probability = -319.937
+#> Initial log joint probability = -56.2449
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 99 120.913 0.248985 3.76333e+09 1 1 183
+#> 99 121.706 0.109668 2.48002e+09 1 1 174
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 180 242.851 0.0892321 2.24452e+16 1e-12 0.001 378 LS failed, Hessian reset
+#> 187 244.785 0.253817 8.00296 1e-12 0.001 400 LS failed, Hessian reset
#> Line search failed to achieve a sufficient decrease, no more progress can be made
#> Chain 1 Optimization terminated with error:
#> Warning: Fitting finished unexpectedly! Use the $output() method for more information.
diff --git a/docs/reference/draws_to_csv.html b/docs/reference/draws_to_csv.html
index 9f523602..355224d7 100644
--- a/docs/reference/draws_to_csv.html
+++ b/docs/reference/draws_to_csv.html
@@ -169,10 +169,10 @@ Examples
draws_csv_files <- draws_to_csv(draws)
print(draws_csv_files)
-#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpGCiVFY/fittedParams-202311081026-1-7ea6a2.csv"
-#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpGCiVFY/fittedParams-202311081026-2-7ea6a2.csv"
-#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpGCiVFY/fittedParams-202311081026-3-7ea6a2.csv"
-#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpGCiVFY/fittedParams-202311081026-4-7ea6a2.csv"
+#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpAMFHpW/fittedParams-202312131001-1-1dd4e6.csv"
+#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpAMFHpW/fittedParams-202312131001-2-1dd4e6.csv"
+#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpAMFHpW/fittedParams-202312131001-3-1dd4e6.csv"
+#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpAMFHpW/fittedParams-202312131001-4-1dd4e6.csv"
# draws_csv_files <- draws_to_csv(draws,
# sampler_diagnostic = sampler_diagnostics,
diff --git a/docs/reference/fit-method-cmdstan_summary.html b/docs/reference/fit-method-cmdstan_summary.html
index 2ab3dc62..47d7f8f7 100644
--- a/docs/reference/fit-method-cmdstan_summary.html
+++ b/docs/reference/fit-method-cmdstan_summary.html
@@ -149,7 +149,7 @@ Examples
# \dontrun{
fit <- cmdstanr_example("logistic")
fit$cmdstan_diagnose()
-#> Processing csv files: /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081026-1-1f791d.csv, /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081026-2-1f791d.csv, /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081026-3-1f791d.csv, /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081026-4-1f791d.csv
+#> Processing csv files: /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131001-1-2718e9.csv, /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131001-2-2718e9.csv, /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131001-3-2718e9.csv, /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131001-4-2718e9.csv
#>
#> Checking sampler transitions treedepth.
#> Treedepth satisfactory for all transitions.
@@ -169,123 +169,123 @@ Examples
#> Inference for Stan model: logistic_model
#> 4 chains: each with iter=(1000,1000,1000,1000); warmup=(0,0,0,0); thin=(1,1,1,1); 4000 iterations saved.
#>
-#> Warmup took (0.023, 0.023, 0.023, 0.023) seconds, 0.092 seconds total
-#> Sampling took (0.076, 0.070, 0.072, 0.073) seconds, 0.29 seconds total
+#> Warmup took (0.022, 0.023, 0.023, 0.023) seconds, 0.091 seconds total
+#> Sampling took (0.071, 0.070, 0.070, 0.070) seconds, 0.28 seconds total
#>
#> Mean MCSE StdDev 5% 50% 95% N_Eff N_Eff/s R_hat
#>
-#> lp__ -6.6e+01 3.0e-02 1.4 -69 -6.6e+01 -6.4e+01 2277 7826 1.0
-#> accept_stat__ 0.89 1.8e-03 0.12 0.63 0.94 1.0 4996 17168 1.0e+00
-#> stepsize__ 0.80 4.6e-02 0.066 0.73 0.85 0.88 2.0 6.9 2.6e+13
-#> treedepth__ 2.3 8.8e-02 0.50 2.0 2.0 3.0 32 109 1.0e+00
-#> n_leapfrog__ 4.8 2.8e-01 2.0 3.0 3.0 7.0 53 182 1.0e+00
+#> lp__ -6.6e+01 3.1e-02 1.4 -69 -6.6e+01 -6.4e+01 2120 7545 1.0
+#> accept_stat__ 0.91 1.4e-03 0.10 0.69 0.95 1.0 5437 19350 1.0e+00
+#> stepsize__ 0.74 2.1e-02 0.030 0.70 0.75 0.78 2.0 7.1 1.1e+13
+#> treedepth__ 2.4 8.8e-03 0.53 2.0 2.0 3.0 3601 12815 1.0e+00
+#> n_leapfrog__ 5.3 3.3e-02 2.0 3.0 7.0 7.0 3773 13428 1.0e+00
#> divergent__ 0.00 nan 0.00 0.00 0.00 0.00 nan nan nan
-#> energy__ 68 4.5e-02 2.0 65 68 72 1941 6671 1.0e+00
+#> energy__ 68 4.9e-02 2.0 65 68 72 1750 6227 1.0e+00
#>
-#> alpha 3.8e-01 3.5e-03 0.22 0.014 3.8e-01 7.4e-01 4054 13931 1.0
-#> beta[1] -6.7e-01 3.7e-03 0.25 -1.1 -6.7e-01 -2.8e-01 4566 15692 1.0
-#> beta[2] -2.8e-01 3.9e-03 0.23 -0.66 -2.8e-01 9.5e-02 3521 12100 1.0
-#> beta[3] 6.8e-01 4.0e-03 0.26 0.25 6.8e-01 1.1e+00 4334 14894 1.0
-#> log_lik[1] -5.2e-01 1.6e-03 0.10 -0.69 -5.1e-01 -3.6e-01 4009 13775 1.0
-#> log_lik[2] -4.0e-01 2.2e-03 0.15 -0.69 -3.8e-01 -1.9e-01 4671 16052 1.0
-#> log_lik[3] -5.0e-01 3.7e-03 0.22 -0.91 -4.7e-01 -2.1e-01 3570 12267 1.0
-#> log_lik[4] -4.5e-01 2.4e-03 0.15 -0.72 -4.3e-01 -2.3e-01 3825 13143 1.0
-#> log_lik[5] -1.2e+00 4.1e-03 0.28 -1.7 -1.2e+00 -7.6e-01 4632 15916 1.0
-#> log_lik[6] -5.9e-01 2.8e-03 0.19 -0.93 -5.7e-01 -3.2e-01 4602 15813 1.0
-#> log_lik[7] -6.4e-01 1.9e-03 0.13 -0.86 -6.3e-01 -4.5e-01 4425 15206 1.0
-#> log_lik[8] -2.7e-01 2.3e-03 0.14 -0.54 -2.5e-01 -1.0e-01 3551 12204 1.0
-#> log_lik[9] -6.9e-01 2.6e-03 0.17 -0.99 -6.8e-01 -4.4e-01 4396 15105 1.0
-#> log_lik[10] -7.5e-01 4.0e-03 0.24 -1.2 -7.2e-01 -4.1e-01 3524 12111 1.0
-#> log_lik[11] -2.8e-01 1.9e-03 0.12 -0.51 -2.6e-01 -1.2e-01 4067 13978 1.00
-#> log_lik[12] -5.0e-01 3.5e-03 0.24 -0.94 -4.6e-01 -1.9e-01 4672 16056 1.00
-#> log_lik[13] -6.6e-01 3.0e-03 0.21 -1.0 -6.4e-01 -3.6e-01 4681 16086 1.0
-#> log_lik[14] -3.6e-01 2.9e-03 0.17 -0.69 -3.3e-01 -1.4e-01 3667 12602 1.0
-#> log_lik[15] -2.8e-01 1.6e-03 0.11 -0.47 -2.6e-01 -1.4e-01 4253 14617 1.0
-#> log_lik[16] -2.7e-01 1.5e-03 0.087 -0.43 -2.6e-01 -1.5e-01 3572 12276 1.0
-#> log_lik[17] -1.6e+00 4.6e-03 0.29 -2.1 -1.6e+00 -1.2e+00 3940 13539 1.00
-#> log_lik[18] -4.8e-01 1.7e-03 0.11 -0.68 -4.7e-01 -3.1e-01 4208 14461 1.0
-#> log_lik[19] -2.3e-01 1.3e-03 0.075 -0.37 -2.2e-01 -1.2e-01 3488 11985 1.00
-#> log_lik[20] -1.1e-01 1.3e-03 0.078 -0.26 -9.3e-02 -2.8e-02 3400 11685 1.0
-#> log_lik[21] -2.1e-01 1.4e-03 0.086 -0.37 -2.0e-01 -9.3e-02 3747 12875 1.0
-#> log_lik[22] -5.7e-01 2.3e-03 0.15 -0.84 -5.5e-01 -3.5e-01 4159 14294 1.0
-#> log_lik[23] -3.3e-01 2.3e-03 0.14 -0.60 -3.0e-01 -1.4e-01 3876 13319 1.0
-#> log_lik[24] -1.3e-01 1.1e-03 0.066 -0.26 -1.2e-01 -5.1e-02 3311 11379 1.0
-#> log_lik[25] -4.5e-01 1.9e-03 0.12 -0.67 -4.4e-01 -2.7e-01 4263 14650 1.0
-#> log_lik[26] -1.5e+00 4.9e-03 0.34 -2.1 -1.5e+00 -1.0e+00 4863 16712 1.00
-#> log_lik[27] -3.0e-01 1.9e-03 0.12 -0.53 -2.9e-01 -1.4e-01 3942 13545 1.0
-#> log_lik[28] -4.4e-01 1.3e-03 0.085 -0.59 -4.4e-01 -3.1e-01 4011 13785 1.0
-#> log_lik[29] -7.2e-01 3.4e-03 0.23 -1.1 -6.9e-01 -3.9e-01 4401 15125 1.0
-#> log_lik[30] -6.9e-01 2.9e-03 0.20 -1.0 -6.7e-01 -4.0e-01 4483 15406 1.0
-#> log_lik[31] -4.9e-01 2.5e-03 0.16 -0.78 -4.7e-01 -2.6e-01 4140 14226 1.0
-#> log_lik[32] -4.2e-01 1.6e-03 0.11 -0.61 -4.1e-01 -2.7e-01 4397 15110 1.0
-#> log_lik[33] -4.1e-01 1.9e-03 0.13 -0.64 -4.0e-01 -2.2e-01 4495 15446 1.0
-#> log_lik[34] -6.2e-02 8.6e-04 0.050 -0.16 -4.8e-02 -1.2e-02 3377 11605 1.0
-#> log_lik[35] -5.8e-01 2.5e-03 0.18 -0.90 -5.6e-01 -3.2e-01 5084 17471 1.00
-#> log_lik[36] -3.2e-01 2.0e-03 0.13 -0.56 -3.0e-01 -1.4e-01 4311 14814 1.0
-#> log_lik[37] -7.1e-01 3.7e-03 0.23 -1.1 -6.8e-01 -3.8e-01 3857 13253 1.0
-#> log_lik[38] -3.1e-01 2.3e-03 0.15 -0.58 -2.8e-01 -1.2e-01 3910 13435 1.0
-#> log_lik[39] -1.8e-01 1.8e-03 0.11 -0.39 -1.5e-01 -5.3e-02 3559 12229 1.0
-#> log_lik[40] -6.8e-01 2.0e-03 0.13 -0.92 -6.7e-01 -4.8e-01 4390 15085 1.0
-#> log_lik[41] -1.1e+00 4.2e-03 0.26 -1.6 -1.1e+00 -7.5e-01 3790 13024 1.0
-#> log_lik[42] -9.3e-01 3.1e-03 0.20 -1.3 -9.1e-01 -6.3e-01 4446 15278 1.0
-#> log_lik[43] -4.0e-01 3.5e-03 0.25 -0.89 -3.5e-01 -1.0e-01 5239 18003 1.00
-#> log_lik[44] -1.2e+00 3.0e-03 0.19 -1.5 -1.2e+00 -8.9e-01 3904 13415 1.0
-#> log_lik[45] -3.6e-01 1.8e-03 0.12 -0.57 -3.4e-01 -1.9e-01 4092 14061 1.0
-#> log_lik[46] -5.8e-01 2.0e-03 0.13 -0.82 -5.7e-01 -3.8e-01 4539 15598 1.0
-#> log_lik[47] -3.0e-01 2.0e-03 0.13 -0.55 -2.8e-01 -1.3e-01 4158 14288 1.0
-#> log_lik[48] -3.2e-01 1.3e-03 0.083 -0.47 -3.1e-01 -2.0e-01 4285 14726 1.00
-#> log_lik[49] -3.2e-01 1.3e-03 0.080 -0.46 -3.1e-01 -2.0e-01 3835 13178 1.0
-#> log_lik[50] -1.3e+00 4.6e-03 0.33 -1.9 -1.3e+00 -8.0e-01 5110 17559 1.00
-#> log_lik[51] -2.9e-01 1.4e-03 0.094 -0.45 -2.7e-01 -1.5e-01 4316 14833 1.00
-#> log_lik[52] -8.3e-01 2.3e-03 0.14 -1.1 -8.3e-01 -6.1e-01 4123 14167 1.0
-#> log_lik[53] -4.0e-01 2.0e-03 0.13 -0.64 -3.8e-01 -2.2e-01 3978 13669 1.0
-#> log_lik[54] -3.7e-01 2.2e-03 0.14 -0.63 -3.5e-01 -1.8e-01 4204 14447 1.0
-#> log_lik[55] -3.9e-01 2.0e-03 0.14 -0.64 -3.7e-01 -1.9e-01 4560 15671 1.0
-#> log_lik[56] -3.1e-01 2.9e-03 0.19 -0.68 -2.7e-01 -8.9e-02 4172 14335 1.0
-#> log_lik[57] -6.6e-01 1.9e-03 0.12 -0.87 -6.5e-01 -4.8e-01 4000 13747 1.0
-#> log_lik[58] -9.6e-01 5.3e-03 0.35 -1.6 -9.1e-01 -4.6e-01 4421 15193 1.0
-#> log_lik[59] -1.4e+00 5.3e-03 0.35 -2.0 -1.3e+00 -8.4e-01 4356 14970 1.0
-#> log_lik[60] -9.8e-01 2.5e-03 0.16 -1.3 -9.7e-01 -7.3e-01 4051 13921 1.0
-#> log_lik[61] -5.4e-01 1.5e-03 0.10 -0.71 -5.3e-01 -3.9e-01 4197 14422 1.0
-#> log_lik[62] -8.8e-01 4.6e-03 0.31 -1.4 -8.4e-01 -4.4e-01 4561 15674 1.00
-#> log_lik[63] -1.1e-01 1.3e-03 0.072 -0.26 -9.8e-02 -3.2e-02 3248 11162 1.0
-#> log_lik[64] -9.1e-01 3.9e-03 0.26 -1.4 -8.9e-01 -5.3e-01 4383 15063 1.0
-#> log_lik[65] -2.0e+00 9.5e-03 0.59 -3.0 -2.0e+00 -1.1e+00 3828 13154 1.00
-#> log_lik[66] -5.1e-01 2.0e-03 0.13 -0.75 -5.0e-01 -3.1e-01 4591 15777 1.0
-#> log_lik[67] -2.7e-01 1.3e-03 0.082 -0.42 -2.7e-01 -1.6e-01 3737 12841 1.00
-#> log_lik[68] -1.1e+00 3.9e-03 0.24 -1.5 -1.1e+00 -7.0e-01 3952 13582 1.0
-#> log_lik[69] -4.4e-01 1.3e-03 0.085 -0.59 -4.3e-01 -3.1e-01 3944 13552 1.0
-#> log_lik[70] -6.3e-01 3.4e-03 0.24 -1.1 -6.0e-01 -3.0e-01 5018 17243 1.0
-#> log_lik[71] -6.1e-01 2.8e-03 0.21 -0.98 -5.9e-01 -3.2e-01 5227 17963 1.00
-#> log_lik[72] -4.6e-01 2.6e-03 0.17 -0.78 -4.4e-01 -2.3e-01 4552 15644 1.0
-#> log_lik[73] -1.5e+00 5.9e-03 0.37 -2.2 -1.5e+00 -9.4e-01 3999 13742 1.0
-#> log_lik[74] -9.4e-01 3.0e-03 0.19 -1.3 -9.3e-01 -6.5e-01 4092 14063 1.0
-#> log_lik[75] -1.1e+00 5.6e-03 0.38 -1.8 -1.1e+00 -5.9e-01 4639 15941 1.00
-#> log_lik[76] -3.7e-01 2.3e-03 0.14 -0.63 -3.5e-01 -1.8e-01 3728 12812 1.0
-#> log_lik[77] -8.8e-01 2.2e-03 0.14 -1.1 -8.7e-01 -6.6e-01 4154 14274 1.0
-#> log_lik[78] -4.9e-01 2.4e-03 0.17 -0.80 -4.7e-01 -2.5e-01 4939 16971 1.00
-#> log_lik[79] -7.7e-01 3.2e-03 0.19 -1.1 -7.5e-01 -4.9e-01 3734 12831 1.0
-#> log_lik[80] -5.5e-01 2.8e-03 0.20 -0.91 -5.2e-01 -2.7e-01 5052 17361 1.0
-#> log_lik[81] -1.6e-01 1.6e-03 0.100 -0.35 -1.4e-01 -4.6e-02 4042 13890 1.0
-#> log_lik[82] -2.2e-01 2.1e-03 0.14 -0.50 -1.9e-01 -6.1e-02 4473 15371 1.0
-#> log_lik[83] -3.4e-01 1.3e-03 0.081 -0.49 -3.4e-01 -2.2e-01 3946 13559 1.0
-#> log_lik[84] -2.8e-01 1.4e-03 0.091 -0.44 -2.6e-01 -1.5e-01 4018 13807 1.0
-#> log_lik[85] -1.3e-01 1.3e-03 0.074 -0.27 -1.1e-01 -4.2e-02 3489 11990 1.0
-#> log_lik[86] -1.1e+00 4.7e-03 0.32 -1.7 -1.1e+00 -6.4e-01 4742 16295 1.0
-#> log_lik[87] -8.3e-01 2.0e-03 0.13 -1.0 -8.2e-01 -6.2e-01 4289 14739 1.0
-#> log_lik[88] -7.8e-01 3.5e-03 0.24 -1.2 -7.5e-01 -4.3e-01 4606 15828 1.00
-#> log_lik[89] -1.3e+00 4.9e-03 0.32 -1.9 -1.3e+00 -7.9e-01 4346 14936 1.0
-#> log_lik[90] -2.6e-01 2.1e-03 0.13 -0.51 -2.3e-01 -9.0e-02 4192 14407 1.00
-#> log_lik[91] -3.9e-01 1.9e-03 0.13 -0.62 -3.7e-01 -2.0e-01 4638 15940 1.0
-#> log_lik[92] -1.5e+00 5.2e-03 0.34 -2.1 -1.5e+00 -9.9e-01 4259 14636 1.0
-#> log_lik[93] -7.3e-01 3.6e-03 0.22 -1.1 -7.1e-01 -4.2e-01 3742 12858 1.0
-#> log_lik[94] -3.2e-01 1.4e-03 0.088 -0.48 -3.1e-01 -1.9e-01 3956 13596 1.0
-#> log_lik[95] -3.9e-01 1.8e-03 0.11 -0.59 -3.8e-01 -2.3e-01 3846 13217 1.0
-#> log_lik[96] -1.6e+00 4.5e-03 0.28 -2.1 -1.6e+00 -1.1e+00 3868 13293 1.0
-#> log_lik[97] -4.3e-01 1.5e-03 0.10 -0.61 -4.2e-01 -2.7e-01 4724 16235 1.0
-#> log_lik[98] -1.1e+00 5.5e-03 0.37 -1.7 -1.0e+00 -5.2e-01 4560 15668 1.0
-#> log_lik[99] -7.0e-01 2.2e-03 0.15 -0.95 -6.8e-01 -4.7e-01 4389 15084 1.0
-#> log_lik[100] -3.9e-01 1.5e-03 0.097 -0.56 -3.8e-01 -2.5e-01 4436 15244 1.00
+#> alpha 3.8e-01 3.5e-03 0.22 0.026 3.8e-01 7.5e-01 3978 14156 1.00
+#> beta[1] -6.7e-01 4.1e-03 0.26 -1.1 -6.6e-01 -2.6e-01 3779 13447 1.0
+#> beta[2] -2.7e-01 3.5e-03 0.23 -0.64 -2.7e-01 1.0e-01 4061 14450 1.0
+#> beta[3] 6.7e-01 4.3e-03 0.27 0.24 6.7e-01 1.1e+00 3879 13804 1.00
+#> log_lik[1] -5.1e-01 1.5e-03 0.097 -0.68 -5.1e-01 -3.7e-01 3951 14060 1.00
+#> log_lik[2] -4.1e-01 2.3e-03 0.15 -0.69 -3.9e-01 -1.9e-01 4167 14830 1.00
+#> log_lik[3] -4.9e-01 3.3e-03 0.21 -0.88 -4.6e-01 -2.1e-01 4010 14272 1.00
+#> log_lik[4] -4.5e-01 2.5e-03 0.15 -0.72 -4.4e-01 -2.4e-01 3751 13350 1.0
+#> log_lik[5] -1.2e+00 4.4e-03 0.28 -1.7 -1.2e+00 -7.6e-01 4068 14476 1.0
+#> log_lik[6] -5.9e-01 3.0e-03 0.19 -0.96 -5.7e-01 -3.2e-01 4275 15213 1.0
+#> log_lik[7] -6.4e-01 2.0e-03 0.13 -0.86 -6.4e-01 -4.5e-01 4183 14885 1.0
+#> log_lik[8] -2.8e-01 2.3e-03 0.14 -0.55 -2.5e-01 -1.1e-01 3659 13021 1.0
+#> log_lik[9] -6.9e-01 2.7e-03 0.17 -1.0 -6.7e-01 -4.4e-01 4128 14690 1.0
+#> log_lik[10] -7.3e-01 3.6e-03 0.22 -1.1 -7.1e-01 -4.1e-01 3894 13857 1.00
+#> log_lik[11] -2.8e-01 2.1e-03 0.13 -0.54 -2.6e-01 -1.1e-01 3822 13601 1.00
+#> log_lik[12] -5.0e-01 3.8e-03 0.24 -0.95 -4.6e-01 -1.9e-01 3952 14065 1.00
+#> log_lik[13] -6.6e-01 3.3e-03 0.21 -1.0 -6.4e-01 -3.5e-01 4181 14878 1.0
+#> log_lik[14] -3.6e-01 2.6e-03 0.17 -0.67 -3.2e-01 -1.4e-01 4021 14308 1.00
+#> log_lik[15] -2.8e-01 1.7e-03 0.10 -0.47 -2.6e-01 -1.3e-01 3858 13730 1.00
+#> log_lik[16] -2.8e-01 1.5e-03 0.091 -0.44 -2.7e-01 -1.5e-01 3706 13189 1.00
+#> log_lik[17] -1.6e+00 5.0e-03 0.30 -2.1 -1.6e+00 -1.1e+00 3612 12854 1.0
+#> log_lik[18] -4.8e-01 1.8e-03 0.11 -0.68 -4.7e-01 -3.1e-01 4081 14523 1.0
+#> log_lik[19] -2.3e-01 1.3e-03 0.079 -0.37 -2.2e-01 -1.2e-01 3751 13347 1.0
+#> log_lik[20] -1.1e-01 1.3e-03 0.078 -0.26 -9.4e-02 -2.8e-02 3798 13516 1.00
+#> log_lik[21] -2.1e-01 1.5e-03 0.091 -0.39 -2.0e-01 -9.3e-02 3626 12906 1.00
+#> log_lik[22] -5.7e-01 2.4e-03 0.15 -0.86 -5.5e-01 -3.5e-01 4061 14452 1.0
+#> log_lik[23] -3.3e-01 2.3e-03 0.15 -0.61 -3.1e-01 -1.4e-01 3872 13780 1.0
+#> log_lik[24] -1.4e-01 1.1e-03 0.069 -0.27 -1.2e-01 -5.1e-02 3743 13321 1.00
+#> log_lik[25] -4.6e-01 1.9e-03 0.12 -0.68 -4.5e-01 -2.8e-01 3975 14145 1.0
+#> log_lik[26] -1.5e+00 5.8e-03 0.35 -2.1 -1.5e+00 -1.0e+00 3699 13164 1.0
+#> log_lik[27] -3.1e-01 2.0e-03 0.13 -0.55 -2.9e-01 -1.4e-01 3831 13633 1.00
+#> log_lik[28] -4.4e-01 1.4e-03 0.086 -0.59 -4.4e-01 -3.1e-01 3970 14130 1.0
+#> log_lik[29] -7.3e-01 3.4e-03 0.22 -1.1 -7.1e-01 -4.0e-01 4258 15153 1.0
+#> log_lik[30] -6.9e-01 3.1e-03 0.20 -1.1 -6.8e-01 -4.0e-01 4121 14666 1.00
+#> log_lik[31] -4.9e-01 2.6e-03 0.17 -0.81 -4.7e-01 -2.5e-01 4046 14398 1.0
+#> log_lik[32] -4.2e-01 1.7e-03 0.11 -0.62 -4.1e-01 -2.6e-01 3986 14185 1.0
+#> log_lik[33] -4.1e-01 2.0e-03 0.13 -0.65 -4.0e-01 -2.2e-01 4122 14669 1.0
+#> log_lik[34] -6.5e-02 9.1e-04 0.054 -0.17 -5.0e-02 -1.3e-02 3544 12612 1.0
+#> log_lik[35] -5.9e-01 2.8e-03 0.18 -0.92 -5.7e-01 -3.2e-01 4411 15696 1.0
+#> log_lik[36] -3.3e-01 2.2e-03 0.14 -0.58 -3.0e-01 -1.4e-01 4001 14239 1.0
+#> log_lik[37] -6.9e-01 3.4e-03 0.22 -1.1 -6.7e-01 -3.7e-01 4045 14394 1.0
+#> log_lik[38] -3.2e-01 2.4e-03 0.15 -0.60 -2.9e-01 -1.2e-01 3854 13717 1.0
+#> log_lik[39] -1.8e-01 1.7e-03 0.11 -0.38 -1.5e-01 -5.2e-02 3915 13934 1.00
+#> log_lik[40] -6.8e-01 2.1e-03 0.13 -0.92 -6.7e-01 -4.8e-01 4145 14752 1.0
+#> log_lik[41] -1.1e+00 4.2e-03 0.26 -1.6 -1.1e+00 -7.3e-01 3929 13983 1.0
+#> log_lik[42] -9.3e-01 3.2e-03 0.20 -1.3 -9.1e-01 -6.3e-01 3967 14116 1.0
+#> log_lik[43] -4.1e-01 4.0e-03 0.26 -0.91 -3.4e-01 -1.0e-01 4191 14913 1.0
+#> log_lik[44] -1.2e+00 3.1e-03 0.19 -1.5 -1.2e+00 -9.0e-01 3709 13201 1.00
+#> log_lik[45] -3.6e-01 1.8e-03 0.11 -0.56 -3.4e-01 -1.9e-01 4009 14267 1.00
+#> log_lik[46] -5.9e-01 2.0e-03 0.13 -0.82 -5.8e-01 -3.8e-01 4248 15119 1.00
+#> log_lik[47] -3.1e-01 2.2e-03 0.13 -0.55 -2.9e-01 -1.3e-01 3696 13153 1.0
+#> log_lik[48] -3.2e-01 1.4e-03 0.085 -0.47 -3.2e-01 -2.0e-01 3847 13691 1.0
+#> log_lik[49] -3.2e-01 1.3e-03 0.082 -0.46 -3.1e-01 -2.0e-01 3716 13223 1.00
+#> log_lik[50] -1.3e+00 5.4e-03 0.33 -1.9 -1.3e+00 -8.1e-01 3859 13734 1.0
+#> log_lik[51] -2.9e-01 1.6e-03 0.096 -0.46 -2.8e-01 -1.5e-01 3714 13218 1.0
+#> log_lik[52] -8.4e-01 2.2e-03 0.14 -1.1 -8.3e-01 -6.2e-01 3985 14182 1.00
+#> log_lik[53] -4.0e-01 2.1e-03 0.13 -0.66 -3.9e-01 -2.1e-01 3970 14127 1.00
+#> log_lik[54] -3.7e-01 2.2e-03 0.14 -0.62 -3.5e-01 -1.8e-01 4008 14263 1.00
+#> log_lik[55] -3.9e-01 2.2e-03 0.14 -0.65 -3.7e-01 -1.9e-01 4107 14614 1.00
+#> log_lik[56] -3.2e-01 3.2e-03 0.20 -0.70 -2.8e-01 -9.3e-02 3745 13326 1.0
+#> log_lik[57] -6.5e-01 1.8e-03 0.12 -0.85 -6.5e-01 -4.8e-01 3918 13943 1.0
+#> log_lik[58] -9.4e-01 5.3e-03 0.35 -1.6 -9.0e-01 -4.5e-01 4317 15364 1.0
+#> log_lik[59] -1.4e+00 5.7e-03 0.35 -2.0 -1.3e+00 -8.4e-01 3801 13527 1.0
+#> log_lik[60] -9.8e-01 2.5e-03 0.16 -1.3 -9.7e-01 -7.4e-01 3902 13886 1.00
+#> log_lik[61] -5.4e-01 1.5e-03 0.097 -0.70 -5.3e-01 -3.9e-01 4078 14513 1.00
+#> log_lik[62] -8.9e-01 5.0e-03 0.31 -1.5 -8.5e-01 -4.4e-01 3852 13708 1.00
+#> log_lik[63] -1.2e-01 1.3e-03 0.077 -0.27 -9.9e-02 -3.2e-02 3330 11849 1.00
+#> log_lik[64] -9.0e-01 3.8e-03 0.25 -1.4 -8.8e-01 -5.3e-01 4445 15817 1.00
+#> log_lik[65] -2.0e+00 9.8e-03 0.61 -3.1 -2.0e+00 -1.1e+00 3783 13462 1.00
+#> log_lik[66] -5.1e-01 2.1e-03 0.13 -0.74 -4.9e-01 -3.1e-01 4154 14782 1.0
+#> log_lik[67] -2.8e-01 1.4e-03 0.085 -0.43 -2.7e-01 -1.6e-01 3827 13618 1.0
+#> log_lik[68] -1.1e+00 3.8e-03 0.24 -1.5 -1.0e+00 -6.8e-01 4102 14597 1.00
+#> log_lik[69] -4.3e-01 1.4e-03 0.085 -0.58 -4.3e-01 -3.0e-01 3842 13673 1.0
+#> log_lik[70] -6.4e-01 3.6e-03 0.24 -1.1 -6.1e-01 -3.1e-01 4371 15555 1.00
+#> log_lik[71] -6.1e-01 3.2e-03 0.21 -0.99 -5.9e-01 -3.1e-01 4401 15663 1.0
+#> log_lik[72] -4.6e-01 2.7e-03 0.17 -0.79 -4.5e-01 -2.2e-01 4214 14996 1.0
+#> log_lik[73] -1.5e+00 6.1e-03 0.37 -2.1 -1.4e+00 -9.2e-01 3671 13065 1.0
+#> log_lik[74] -9.5e-01 3.0e-03 0.19 -1.3 -9.4e-01 -6.7e-01 3944 14035 1.00
+#> log_lik[75] -1.2e+00 6.4e-03 0.39 -1.8 -1.1e+00 -5.9e-01 3678 13088 1.00
+#> log_lik[76] -3.7e-01 2.1e-03 0.13 -0.62 -3.5e-01 -1.8e-01 3976 14151 1.00
+#> log_lik[77] -8.8e-01 2.2e-03 0.14 -1.1 -8.8e-01 -6.6e-01 4034 14357 1.0
+#> log_lik[78] -4.8e-01 2.7e-03 0.17 -0.79 -4.6e-01 -2.4e-01 4097 14581 1.00
+#> log_lik[79] -7.6e-01 2.9e-03 0.18 -1.1 -7.4e-01 -4.8e-01 3889 13840 1.0
+#> log_lik[80] -5.5e-01 3.0e-03 0.20 -0.91 -5.2e-01 -2.7e-01 4407 15683 1.00
+#> log_lik[81] -1.7e-01 1.7e-03 0.10 -0.37 -1.4e-01 -4.8e-02 3780 13450 1.0
+#> log_lik[82] -2.3e-01 2.3e-03 0.14 -0.51 -2.0e-01 -6.3e-02 3943 14031 1.00
+#> log_lik[83] -3.4e-01 1.3e-03 0.081 -0.48 -3.4e-01 -2.2e-01 3766 13404 1.00
+#> log_lik[84] -2.7e-01 1.5e-03 0.090 -0.44 -2.6e-01 -1.4e-01 3767 13405 1.00
+#> log_lik[85] -1.3e-01 1.2e-03 0.075 -0.28 -1.1e-01 -4.1e-02 3780 13453 1.00
+#> log_lik[86] -1.1e+00 5.0e-03 0.32 -1.7 -1.1e+00 -6.4e-01 4173 14850 1.00
+#> log_lik[87] -8.3e-01 2.0e-03 0.13 -1.1 -8.2e-01 -6.2e-01 4183 14887 1.00
+#> log_lik[88] -7.8e-01 3.8e-03 0.24 -1.2 -7.5e-01 -4.2e-01 4157 14794 1.0
+#> log_lik[89] -1.3e+00 5.1e-03 0.32 -1.9 -1.2e+00 -7.9e-01 3879 13805 1.00
+#> log_lik[90] -2.6e-01 2.2e-03 0.14 -0.52 -2.4e-01 -9.4e-02 4008 14262 1.0
+#> log_lik[91] -3.9e-01 2.1e-03 0.13 -0.63 -3.8e-01 -2.1e-01 4144 14746 1.0
+#> log_lik[92] -1.5e+00 5.6e-03 0.34 -2.1 -1.5e+00 -9.7e-01 3829 13625 1.00
+#> log_lik[93] -7.5e-01 3.4e-03 0.21 -1.1 -7.2e-01 -4.4e-01 3888 13835 1.00
+#> log_lik[94] -3.2e-01 1.4e-03 0.087 -0.47 -3.1e-01 -1.9e-01 3803 13533 1.00
+#> log_lik[95] -3.9e-01 1.9e-03 0.12 -0.60 -3.8e-01 -2.2e-01 3889 13841 1.0
+#> log_lik[96] -1.6e+00 4.8e-03 0.29 -2.1 -1.6e+00 -1.1e+00 3601 12815 1.00
+#> log_lik[97] -4.3e-01 1.6e-03 0.10 -0.61 -4.2e-01 -2.7e-01 4067 14472 1.0
+#> log_lik[98] -1.0e+00 5.6e-03 0.37 -1.7 -1.0e+00 -5.2e-01 4342 15452 1.0
+#> log_lik[99] -7.0e-01 2.2e-03 0.15 -0.96 -6.9e-01 -4.7e-01 4351 15484 1.00
+#> log_lik[100] -3.9e-01 1.5e-03 0.097 -0.55 -3.8e-01 -2.4e-01 4019 14301 1.00
#>
#> Samples were drawn using hmc with nuts.
#> For each parameter, N_Eff is a crude measure of effective sample size,
diff --git a/docs/reference/fit-method-diagnostic_summary.html b/docs/reference/fit-method-diagnostic_summary.html
index 97dce2c2..53c45c1c 100644
--- a/docs/reference/fit-method-diagnostic_summary.html
+++ b/docs/reference/fit-method-diagnostic_summary.html
@@ -161,34 +161,29 @@ See also
Examples
# \dontrun{
fit <- cmdstanr_example("schools")
-#> Chain 2 Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
-#> Chain 2 Exception: normal_lpdf: Scale parameter is 0, but must be positive! (in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/model-11d99572dc9ce.stan', line 14, column 2 to column 41)
-#> Chain 2 If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
-#> Chain 2 but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.
-#> Chain 2
-#> Warning: 103 of 4000 (3.0%) transitions ended with a divergence.
+#> Warning: 91 of 4000 (2.0%) transitions ended with a divergence.
#> See https://mc-stan.org/misc/warnings for details.
fit$diagnostic_summary()
-#> Warning: 103 of 4000 (3.0%) transitions ended with a divergence.
+#> Warning: 91 of 4000 (2.0%) transitions ended with a divergence.
#> See https://mc-stan.org/misc/warnings for details.
#> $num_divergent
-#> [1] 2 40 38 23
+#> [1] 12 18 11 50
#>
#> $num_max_treedepth
#> [1] 0 0 0 0
#>
#> $ebfmi
-#> [1] 0.2865692 0.3867145 0.2763028 0.3720129
+#> [1] 0.3003970 0.2974182 0.3438194 0.4920025
#>
fit$diagnostic_summary(quiet = TRUE)
#> $num_divergent
-#> [1] 2 40 38 23
+#> [1] 12 18 11 50
#>
#> $num_max_treedepth
#> [1] 0 0 0 0
#>
#> $ebfmi
-#> [1] 0.2865692 0.3867145 0.2763028 0.3720129
+#> [1] 0.3003970 0.2974182 0.3438194 0.4920025
#>
# }
diff --git a/docs/reference/fit-method-draws-1.png b/docs/reference/fit-method-draws-1.png
index 27dbcc21..a6899fc4 100644
Binary files a/docs/reference/fit-method-draws-1.png and b/docs/reference/fit-method-draws-1.png differ
diff --git a/docs/reference/fit-method-draws-2.png b/docs/reference/fit-method-draws-2.png
index 78e9ff03..fb93238c 100644
Binary files a/docs/reference/fit-method-draws-2.png and b/docs/reference/fit-method-draws-2.png differ
diff --git a/docs/reference/fit-method-draws.html b/docs/reference/fit-method-draws.html
index 1a2ac8f7..b257cb5d 100644
--- a/docs/reference/fit-method-draws.html
+++ b/docs/reference/fit-method-draws.html
@@ -203,7 +203,7 @@ Examples
dim(draws)
#> [1] 1000 4 105
str(draws)
-#> 'draws_array' num [1:1000, 1:4, 1:105] -65.8 -67 -66.3 -66.2 -66.8 ...
+#> 'draws_array' num [1:1000, 1:4, 1:105] -64.2 -65.3 -65.3 -64.7 -64.8 ...
#> - attr(*, "dimnames")=List of 3
#> ..$ iteration: chr [1:1000] "1" "2" "3" "4" ...
#> ..$ chain : chr [1:4] "1" "2" "3" "4"
@@ -215,12 +215,12 @@ Examples
#> # A draws_matrix: 6 iterations, 1 chains, and 105 variables
#> variable
#> draw lp__ alpha beta[1] beta[2] beta[3] log_lik[1] log_lik[2] log_lik[3]
-#> 1 -66 0.24 -0.55 0.09 0.39 -0.52 -0.42 -0.32
-#> 2 -67 0.52 -0.85 -0.20 1.28 -0.46 -0.18 -0.26
-#> 3 -66 0.19 -0.80 -0.31 0.20 -0.54 -0.53 -0.62
-#> 4 -66 0.39 -0.57 -0.68 1.03 -0.59 -0.33 -0.81
-#> 5 -67 0.46 -0.49 -0.63 1.16 -0.57 -0.30 -0.72
-#> 6 -65 0.30 -0.44 -0.21 0.28 -0.54 -0.59 -0.56
+#> 1 -64 0.28 -0.73 -0.16 0.73 -0.53 -0.30 -0.39
+#> 2 -65 0.19 -0.42 -0.13 0.37 -0.59 -0.48 -0.53
+#> 3 -65 0.61 -0.93 -0.25 0.83 -0.40 -0.34 -0.30
+#> 4 -65 0.42 -0.81 -0.32 0.94 -0.50 -0.28 -0.41
+#> 5 -65 0.36 -0.41 -0.20 0.39 -0.52 -0.56 -0.52
+#> 6 -67 0.55 -0.24 -0.43 0.24 -0.49 -0.87 -0.75
#> # ... with 97 more variables
# or can specify 'format' argument to avoid manual conversion
@@ -230,12 +230,12 @@ Examples
#> # A draws_matrix: 6 iterations, 1 chains, and 105 variables
#> variable
#> draw lp__ alpha beta[1] beta[2] beta[3] log_lik[1] log_lik[2] log_lik[3]
-#> 1 -66 0.24 -0.55 0.09 0.39 -0.52 -0.42 -0.32
-#> 2 -67 0.52 -0.85 -0.20 1.28 -0.46 -0.18 -0.26
-#> 3 -66 0.19 -0.80 -0.31 0.20 -0.54 -0.53 -0.62
-#> 4 -66 0.39 -0.57 -0.68 1.03 -0.59 -0.33 -0.81
-#> 5 -67 0.46 -0.49 -0.63 1.16 -0.57 -0.30 -0.72
-#> 6 -65 0.30 -0.44 -0.21 0.28 -0.54 -0.59 -0.56
+#> 1 -64 0.28 -0.73 -0.16 0.73 -0.53 -0.30 -0.39
+#> 2 -65 0.19 -0.42 -0.13 0.37 -0.59 -0.48 -0.53
+#> 3 -65 0.61 -0.93 -0.25 0.83 -0.40 -0.34 -0.30
+#> 4 -65 0.42 -0.81 -0.32 0.94 -0.50 -0.28 -0.41
+#> 5 -65 0.36 -0.41 -0.20 0.39 -0.52 -0.56 -0.52
+#> 6 -67 0.55 -0.24 -0.43 0.24 -0.49 -0.87 -0.75
#> # ... with 97 more variables
# can select specific parameters
@@ -244,12 +244,12 @@ Examples
#> , , variable = alpha
#>
#> chain
-#> iteration 1 2 3 4
-#> 1 0.24 0.310 0.180 0.67
-#> 2 0.52 -0.014 0.351 0.23
-#> 3 0.19 0.366 0.682 0.48
-#> 4 0.39 0.645 0.098 0.49
-#> 5 0.46 0.177 0.677 0.65
+#> iteration 1 2 3 4
+#> 1 0.28 0.27 0.62 0.10
+#> 2 0.19 0.70 0.49 0.71
+#> 3 0.61 0.26 0.89 0.14
+#> 4 0.42 0.39 0.58 0.39
+#> 5 0.36 0.39 0.58 0.48
#>
#> # ... with 995 more iterations
fit$draws("beta") # selects entire vector beta
@@ -258,31 +258,31 @@ Examples
#>
#> chain
#> iteration 1 2 3 4
-#> 1 -0.55 -1.00 -0.41 -0.55
-#> 2 -0.85 -0.45 -0.62 -0.91
-#> 3 -0.80 -0.52 -0.86 -0.50
-#> 4 -0.57 -0.46 -0.50 -0.57
-#> 5 -0.49 -0.97 -1.00 -0.76
+#> 1 -0.73 -0.46 -0.82 -0.55
+#> 2 -0.42 -0.92 -1.18 -1.08
+#> 3 -0.93 -0.52 -0.63 -0.42
+#> 4 -0.81 -0.86 -0.30 -0.72
+#> 5 -0.41 -0.86 -0.30 -0.86
#>
#> , , variable = beta[2]
#>
#> chain
-#> iteration 1 2 3 4
-#> 1 0.09 -0.32 -0.132 -0.091
-#> 2 -0.20 -0.45 -0.283 -0.479
-#> 3 -0.31 -0.25 -0.335 -0.681
-#> 4 -0.68 -0.25 0.093 -0.717
-#> 5 -0.63 -0.23 -0.227 -0.328
+#> iteration 1 2 3 4
+#> 1 -0.16 -0.31 -0.88 -0.18
+#> 2 -0.13 -0.27 -0.69 -0.21
+#> 3 -0.25 -0.39 -0.38 -0.37
+#> 4 -0.32 -0.43 -0.52 -0.36
+#> 5 -0.20 -0.43 -0.52 -0.42
#>
#> , , variable = beta[3]
#>
#> chain
#> iteration 1 2 3 4
-#> 1 0.39 0.47 0.54 0.70
-#> 2 1.28 0.68 0.76 0.83
-#> 3 0.20 0.45 0.66 0.30
-#> 4 1.03 0.30 0.53 0.54
-#> 5 1.16 1.17 0.46 1.29
+#> 1 0.73 0.28 0.87 0.93
+#> 2 0.37 1.26 0.75 0.45
+#> 3 0.83 0.28 0.88 0.83
+#> 4 0.94 0.64 0.71 0.48
+#> 5 0.39 0.64 0.71 0.41
#>
#> # ... with 995 more iterations
fit$draws(c("alpha", "beta[2]"))
@@ -290,22 +290,22 @@ Examples
#> , , variable = alpha
#>
#> chain
-#> iteration 1 2 3 4
-#> 1 0.24 0.310 0.180 0.67
-#> 2 0.52 -0.014 0.351 0.23
-#> 3 0.19 0.366 0.682 0.48
-#> 4 0.39 0.645 0.098 0.49
-#> 5 0.46 0.177 0.677 0.65
+#> iteration 1 2 3 4
+#> 1 0.28 0.27 0.62 0.10
+#> 2 0.19 0.70 0.49 0.71
+#> 3 0.61 0.26 0.89 0.14
+#> 4 0.42 0.39 0.58 0.39
+#> 5 0.36 0.39 0.58 0.48
#>
#> , , variable = beta[2]
#>
#> chain
-#> iteration 1 2 3 4
-#> 1 0.09 -0.32 -0.132 -0.091
-#> 2 -0.20 -0.45 -0.283 -0.479
-#> 3 -0.31 -0.25 -0.335 -0.681
-#> 4 -0.68 -0.25 0.093 -0.717
-#> 5 -0.63 -0.23 -0.227 -0.328
+#> iteration 1 2 3 4
+#> 1 -0.16 -0.31 -0.88 -0.18
+#> 2 -0.13 -0.27 -0.69 -0.21
+#> 3 -0.25 -0.39 -0.38 -0.37
+#> 4 -0.32 -0.43 -0.52 -0.36
+#> 5 -0.20 -0.43 -0.52 -0.42
#>
#> # ... with 995 more iterations
@@ -323,21 +323,21 @@ Examples
#> # A draws_matrix: 6 iterations, 1 chains, and 3 variables
#> variable
#> draw beta[1] beta[2] beta[3]
-#> 1 -0.74 0.09 0.55
-#> 2 -0.76 0.39 0.68
-#> 3 -0.43 -0.15 1.06
-#> 4 -1.15 -0.35 0.54
-#> 5 -0.60 -0.26 0.34
-#> 6 -0.30 -0.24 1.03
+#> 1 -0.62 -0.485 0.63
+#> 2 -0.34 0.188 0.77
+#> 3 -0.63 -0.236 0.90
+#> 4 -0.65 -0.392 0.76
+#> 5 -0.57 0.028 0.44
+#> 6 -0.58 -0.299 0.69
head(fit$draws("beta", format = "df"))
#> # A draws_df: 6 iterations, 1 chains, and 3 variables
#> beta[1] beta[2] beta[3]
-#> 1 -0.74 0.09 0.55
-#> 2 -0.76 0.39 0.68
-#> 3 -0.43 -0.15 1.06
-#> 4 -1.15 -0.35 0.54
-#> 5 -0.60 -0.26 0.34
-#> 6 -0.30 -0.24 1.03
+#> 1 -0.62 -0.485 0.63
+#> 2 -0.34 0.188 0.77
+#> 3 -0.63 -0.236 0.90
+#> 4 -0.65 -0.392 0.76
+#> 5 -0.57 0.028 0.44
+#> 6 -0.58 -0.299 0.69
#> # ... hidden reserved variables {'.chain', '.iteration', '.draw'}
# }
diff --git a/docs/reference/fit-method-grad_log_prob.html b/docs/reference/fit-method-grad_log_prob.html
index 79de7ede..e6dae257 100644
--- a/docs/reference/fit-method-grad_log_prob.html
+++ b/docs/reference/fit-method-grad_log_prob.html
@@ -113,19 +113,26 @@ Calculate the log-probability and the gradient w.r.t. each input for a
- grad_log_prob(unconstrained_variables, jacobian_adjustment = TRUE)
+ grad_log_prob(
+ unconstrained_variables,
+ jacobian = TRUE,
+ jacobian_adjustment = NULL
+)
Arguments
- unconstrained_variables
-(numeric) A vector of unconstrained parameters
-to be passed to grad_log_prob
.
+(numeric) A vector of unconstrained parameters.
+
+
+- jacobian
+(logical) Whether to include the log-density adjustments from
+un/constraining variables.
- jacobian_adjustment
-(logical) Whether to include the log-density
-adjustments from un/constraining variables.
+Deprecated. Please use jacobian
instead.
diff --git a/docs/reference/fit-method-gradients.html b/docs/reference/fit-method-gradients.html
index 828d0688..c682dd04 100644
--- a/docs/reference/fit-method-gradients.html
+++ b/docs/reference/fit-method-gradients.html
@@ -131,11 +131,11 @@ Examples
# retrieve the gradients
test$gradients()
-#> param_idx value model finite_diff error
-#> 1 0 1.376210 -19.10810 -19.10810 5.51201e-09
-#> 2 1 -0.796954 -2.04336 -2.04336 5.51900e-09
-#> 3 2 0.520069 -11.77830 -11.77830 -6.60224e-10
-#> 4 3 0.122833 7.41794 7.41794 4.62926e-08
+#> param_idx value model finite_diff error
+#> 1 0 1.083910 -6.21416 -6.21416 3.58858e-08
+#> 2 1 1.800640 -33.18970 -33.18970 4.38607e-08
+#> 3 2 0.683175 -19.70780 -19.70780 1.73640e-08
+#> 4 3 1.857330 -9.17992 -9.17992 1.12563e-08
# }
diff --git a/docs/reference/fit-method-hessian.html b/docs/reference/fit-method-hessian.html
index b08bb4ea..12bcc5e8 100644
--- a/docs/reference/fit-method-hessian.html
+++ b/docs/reference/fit-method-hessian.html
@@ -113,19 +113,22 @@ Calculate the log-probability , the gradient w.r.t. each input, and the hess
- hessian(unconstrained_variables, jacobian_adjustment = TRUE)
+ hessian(unconstrained_variables, jacobian = TRUE, jacobian_adjustment = TRUE)
Arguments
- unconstrained_variables
-(numeric) A vector of unconstrained parameters
-to be passed to hessian
.
+(numeric) A vector of unconstrained parameters.
+
+
+- jacobian
+(logical) Whether to include the log-density adjustments from
+un/constraining variables.
- jacobian_adjustment
-(logical) Whether to include the log-density
-adjustments from un/constraining variables.
+Deprecated. Please use jacobian
instead.
diff --git a/docs/reference/fit-method-init.html b/docs/reference/fit-method-init.html
index e6001ccc..955ed4b1 100644
--- a/docs/reference/fit-method-init.html
+++ b/docs/reference/fit-method-init.html
@@ -140,11 +140,11 @@ Examples
str(fit$init())
#> List of 2
#> $ :List of 2
-#> ..$ alpha: num 0.865
-#> ..$ beta : num [1:3] -0.0306 -0.1349 1.1272
+#> ..$ alpha: num -0.538
+#> ..$ beta : num [1:3] -0.0289 1.8267 1.6042
#> $ :List of 2
-#> ..$ alpha: num -1.41
-#> ..$ beta : num [1:3] 0.143 -1.043 0.9
+#> ..$ alpha: num -1.4
+#> ..$ beta : num [1:3] -1.313 -1.04 0.224
# partial inits (only specifying for a subset of parameters)
init_list <- list(
diff --git a/docs/reference/fit-method-inv_metric.html b/docs/reference/fit-method-inv_metric.html
index feac9970..3705aecd 100644
--- a/docs/reference/fit-method-inv_metric.html
+++ b/docs/reference/fit-method-inv_metric.html
@@ -140,75 +140,75 @@ Examples
fit$inv_metric()
#> $`1`
#> [,1] [,2] [,3] [,4]
-#> [1,] 0.0461164 0.0000000 0.0000000 0.0000000
-#> [2,] 0.0000000 0.0586249 0.0000000 0.0000000
-#> [3,] 0.0000000 0.0000000 0.0569083 0.0000000
-#> [4,] 0.0000000 0.0000000 0.0000000 0.0695349
+#> [1,] 0.0435508 0.0000000 0.0000000 0.0000000
+#> [2,] 0.0000000 0.0607469 0.0000000 0.0000000
+#> [3,] 0.0000000 0.0000000 0.0503494 0.0000000
+#> [4,] 0.0000000 0.0000000 0.0000000 0.0672705
#>
#> $`2`
#> [,1] [,2] [,3] [,4]
-#> [1,] 0.0423827 0.0000000 0.0000000 0.0000000
-#> [2,] 0.0000000 0.0638639 0.0000000 0.0000000
-#> [3,] 0.0000000 0.0000000 0.0463094 0.0000000
-#> [4,] 0.0000000 0.0000000 0.0000000 0.0646605
+#> [1,] 0.0532065 0.0000000 0.0000000 0.0000000
+#> [2,] 0.0000000 0.0574785 0.0000000 0.0000000
+#> [3,] 0.0000000 0.0000000 0.0512835 0.0000000
+#> [4,] 0.0000000 0.0000000 0.0000000 0.0641874
#>
#> $`3`
#> [,1] [,2] [,3] [,4]
-#> [1,] 0.0555959 0.0000000 0.0000000 0.0000000
-#> [2,] 0.0000000 0.0595803 0.0000000 0.0000000
-#> [3,] 0.0000000 0.0000000 0.0515264 0.0000000
-#> [4,] 0.0000000 0.0000000 0.0000000 0.0759908
+#> [1,] 0.0502858 0.0000000 0.0000000 0.0000000
+#> [2,] 0.0000000 0.0629888 0.0000000 0.0000000
+#> [3,] 0.0000000 0.0000000 0.0512933 0.0000000
+#> [4,] 0.0000000 0.0000000 0.0000000 0.0661664
#>
#> $`4`
-#> [,1] [,2] [,3] [,4]
-#> [1,] 0.05104 0.000000 0.0000000 0.00000
-#> [2,] 0.00000 0.051252 0.0000000 0.00000
-#> [3,] 0.00000 0.000000 0.0567318 0.00000
-#> [4,] 0.00000 0.000000 0.0000000 0.06699
+#> [,1] [,2] [,3] [,4]
+#> [1,] 0.0453724 0.000000 0.00000 0.0000000
+#> [2,] 0.0000000 0.061371 0.00000 0.0000000
+#> [3,] 0.0000000 0.000000 0.04017 0.0000000
+#> [4,] 0.0000000 0.000000 0.00000 0.0682251
#>
fit$inv_metric(matrix=FALSE)
#> $`1`
-#> [1] 0.0461164 0.0586249 0.0569083 0.0695349
+#> [1] 0.0435508 0.0607469 0.0503494 0.0672705
#>
#> $`2`
-#> [1] 0.0423827 0.0638639 0.0463094 0.0646605
+#> [1] 0.0532065 0.0574785 0.0512835 0.0641874
#>
#> $`3`
-#> [1] 0.0555959 0.0595803 0.0515264 0.0759908
+#> [1] 0.0502858 0.0629888 0.0512933 0.0661664
#>
#> $`4`
-#> [1] 0.0510400 0.0512520 0.0567318 0.0669900
+#> [1] 0.0453724 0.0613710 0.0401700 0.0682251
#>
fit <- cmdstanr_example("logistic", metric = "dense_e")
fit$inv_metric()
#> $`1`
-#> [,1] [,2] [,3] [,4]
-#> [1,] 0.048223400 -0.00737038 0.000297676 0.00680596
-#> [2,] -0.007370380 0.05440320 -0.006681250 -0.00162053
-#> [3,] 0.000297676 -0.00668125 0.043576600 -0.00859282
-#> [4,] 0.006805960 -0.00162053 -0.008592820 0.06856220
+#> [,1] [,2] [,3] [,4]
+#> [1,] 0.04487240 -0.00665557 0.00248036 -0.00336473
+#> [2,] -0.00665557 0.05394230 -0.00841737 -0.00815855
+#> [3,] 0.00248036 -0.00841737 0.04945140 -0.01015960
+#> [4,] -0.00336473 -0.00815855 -0.01015960 0.07289150
#>
#> $`2`
-#> [,1] [,2] [,3] [,4]
-#> [1,] 0.04746980 -0.00175084 -0.00118626 0.00664285
-#> [2,] -0.00175084 0.06320920 -0.00172180 -0.01259270
-#> [3,] -0.00118626 -0.00172180 0.04810590 -0.00872089
-#> [4,] 0.00664285 -0.01259270 -0.00872089 0.06689500
+#> [,1] [,2] [,3] [,4]
+#> [1,] 0.044891100 -0.00756532 0.00352846 -0.000462971
+#> [2,] -0.007565320 0.06064960 -0.00809279 -0.004813840
+#> [3,] 0.003528460 -0.00809279 0.05892730 -0.016947100
+#> [4,] -0.000462971 -0.00481384 -0.01694710 0.063878300
#>
#> $`3`
-#> [,1] [,2] [,3] [,4]
-#> [1,] 0.04482880 -0.00377658 -0.00343049 0.00304829
-#> [2,] -0.00377658 0.04803130 -0.00957526 -0.00566723
-#> [3,] -0.00343049 -0.00957526 0.05099840 -0.00574551
-#> [4,] 0.00304829 -0.00566723 -0.00574551 0.07092750
+#> [,1] [,2] [,3] [,4]
+#> [1,] 0.047806100 0.000761202 0.00579535 0.00494546
+#> [2,] 0.000761202 0.062074500 -0.00488086 -0.01014510
+#> [3,] 0.005795350 -0.004880860 0.05170230 -0.00609765
+#> [4,] 0.004945460 -0.010145100 -0.00609765 0.07081120
#>
#> $`4`
-#> [,1] [,2] [,3] [,4]
-#> [1,] 0.04787540 -0.003918010 -0.004273680 0.00253868
-#> [2,] -0.00391801 0.049792000 0.000712128 -0.00453177
-#> [3,] -0.00427368 0.000712128 0.045850800 -0.00639672
-#> [4,] 0.00253868 -0.004531770 -0.006396720 0.07511110
+#> [,1] [,2] [,3] [,4]
+#> [1,] 0.04387350 0.004639300 0.001929550 0.00526756
+#> [2,] 0.00463930 0.064076200 -0.000902685 -0.00609741
+#> [3,] 0.00192955 -0.000902685 0.045911200 -0.00859578
+#> [4,] 0.00526756 -0.006097410 -0.008595780 0.07087270
#>
# }
diff --git a/docs/reference/fit-method-log_prob.html b/docs/reference/fit-method-log_prob.html
index a0a9f638..561ca052 100644
--- a/docs/reference/fit-method-log_prob.html
+++ b/docs/reference/fit-method-log_prob.html
@@ -1,5 +1,6 @@
-Calculate the log-probability given a provided vector of unconstrained parameters. — fit-method-log_prob • cmdstanr Calculate the log-probability given a provided vector of unconstrained parameters. — fit-method-log_prob • cmdstanr
@@ -104,23 +105,27 @@ Calculate the log-probability given a provided vector of unconstrained param
- The $log_prob()
method provides access to the Stan model's log_prob
function
+ The $log_prob()
method provides access to the Stan model's
+log_prob
function.
- log_prob(unconstrained_variables, jacobian_adjustment = TRUE)
+ log_prob(unconstrained_variables, jacobian = TRUE, jacobian_adjustment = NULL)
Arguments
- unconstrained_variables
-(numeric) A vector of unconstrained parameters
-to be passed to log_prob
.
+(numeric) A vector of unconstrained parameters.
+
+
+- jacobian
+(logical) Whether to include the log-density adjustments from
+un/constraining variables.
- jacobian_adjustment
-(logical) Whether to include the log-density
-adjustments from un/constraining variables.
+Deprecated. Please use jacobian
instead.
diff --git a/docs/reference/fit-method-loo.html b/docs/reference/fit-method-loo.html
index 5a1a1743..54c58466 100644
--- a/docs/reference/fit-method-loo.html
+++ b/docs/reference/fit-method-loo.html
@@ -181,9 +181,9 @@ Examples
#> Computed from 4000 by 100 log-likelihood matrix
#>
#> Estimate SE
-#> elpd_loo -63.7 4.2
+#> elpd_loo -63.7 4.1
#> p_loo 3.9 0.5
-#> looic 127.3 8.3
+#> looic 127.4 8.2
#> ------
#> Monte Carlo SE of elpd_loo is 0.0.
#>
diff --git a/docs/reference/fit-method-lp-1.png b/docs/reference/fit-method-lp-1.png
index 508c1b84..980bd46b 100644
Binary files a/docs/reference/fit-method-lp-1.png and b/docs/reference/fit-method-lp-1.png differ
diff --git a/docs/reference/fit-method-lp.html b/docs/reference/fit-method-lp.html
index 1dd19bc7..bca9a329 100644
--- a/docs/reference/fit-method-lp.html
+++ b/docs/reference/fit-method-lp.html
@@ -170,7 +170,7 @@ Examples
# \dontrun{
fit_mcmc <- cmdstanr_example("logistic")
head(fit_mcmc$lp())
-#> [1] -65.4484 -67.4196 -65.8307 -65.3367 -67.3193 -66.8288
+#> [1] -65.6405 -64.4734 -65.4431 -64.9703 -65.8088 -65.6905
fit_mle <- cmdstanr_example("logistic", method = "optimize")
fit_mle$lp()
diff --git a/docs/reference/fit-method-metadata.html b/docs/reference/fit-method-metadata.html
index f97d066f..01634904 100644
--- a/docs/reference/fit-method-metadata.html
+++ b/docs/reference/fit-method-metadata.html
@@ -129,7 +129,7 @@ Examples
#> $ stan_version_major : num 2
#> $ stan_version_minor : num 33
#> $ stan_version_patch : num 0
-#> $ start_datetime : chr "2023-11-08 17:29:44 UTC"
+#> $ start_datetime : chr "2023-12-13 17:04:42 UTC"
#> $ method : chr "sample"
#> $ save_warmup : num 0
#> $ thin : num 1
@@ -146,14 +146,14 @@ Examples
#> $ num_chains : num 1
#> $ id : num [1:4] 1 2 3 4
#> $ init : num [1:4] 2 2 2 2
-#> $ seed : num 1.39e+09
+#> $ seed : num 1.08e+09
#> $ refresh : num 100
#> $ sig_figs : num -1
-#> $ profile_file : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-profile-202311081029-1-216cf7.csv"
+#> $ profile_file : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-profile-202312131004-1-79f552.csv"
#> $ stanc_version : chr "stanc3 v2.33.1"
#> $ sampler_diagnostics : chr [1:6] "accept_stat__" "stepsize__" "treedepth__" "n_leapfrog__" ...
#> $ variables : chr [1:105] "lp__" "alpha" "beta[1]" "beta[2]" ...
-#> $ step_size_adaptation: num [1:4] 0.779 0.737 0.698 0.697
+#> $ step_size_adaptation: num [1:4] 0.723 0.882 0.802 0.749
#> $ model_name : chr "logistic_model"
#> $ adapt_engaged : num 1
#> $ adapt_delta : num 0.8
@@ -164,9 +164,9 @@ Examples
#> $ threads_per_chain : num 1
#> $ time :'data.frame': 4 obs. of 4 variables:
#> ..$ chain_id: num [1:4] 1 2 3 4
-#> ..$ warmup : num [1:4] 0.022 0.023 0.023 0.023
-#> ..$ sampling: num [1:4] 0.081 0.074 0.083 0.081
-#> ..$ total : num [1:4] 0.103 0.097 0.106 0.104
+#> ..$ warmup : num [1:4] 0.022 0.022 0.022 0.022
+#> ..$ sampling: num [1:4] 0.069 0.065 0.07 0.068
+#> ..$ total : num [1:4] 0.091 0.087 0.092 0.09
#> $ stan_variable_sizes :List of 4
#> ..$ lp__ : num 1
#> ..$ alpha : num 1
@@ -181,7 +181,7 @@ Examples
#> $ stan_version_major : num 2
#> $ stan_version_minor : num 33
#> $ stan_version_patch : num 0
-#> $ start_datetime : chr "2023-11-08 17:29:46 UTC"
+#> $ start_datetime : chr "2023-12-13 17:04:44 UTC"
#> $ method : chr "optimize"
#> $ algorithm : chr "lbfgs"
#> $ init_alpha : num 0.001
@@ -196,10 +196,10 @@ Examples
#> $ save_iterations : num 0
#> $ id : num 1
#> $ init : num 2
-#> $ seed : num 1.28e+09
+#> $ seed : num 9.12e+08
#> $ refresh : num 100
#> $ sig_figs : num -1
-#> $ profile_file : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-profile-202311081029-1-65f6b8.csv"
+#> $ profile_file : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-profile-202312131004-1-7b3d9a.csv"
#> $ stanc_version : chr "stanc3 v2.33.1"
#> $ sampler_diagnostics: chr(0)
#> $ variables : chr [1:105] "lp__" "alpha" "beta[1]" "beta[2]" ...
@@ -220,7 +220,7 @@ Examples
#> $ stan_version_major : num 2
#> $ stan_version_minor : num 33
#> $ stan_version_patch : num 0
-#> $ start_datetime : chr "2023-11-08 17:29:46 UTC"
+#> $ start_datetime : chr "2023-12-13 17:04:44 UTC"
#> $ method : chr "variational"
#> $ algorithm : chr "meanfield"
#> $ iter : num 50
@@ -232,10 +232,10 @@ Examples
#> $ output_samples : num 1000
#> $ id : num 1
#> $ init : num 2
-#> $ seed : num 9.18e+08
+#> $ seed : num 3.89e+08
#> $ refresh : num 100
#> $ sig_figs : num -1
-#> $ profile_file : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-profile-202311081029-1-40a7a2.csv"
+#> $ profile_file : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-profile-202312131004-1-645608.csv"
#> $ stanc_version : chr "stanc3 v2.33.1"
#> $ sampler_diagnostics: chr(0)
#> $ variables : chr [1:106] "lp__" "lp_approx__" "alpha" "beta[1]" ...
diff --git a/docs/reference/fit-method-mle.html b/docs/reference/fit-method-mle.html
index 53b88a5e..c9ac5821 100644
--- a/docs/reference/fit-method-mle.html
+++ b/docs/reference/fit-method-mle.html
@@ -147,14 +147,14 @@ Examples
# \dontrun{
fit <- cmdstanr_example("logistic", method = "optimize")
fit$mle("alpha")
-#> alpha
-#> 0.36447
+#> alpha
+#> 0.364472
fit$mle("beta")
#> beta[1] beta[2] beta[3]
-#> -0.631542 -0.258968 0.648496
+#> -0.631560 -0.258925 0.648500
fit$mle("beta[2]")
#> beta[2]
-#> -0.258968
+#> -0.258925
# }
diff --git a/docs/reference/fit-method-output.html b/docs/reference/fit-method-output.html
index d981dc43..ba2dc64f 100644
--- a/docs/reference/fit-method-output.html
+++ b/docs/reference/fit-method-output.html
@@ -166,21 +166,21 @@ Examples
#> num_chains = 1 (Default)
#> id = 1 (Default)
#> data
-#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpYtRZP3/temp_libpath119dc23a21f00/cmdstanr/logistic.data.json
+#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmps9TW4l/temp_libpath5800f91909/cmdstanr/logistic.data.json
#> init = 2 (Default)
#> random
-#> seed = 1225363303
+#> seed = 1467887685
#> output
-#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081029-1-2c7d41.csv
+#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131004-1-910e87.csv
#> diagnostic_file = (Default)
#> refresh = 100 (Default)
#> sig_figs = -1 (Default)
-#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-profile-202311081029-1-1ddd0e.csv
+#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-profile-202312131004-1-90a553.csv
#> num_threads = 1 (Default)
#>
#>
-#> Gradient evaluation took 2.2e-05 seconds
-#> 1000 transitions using 10 leapfrog steps per transition would take 0.22 seconds.
+#> Gradient evaluation took 1.9e-05 seconds
+#> 1000 transitions using 10 leapfrog steps per transition would take 0.19 seconds.
#> Adjust your expectations accordingly!
#>
#>
@@ -207,9 +207,9 @@ Examples
#> Iteration: 1900 / 2000 [ 95%] (Sampling)
#> Iteration: 2000 / 2000 [100%] (Sampling)
#>
-#> Elapsed Time: 0.025 seconds (Warm-up)
-#> 0.082 seconds (Sampling)
-#> 0.107 seconds (Total)
+#> Elapsed Time: 0.022 seconds (Warm-up)
+#> 0.072 seconds (Sampling)
+#> 0.094 seconds (Total)
out <- fit_mcmc$output()
str(out)
#> List of 4
@@ -237,21 +237,21 @@ Examples
#> save_iterations = 0 (Default)
#> id = 1 (Default)
#> data
-#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpYtRZP3/temp_libpath119dc23a21f00/cmdstanr/logistic.data.json
+#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmps9TW4l/temp_libpath5800f91909/cmdstanr/logistic.data.json
#> init = 2 (Default)
#> random
-#> seed = 152179067
+#> seed = 44204223
#> output
-#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081029-1-0168cf.csv
+#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131004-1-75dd88.csv
#> diagnostic_file = (Default)
#> refresh = 100 (Default)
#> sig_figs = -1 (Default)
-#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-profile-202311081029-1-216c50.csv
+#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-profile-202312131004-1-5c2d53.csv
#> num_threads = 1 (Default)
#>
-#> Initial log joint probability = -95.9632
+#> Initial log joint probability = -80.1217
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 7 -63.9218 0.000242271 7.03951e-05 1 1 9
+#> 7 -63.9218 0.00150318 0.00093398 1 1 9
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
@@ -274,16 +274,16 @@ Examples
#> output_samples = 1000 (Default)
#> id = 1 (Default)
#> data
-#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpYtRZP3/temp_libpath119dc23a21f00/cmdstanr/logistic.data.json
+#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmps9TW4l/temp_libpath5800f91909/cmdstanr/logistic.data.json
#> init = 2 (Default)
#> random
-#> seed = 676659604
+#> seed = 244304498
#> output
-#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081029-1-6087e5.csv
+#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131004-1-3b4b11.csv
#> diagnostic_file = (Default)
#> refresh = 100 (Default)
#> sig_figs = -1 (Default)
-#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-profile-202311081029-1-8ae7e6.csv
+#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-profile-202312131004-1-85d291.csv
#> num_threads = 1 (Default)
#>
#> ------------------------------------------------------------
@@ -294,8 +294,8 @@ Examples
#>
#>
#>
-#> Gradient evaluation took 1.8e-05 seconds
-#> 1000 transitions using 10 leapfrog steps per transition would take 0.18 seconds.
+#> Gradient evaluation took 1.9e-05 seconds
+#> 1000 transitions using 10 leapfrog steps per transition would take 0.19 seconds.
#> Adjust your expectations accordingly!
#>
#>
@@ -309,9 +309,9 @@ Examples
#>
#> Begin stochastic gradient ascent.
#> iter ELBO delta_ELBO_mean delta_ELBO_med notes
-#> 100 -66.040 1.000 1.000
-#> 200 -66.445 0.503 1.000
-#> 300 -66.355 0.336 0.006 MEDIAN ELBO CONVERGED
+#> 100 -66.299 1.000 1.000
+#> 200 -66.336 0.500 1.000
+#> 300 -66.628 0.335 0.004 MEDIAN ELBO CONVERGED
#>
#> Drawing a sample of size 1000 from the approximate posterior...
#> COMPLETED.
diff --git a/docs/reference/fit-method-profiles.html b/docs/reference/fit-method-profiles.html
index 6d97a13a..7c4e4b8c 100644
--- a/docs/reference/fit-method-profiles.html
+++ b/docs/reference/fit-method-profiles.html
@@ -176,32 +176,32 @@ Examples
fit$profiles()
#> [[1]]
#> name thread_id total_time forward_time reverse_time chain_stack
-#> 1 gq 0x1061d4e00 0.000364609 0.000364609 0.000000000 0
-#> 2 likelihood 0x1061d4e00 0.001171810 0.000840557 0.000331257 7169
+#> 1 gq 0x10efcde00 0.000375429 0.000375429 0.000000000 0
+#> 2 likelihood 0x10efcde00 0.001165040 0.000834157 0.000330887 7169
#> no_chain_stack autodiff_calls no_autodiff_calls
#> 1 0 0 1000
#> 2 7169 7169 1
#>
#> [[2]]
#> name thread_id total_time forward_time reverse_time chain_stack
-#> 1 gq 0x10e36de00 0.000346564 0.000346564 0.000000000 0
-#> 2 likelihood 0x10e36de00 0.001186840 0.000842553 0.000344283 7155
+#> 1 gq 0x10d0b0e00 0.000407951 0.000407951 0.000000000 0
+#> 2 likelihood 0x10d0b0e00 0.001283690 0.000915781 0.000367905 7155
#> no_chain_stack autodiff_calls no_autodiff_calls
#> 1 0 0 1000
#> 2 7155 7155 1
#>
#> [[3]]
#> name thread_id total_time forward_time reverse_time chain_stack
-#> 1 gq 0x111ab6e00 0.000351792 0.000351792 0.000000000 0
-#> 2 likelihood 0x111ab6e00 0.001143140 0.000829663 0.000313482 6879
+#> 1 gq 0x106bb1e00 0.000399315 0.000399315 0.000000000 0
+#> 2 likelihood 0x106bb1e00 0.001242900 0.000887379 0.000355522 6879
#> no_chain_stack autodiff_calls no_autodiff_calls
#> 1 0 0 1000
#> 2 6879 6879 1
#>
#> [[4]]
#> name thread_id total_time forward_time reverse_time chain_stack
-#> 1 gq 0x10c867e00 0.000408638 0.000408638 0.000000000 0
-#> 2 likelihood 0x10c867e00 0.001279700 0.000924260 0.000355437 6892
+#> 1 gq 0x111b21e00 0.000516567 0.000516567 0.000000000 0
+#> 2 likelihood 0x111b21e00 0.001479350 0.001061390 0.000417962 6892
#> no_chain_stack autodiff_calls no_autodiff_calls
#> 1 0 0 1000
#> 2 6892 6892 1
diff --git a/docs/reference/fit-method-return_codes.html b/docs/reference/fit-method-return_codes.html
index 734fbae7..83a654e0 100644
--- a/docs/reference/fit-method-return_codes.html
+++ b/docs/reference/fit-method-return_codes.html
@@ -130,9 +130,7 @@ Examples
# \dontrun{
# example with return codes all zero
fit_mcmc <- cmdstanr_example("schools", method = "sample")
-#> Warning: 238 of 4000 (6.0%) transitions ended with a divergence.
-#> See https://mc-stan.org/misc/warnings for details.
-#> Warning: 1 of 4 chains had an E-BFMI less than 0.2.
+#> Warning: 72 of 4000 (2.0%) transitions ended with a divergence.
#> See https://mc-stan.org/misc/warnings for details.
fit_mcmc$return_codes() # should be all zero
#> [1] 0 0 0 0
diff --git a/docs/reference/fit-method-sampler_diagnostics.html b/docs/reference/fit-method-sampler_diagnostics.html
index e83c1bf5..69c92928 100644
--- a/docs/reference/fit-method-sampler_diagnostics.html
+++ b/docs/reference/fit-method-sampler_diagnostics.html
@@ -152,7 +152,7 @@ Examples
fit <- cmdstanr_example("logistic")
sampler_diagnostics <- fit$sampler_diagnostics()
str(sampler_diagnostics)
-#> 'draws_array' num [1:1000, 1:4, 1:6] 2 2 2 2 2 3 2 2 2 3 ...
+#> 'draws_array' num [1:1000, 1:4, 1:6] 2 2 2 2 3 2 2 3 2 2 ...
#> - attr(*, "dimnames")=List of 3
#> ..$ iteration: chr [1:1000] "1" "2" "3" "4" ...
#> ..$ chain : chr [1:4] "1" "2" "3" "4"
@@ -162,16 +162,16 @@ Examples
as_draws_df(sampler_diagnostics)
#> # A draws_df: 1000 iterations, 4 chains, and 6 variables
#> treedepth__ divergent__ energy__ accept_stat__ stepsize__ n_leapfrog__
-#> 1 2 0 70 0.76 0.73 3
-#> 2 2 0 69 1.00 0.73 3
-#> 3 2 0 69 1.00 0.73 3
-#> 4 2 0 66 1.00 0.73 3
-#> 5 2 0 66 0.97 0.73 3
-#> 6 3 0 67 0.88 0.73 7
-#> 7 2 0 72 0.74 0.73 3
-#> 8 2 0 73 1.00 0.73 3
-#> 9 2 0 69 1.00 0.73 3
-#> 10 3 0 66 0.95 0.73 7
+#> 1 2 0 66 0.87 0.85 3
+#> 2 2 0 66 0.91 0.85 3
+#> 3 2 0 66 0.99 0.85 3
+#> 4 2 0 65 1.00 0.85 3
+#> 5 3 0 65 0.94 0.85 7
+#> 6 2 0 68 0.83 0.85 7
+#> 7 2 0 66 0.93 0.85 7
+#> 8 3 0 67 0.94 0.85 7
+#> 9 2 0 66 1.00 0.85 3
+#> 10 2 0 68 0.65 0.85 3
#> # ... with 3990 more draws
#> # ... hidden reserved variables {'.chain', '.iteration', '.draw'}
@@ -179,16 +179,16 @@ Examples
fit$sampler_diagnostics(format = "df")
#> # A draws_df: 1000 iterations, 4 chains, and 6 variables
#> treedepth__ divergent__ energy__ accept_stat__ stepsize__ n_leapfrog__
-#> 1 2 0 70 0.76 0.73 3
-#> 2 2 0 69 1.00 0.73 3
-#> 3 2 0 69 1.00 0.73 3
-#> 4 2 0 66 1.00 0.73 3
-#> 5 2 0 66 0.97 0.73 3
-#> 6 3 0 67 0.88 0.73 7
-#> 7 2 0 72 0.74 0.73 3
-#> 8 2 0 73 1.00 0.73 3
-#> 9 2 0 69 1.00 0.73 3
-#> 10 3 0 66 0.95 0.73 7
+#> 1 2 0 66 0.87 0.85 3
+#> 2 2 0 66 0.91 0.85 3
+#> 3 2 0 66 0.99 0.85 3
+#> 4 2 0 65 1.00 0.85 3
+#> 5 3 0 65 0.94 0.85 7
+#> 6 2 0 68 0.83 0.85 7
+#> 7 2 0 66 0.93 0.85 7
+#> 8 3 0 67 0.94 0.85 7
+#> 9 2 0 66 1.00 0.85 3
+#> 10 2 0 68 0.65 0.85 3
#> # ... with 3990 more draws
#> # ... hidden reserved variables {'.chain', '.iteration', '.draw'}
# }
diff --git a/docs/reference/fit-method-save_object.html b/docs/reference/fit-method-save_object.html
index 90155c94..8464814f 100644
--- a/docs/reference/fit-method-save_object.html
+++ b/docs/reference/fit-method-save_object.html
@@ -148,16 +148,16 @@ Examples
#> # A tibble: 105 × 10
#> variable mean median sd mad q5 q95 rhat ess_bulk
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -66.0 -65.6 1.43 1.24 -68.6 -64.3 1.00 2220.
-#> 2 alpha 0.383 0.380 0.214 0.213 0.0497 0.741 1.00 4650.
-#> 3 beta[1] -0.669 -0.668 0.251 0.258 -1.08 -0.266 1.00 4431.
-#> 4 beta[2] -0.274 -0.269 0.226 0.224 -0.644 0.0995 1.00 3964.
-#> 5 beta[3] 0.675 0.670 0.269 0.269 0.243 1.13 1.00 3857.
-#> 6 log_lik[1] -0.513 -0.506 0.0969 0.0968 -0.678 -0.368 1.00 4700.
-#> 7 log_lik[2] -0.407 -0.386 0.151 0.144 -0.689 -0.194 1.00 4212.
-#> 8 log_lik[3] -0.496 -0.460 0.215 0.203 -0.888 -0.211 1.00 4110.
-#> 9 log_lik[4] -0.452 -0.436 0.152 0.146 -0.732 -0.233 1.00 4273.
-#> 10 log_lik[5] -1.18 -1.16 0.274 0.268 -1.65 -0.760 1.00 4342.
+#> 1 lp__ -65.9 -65.6 1.40 1.17 -68.7 -64.3 1.00 1893.
+#> 2 alpha 0.380 0.380 0.218 0.216 0.0231 0.740 1.00 4801.
+#> 3 beta[1] -0.668 -0.659 0.248 0.247 -1.09 -0.273 1.00 4573.
+#> 4 beta[2] -0.271 -0.267 0.224 0.229 -0.634 0.0845 1.00 4645.
+#> 5 beta[3] 0.678 0.666 0.266 0.259 0.248 1.12 1.00 4505.
+#> 6 log_lik[1] -0.515 -0.508 0.0990 0.0965 -0.689 -0.362 1.00 4844.
+#> 7 log_lik[2] -0.403 -0.384 0.147 0.139 -0.669 -0.199 1.00 4585.
+#> 8 log_lik[3] -0.495 -0.459 0.218 0.202 -0.898 -0.206 1.00 4890.
+#> 9 log_lik[4] -0.452 -0.433 0.153 0.150 -0.726 -0.239 1.00 4491.
+#> 10 log_lik[5] -1.18 -1.16 0.278 0.275 -1.67 -0.765 1.00 5130.
#> # ℹ 95 more rows
#> # ℹ 1 more variable: ess_tail <dbl>
# }
diff --git a/docs/reference/fit-method-save_output_files.html b/docs/reference/fit-method-save_output_files.html
index f096f70e..8fb2b772 100644
--- a/docs/reference/fit-method-save_output_files.html
+++ b/docs/reference/fit-method-save_output_files.html
@@ -210,33 +210,33 @@ Examples
# \dontrun{
fit <- cmdstanr_example()
fit$output_files()
-#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081030-1-98eced.csv"
-#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081030-2-98eced.csv"
-#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081030-3-98eced.csv"
-#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081030-4-98eced.csv"
+#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131005-1-212881.csv"
+#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131005-2-212881.csv"
+#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131005-3-212881.csv"
+#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131005-4-212881.csv"
fit$data_file()
-#> [1] "/private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpYtRZP3/temp_libpath119dc23a21f00/cmdstanr/logistic.data.json"
+#> [1] "/private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmps9TW4l/temp_libpath5800f91909/cmdstanr/logistic.data.json"
# just using tempdir for the example
my_dir <- tempdir()
fit$save_output_files(dir = my_dir, basename = "banana")
#> Moved 4 files and set internal paths to new locations:
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/banana-202311081030-1-846feb.csv
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/banana-202311081030-2-846feb.csv
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/banana-202311081030-3-846feb.csv
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/banana-202311081030-4-846feb.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/banana-202312131005-1-932dd0.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/banana-202312131005-2-932dd0.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/banana-202312131005-3-932dd0.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/banana-202312131005-4-932dd0.csv
fit$save_output_files(dir = my_dir, basename = "tomato", timestamp = FALSE)
#> Moved 4 files and set internal paths to new locations:
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/tomato-1-270839.csv
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/tomato-2-270839.csv
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/tomato-3-270839.csv
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/tomato-4-270839.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/tomato-1-1f5444.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/tomato-2-1f5444.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/tomato-3-1f5444.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/tomato-4-1f5444.csv
fit$save_output_files(dir = my_dir, basename = "lettuce", timestamp = FALSE, random = FALSE)
#> Moved 4 files and set internal paths to new locations:
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/lettuce-1.csv
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/lettuce-2.csv
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/lettuce-3.csv
-#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/lettuce-4.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/lettuce-1.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/lettuce-2.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/lettuce-3.csv
+#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/lettuce-4.csv
# }
diff --git a/docs/reference/fit-method-summary.html b/docs/reference/fit-method-summary.html
index 6f8199fa..14110b92 100644
--- a/docs/reference/fit-method-summary.html
+++ b/docs/reference/fit-method-summary.html
@@ -165,36 +165,36 @@ Examples
#> # A tibble: 105 × 10
#> variable mean median sd mad q5 q95 rhat ess_bulk
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -65.9 -65.6 1.43 1.23 -68.7 -64.3 1.00 2038.
-#> 2 alpha 0.376 0.369 0.215 0.214 0.0214 0.727 1.00 4221.
-#> 3 beta[1] -0.665 -0.659 0.247 0.241 -1.08 -0.263 1.00 4093.
-#> 4 beta[2] -0.275 -0.271 0.224 0.221 -0.652 0.0850 1.00 4052.
-#> 5 beta[3] 0.676 0.669 0.268 0.268 0.244 1.12 1.00 4213.
-#> 6 log_lik[1] -0.517 -0.511 0.0979 0.0959 -0.683 -0.369 1.00 4266.
-#> 7 log_lik[2] -0.404 -0.383 0.147 0.140 -0.669 -0.200 1.00 4613.
-#> 8 log_lik[3] -0.501 -0.466 0.218 0.200 -0.913 -0.209 1.00 4197.
-#> 9 log_lik[4] -0.450 -0.430 0.153 0.145 -0.724 -0.229 1.00 4069.
-#> 10 log_lik[5] -1.18 -1.15 0.278 0.270 -1.67 -0.758 1.00 4386.
+#> 1 lp__ -66.0 -65.7 1.48 1.23 -68.9 -64.3 1.00 1956.
+#> 2 alpha 0.382 0.381 0.221 0.222 0.0263 0.744 1.00 3982.
+#> 3 beta[1] -0.665 -0.661 0.252 0.253 -1.09 -0.264 1.00 4131.
+#> 4 beta[2] -0.274 -0.280 0.226 0.226 -0.640 0.0976 1.00 3816.
+#> 5 beta[3] 0.675 0.673 0.268 0.265 0.238 1.12 1.00 3963.
+#> 6 log_lik[1] -0.514 -0.508 0.0987 0.0980 -0.686 -0.364 1.00 3980.
+#> 7 log_lik[2] -0.408 -0.385 0.153 0.142 -0.690 -0.197 1.00 4263.
+#> 8 log_lik[3] -0.498 -0.467 0.217 0.204 -0.889 -0.206 1.00 3904.
+#> 9 log_lik[4] -0.453 -0.436 0.152 0.148 -0.732 -0.236 1.00 3847.
+#> 10 log_lik[5] -1.18 -1.16 0.285 0.281 -1.68 -0.749 1.00 4407.
#> # ℹ 95 more rows
#> # ℹ 1 more variable: ess_tail <dbl>
fit$print()
#> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail
-#> lp__ -65.92 -65.59 1.43 1.23 -68.71 -64.30 1.00 2038 2638
-#> alpha 0.38 0.37 0.21 0.21 0.02 0.73 1.00 4221 3302
-#> beta[1] -0.67 -0.66 0.25 0.24 -1.08 -0.26 1.00 4092 2987
-#> beta[2] -0.28 -0.27 0.22 0.22 -0.65 0.09 1.00 4052 3349
-#> beta[3] 0.68 0.67 0.27 0.27 0.24 1.12 1.00 4212 2892
-#> log_lik[1] -0.52 -0.51 0.10 0.10 -0.68 -0.37 1.00 4265 3448
-#> log_lik[2] -0.40 -0.38 0.15 0.14 -0.67 -0.20 1.00 4612 3246
-#> log_lik[3] -0.50 -0.47 0.22 0.20 -0.91 -0.21 1.00 4197 3040
-#> log_lik[4] -0.45 -0.43 0.15 0.14 -0.72 -0.23 1.00 4069 2989
-#> log_lik[5] -1.18 -1.15 0.28 0.27 -1.67 -0.76 1.00 4386 2650
+#> lp__ -66.00 -65.68 1.48 1.23 -68.89 -64.30 1.00 1956 2665
+#> alpha 0.38 0.38 0.22 0.22 0.03 0.74 1.00 3981 3124
+#> beta[1] -0.66 -0.66 0.25 0.25 -1.09 -0.26 1.00 4131 3206
+#> beta[2] -0.27 -0.28 0.23 0.23 -0.64 0.10 1.00 3815 2736
+#> beta[3] 0.67 0.67 0.27 0.26 0.24 1.12 1.00 3963 3257
+#> log_lik[1] -0.51 -0.51 0.10 0.10 -0.69 -0.36 1.00 3979 2841
+#> log_lik[2] -0.41 -0.39 0.15 0.14 -0.69 -0.20 1.00 4263 3051
+#> log_lik[3] -0.50 -0.47 0.22 0.20 -0.89 -0.21 1.00 3904 3141
+#> log_lik[4] -0.45 -0.44 0.15 0.15 -0.73 -0.24 1.00 3847 2904
+#> log_lik[5] -1.18 -1.16 0.28 0.28 -1.68 -0.75 1.00 4406 3095
#>
#> # showing 10 of 105 rows (change via 'max_rows' argument or 'cmdstanr_max_rows' option)
fit$print(max_rows = 2) # same as print(fit, max_rows = 2)
#> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail
-#> lp__ -65.92 -65.59 1.43 1.23 -68.71 -64.30 1.00 2038 2638
-#> alpha 0.38 0.37 0.21 0.21 0.02 0.73 1.00 4221 3302
+#> lp__ -66.00 -65.68 1.48 1.23 -68.89 -64.30 1.00 1956 2665
+#> alpha 0.38 0.38 0.22 0.22 0.03 0.74 1.00 3981 3124
#>
#> # showing 2 of 105 rows (change via 'max_rows' argument or 'cmdstanr_max_rows' option)
@@ -203,29 +203,29 @@ Examples
#> # A tibble: 3 × 10
#> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 beta[1] -0.665 -0.659 0.247 0.241 -1.08 -0.263 1.00 4093. 2988.
-#> 2 beta[2] -0.275 -0.271 0.224 0.221 -0.652 0.0850 1.00 4052. 3350.
-#> 3 beta[3] 0.676 0.669 0.268 0.268 0.244 1.12 1.00 4213. 2892.
+#> 1 beta[1] -0.665 -0.661 0.252 0.253 -1.09 -0.264 1.00 4131. 3207.
+#> 2 beta[2] -0.274 -0.280 0.226 0.226 -0.640 0.0976 1.00 3816. 2736.
+#> 3 beta[3] 0.675 0.673 0.268 0.265 0.238 1.12 1.00 3963. 3257.
fit$print(c("alpha", "beta[2]"))
#> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail
-#> alpha 0.38 0.37 0.21 0.21 0.02 0.73 1.00 4221 3302
-#> beta[2] -0.28 -0.27 0.22 0.22 -0.65 0.09 1.00 4052 3349
+#> alpha 0.38 0.38 0.22 0.22 0.03 0.74 1.00 3981 3124
+#> beta[2] -0.27 -0.28 0.23 0.23 -0.64 0.10 1.00 3815 2736
# include all variables but only certain summaries
fit$summary(NULL, c("mean", "sd"))
#> # A tibble: 105 × 3
#> variable mean sd
#> <chr> <dbl> <dbl>
-#> 1 lp__ -65.9 1.43
-#> 2 alpha 0.376 0.215
-#> 3 beta[1] -0.665 0.247
-#> 4 beta[2] -0.275 0.224
-#> 5 beta[3] 0.676 0.268
-#> 6 log_lik[1] -0.517 0.0979
-#> 7 log_lik[2] -0.404 0.147
-#> 8 log_lik[3] -0.501 0.218
-#> 9 log_lik[4] -0.450 0.153
-#> 10 log_lik[5] -1.18 0.278
+#> 1 lp__ -66.0 1.48
+#> 2 alpha 0.382 0.221
+#> 3 beta[1] -0.665 0.252
+#> 4 beta[2] -0.274 0.226
+#> 5 beta[3] 0.675 0.268
+#> 6 log_lik[1] -0.514 0.0987
+#> 7 log_lik[2] -0.408 0.153
+#> 8 log_lik[3] -0.498 0.217
+#> 9 log_lik[4] -0.453 0.152
+#> 10 log_lik[5] -1.18 0.285
#> # ℹ 95 more rows
# can use functions created from formulas
@@ -234,9 +234,9 @@ Examples
#> # A tibble: 3 × 2
#> variable prob_gt_0
#> <chr> <dbl>
-#> 1 beta[1] 0.00225
-#> 2 beta[2] 0.107
-#> 3 beta[3] 0.995
+#> 1 beta[1] 0.00325
+#> 2 beta[2] 0.114
+#> 3 beta[3] 0.997
# can combine user-specified functions with
# the default summary functions
@@ -248,10 +248,10 @@ Examples
#> # A tibble: 4 × 10
#> variable mean median sd mad q2.5 q97.5 rhat ess_bulk ess_tail
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 alpha 0.376 0.369 0.215 0.214 -0.0365 0.800 1.00 4221. 3303.
-#> 2 beta[1] -0.665 -0.659 0.247 0.241 -1.17 -0.200 1.00 4093. 2988.
-#> 3 beta[2] -0.275 -0.271 0.224 0.221 -0.720 0.155 1.00 4052. 3350.
-#> 4 beta[3] 0.676 0.669 0.268 0.268 0.172 1.23 1.00 4213. 2892.
+#> 1 alpha 0.382 0.381 0.221 0.222 -0.0413 0.821 1.00 3982. 3124.
+#> 2 beta[1] -0.665 -0.661 0.252 0.253 -1.18 -0.185 1.00 4131. 3207.
+#> 3 beta[2] -0.274 -0.280 0.226 0.226 -0.715 0.168 1.00 3816. 2736.
+#> 4 beta[3] 0.675 0.673 0.268 0.265 0.170 1.20 1.00 3963. 3257.
# the functions need to calculate the appropriate
# value for a matrix input
diff --git a/docs/reference/fit-method-time.html b/docs/reference/fit-method-time.html
index 474e4a0b..c0a070b8 100644
--- a/docs/reference/fit-method-time.html
+++ b/docs/reference/fit-method-time.html
@@ -140,36 +140,36 @@ Examples
fit_mcmc <- cmdstanr_example("logistic", method = "sample")
fit_mcmc$time()
#> $total
-#> [1] 0.5498919
+#> [1] 0.554847
#>
#> $chains
#> chain_id warmup sampling total
#> 1 1 0.023 0.071 0.094
-#> 2 2 0.023 0.070 0.093
-#> 3 3 0.023 0.074 0.097
-#> 4 4 0.023 0.074 0.097
+#> 2 2 0.022 0.066 0.088
+#> 3 3 0.023 0.071 0.094
+#> 4 4 0.023 0.071 0.094
#>
fit_vb <- cmdstanr_example("logistic", method = "variational")
fit_vb$time()
#> $total
-#> [1] 0.1315289
+#> [1] 0.1302531
#>
fit_mle <- cmdstanr_example("logistic", method = "optimize", jacobian = TRUE)
fit_mle$time()
#> $total
-#> [1] 0.1302979
+#> [1] 0.1320548
#>
# use fit_mle to draw samples from laplace approximation
fit_laplace <- cmdstanr_example("logistic", method = "laplace", mode = fit_mle)
fit_laplace$time() # just time for drawing sample not for running optimize
#> $total
-#> [1] 0.136251
+#> [1] 0.126792
#>
fit_laplace$time()$total + fit_mle$time()$total # total time
-#> [1] 0.2665489
+#> [1] 0.2588468
# }
diff --git a/docs/reference/index.html b/docs/reference/index.html
index 1036551c..c1a096fe 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -160,7 +160,7 @@ Running CmdStan from R laplace()
- Run Stan's laplace algorithm
+ Run Stan's Laplace algorithm
diff --git a/docs/reference/model-method-check_syntax.html b/docs/reference/model-method-check_syntax.html
index 14ad8c59..6ec6f59e 100644
--- a/docs/reference/model-method-check_syntax.html
+++ b/docs/reference/model-method-check_syntax.html
@@ -125,7 +125,7 @@ Arguments
- pedantic
(logical) Should pedantic mode be turned on? The default is
FALSE
. Pedantic mode attempts to warn you about potential issues in your
-Stan program beyond syntax errors. For details see the Pedantic mode chapter in
+Stan program beyond syntax errors. For details see the Pedantic mode chapter in
the Stan Reference Manual.
@@ -202,7 +202,7 @@ Examples
# pedantic mode will warn that lambda should be constrained to be positive
# and that lambda has no prior distribution
mod$check_syntax(pedantic = TRUE)
-#> Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/model_febb1e69c7387a0e64cf13583e078104.stan', line 11, column 14: A
+#> Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/model_febb1e69c7387a0e64cf13583e078104.stan', line 11, column 14: A
#> poisson distribution is given parameter lambda as a rate parameter
#> (argument 1), but lambda was not constrained to be strictly positive.
#> Warning: The parameter lambda has no priors. This means either no prior is
diff --git a/docs/reference/model-method-compile.html b/docs/reference/model-method-compile.html
index 2ae3d9c3..e5a50034 100644
--- a/docs/reference/model-method-compile.html
+++ b/docs/reference/model-method-compile.html
@@ -171,7 +171,7 @@ Arguments
- pedantic
(logical) Should pedantic mode be turned on? The default is
FALSE
. Pedantic mode attempts to warn you about potential issues in your
-Stan program beyond syntax errors. For details see the Pedantic mode chapter in
+Stan program beyond syntax errors. For details see the Pedantic mode chapter in
the Stan Reference Manual. Note: to do a pedantic check for a model
without compiling it or for a model that is already compiled the
$check_syntax()
method can be used instead.
@@ -303,7 +303,7 @@ Examples
}
")
mod <- cmdstan_model(file_pedantic, pedantic = TRUE)
-#> Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/model-11d996d1c906f.stan', line 6, column 2: Parameter
+#> Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/model-5f0d242e1d46.stan', line 6, column 2: Parameter
#> sigma is given a exponential distribution, which has strictly positive
#> support, but sigma was not constrained to be strictly positive.
diff --git a/docs/reference/model-method-diagnose.html b/docs/reference/model-method-diagnose.html
index e4120b50..9a09d308 100644
--- a/docs/reference/model-method-diagnose.html
+++ b/docs/reference/model-method-diagnose.html
@@ -165,10 +165,10 @@ Arguments
write_stan_json()
to write R objects to JSON files compatible with
CmdStan.
A list of lists containing initial values for all or some parameters. For
-MCMC the list should contain a sublist for each chain. For optimization and
-variational inference there should be just one sublist. The sublists should
-have named elements corresponding to the parameters for which you are
-specifying initial values. See Examples.
+MCMC the list should contain a sublist for each chain. For other model
+fitting methods there should be just one sublist. The sublists should have
+named elements corresponding to the parameters for which you are specifying
+initial values. See Examples.
A function that returns a single list with names corresponding to the
parameters for which you are specifying initial values. The function can
take no arguments or a single argument chain_id
. For MCMC, if the function
@@ -245,11 +245,11 @@
Examples
# retrieve the gradients
test$gradients()
-#> param_idx value model finite_diff error
-#> 1 0 0.466346 3.5478 3.5478 1.64210e-08
-#> 2 1 1.496850 -35.5646 -35.5646 6.49428e-09
-#> 3 2 1.385000 -27.1027 -27.1027 -1.36431e-08
-#> 4 3 -0.467569 14.0233 14.0233 1.05492e-08
+#> param_idx value model finite_diff error
+#> 1 0 -1.0700800 30.35590 30.35590 -8.78525e-09
+#> 2 1 0.5670250 -22.14500 -22.14500 9.99824e-09
+#> 3 2 0.0466329 -10.07860 -10.07860 1.68498e-08
+#> 4 3 1.1724800 -5.09201 -5.09201 2.79421e-10
# }
diff --git a/docs/reference/model-method-format.html b/docs/reference/model-method-format.html
index b0a71308..3e6ef100 100644
--- a/docs/reference/model-method-format.html
+++ b/docs/reference/model-method-format.html
@@ -212,7 +212,7 @@ Examples
# overwrite the original file instead of just printing it
mod$format(canonicalize = list("deprecations"), overwrite_file = TRUE)
-#> Old version of the model stored to /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/model_1fc88c86300d78667dd3e476a636c279.stan.bak-20231108103429.
+#> Old version of the model stored to /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/model_1fc88c86300d78667dd3e476a636c279.stan.bak-20231213100754.
mod$compile()
diff --git a/docs/reference/model-method-laplace-1.png b/docs/reference/model-method-laplace-1.png
index 01b1f50d..aaf21c13 100644
Binary files a/docs/reference/model-method-laplace-1.png and b/docs/reference/model-method-laplace-1.png differ
diff --git a/docs/reference/model-method-laplace.html b/docs/reference/model-method-laplace.html
index 6a0d5658..20880c2f 100644
--- a/docs/reference/model-method-laplace.html
+++ b/docs/reference/model-method-laplace.html
@@ -1,5 +1,5 @@
-Run Stan's laplace algorithm — model-method-laplace • cmdstanr Run Stan's Laplace algorithm — model-method-laplace • cmdstanr
- Run Stan's laplace algorithm
+ Run Stan's Laplace algorithm
Source: R/model.R
model-method-laplace.Rd
@@ -192,10 +192,10 @@ Arguments
write_stan_json()
to write R objects to JSON files compatible with
CmdStan.
A list of lists containing initial values for all or some parameters. For
-MCMC the list should contain a sublist for each chain. For optimization and
-variational inference there should be just one sublist. The sublists should
-have named elements corresponding to the parameters for which you are
-specifying initial values. See Examples.
+MCMC the list should contain a sublist for each chain. For other model
+fitting methods there should be just one sublist. The sublists should have
+named elements corresponding to the parameters for which you are specifying
+initial values. See Examples.
A function that returns a single list with names corresponding to the
parameters for which you are specifying initial values. The function can
take no arguments or a single argument chain_id
. For MCMC, if the function
@@ -332,9 +332,9 @@
Examples
stan_data <- list(N = 10, y = c(0,1,0,0,0,0,0,0,0,1))
fit_mode <- mod$optimize(data = stan_data, jacobian = TRUE)
-#> Initial log joint probability = -6.78622
+#> Initial log joint probability = -8.0994
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 4 -6.74802 0.000186334 5.91326e-07 1 1 7
+#> 5 -6.74802 0.000245062 1.61833e-06 1 1 8
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
#> Finished in 0.1 seconds.
@@ -357,15 +357,15 @@ Examples
#> # A tibble: 3 × 7
#> variable mean median sd mad q5 q95
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -7.24 -6.98 0.677 0.309 -8.74 -6.75
-#> 2 lp_approx__ -0.505 -0.230 0.686 0.308 -1.92 -0.00197
-#> 3 theta 0.269 0.254 0.123 0.125 0.0982 0.500
+#> 1 lp__ -7.25 -6.97 0.724 0.305 -8.72 -6.75
+#> 2 lp_approx__ -0.516 -0.225 0.747 0.306 -1.93 -0.00324
+#> 3 theta 0.267 0.250 0.124 0.120 0.0954 0.499
# if mode isn't specified optimize is run internally first
fit_laplace <- mod$laplace(data = stan_data)
-#> Initial log joint probability = -6.7528
+#> Initial log joint probability = -15.1067
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 3 -6.74802 0.000769281 2.15262e-05 1 1 6
+#> 5 -6.74802 0.00203152 6.06231e-05 1 1 8
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
#> Finished in 0.1 seconds.
@@ -387,9 +387,9 @@ Examples
#> # A tibble: 3 × 7
#> variable mean median sd mad q5 q95
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -7.26 -6.95 0.755 0.289 -8.76 -6.75
-#> 2 lp_approx__ -0.518 -0.203 0.755 0.285 -2.15 -0.00170
-#> 3 theta 0.267 0.250 0.125 0.115 0.0947 0.505
+#> 1 lp__ -7.28 -6.98 0.782 0.316 -8.84 -6.75
+#> 2 lp_approx__ -0.531 -0.231 0.756 0.320 -1.96 -0.00280
+#> 3 theta 0.273 0.251 0.128 0.123 0.0984 0.510
# plot approximate posterior
bayesplot::mcmc_hist(fit_laplace$draws("theta"))
diff --git a/docs/reference/model-method-optimize.html b/docs/reference/model-method-optimize.html
index f88b0551..78b2a042 100644
--- a/docs/reference/model-method-optimize.html
+++ b/docs/reference/model-method-optimize.html
@@ -194,10 +194,10 @@ Arguments
write_stan_json()
to write R objects to JSON files compatible with
CmdStan.
A list of lists containing initial values for all or some parameters. For
-MCMC the list should contain a sublist for each chain. For optimization and
-variational inference there should be just one sublist. The sublists should
-have named elements corresponding to the parameters for which you are
-specifying initial values. See Examples.
+MCMC the list should contain a sublist for each chain. For other model
+fitting methods there should be just one sublist. The sublists should have
+named elements corresponding to the parameters for which you are specifying
+initial values. See Examples.
A function that returns a single list with names corresponding to the
parameters for which you are specifying initial values. The function can
take no arguments or a single argument chain_id
. For MCMC, if the function
@@ -531,12 +531,12 @@
Examples
#> 1 lp__ -5.00
#> 2 theta 0.2
-# Run 'optimize' again with 'jacobian=TRUE' and then draw from laplace approximation
+# Run 'optimize' again with 'jacobian=TRUE' and then draw from Laplace approximation
# to the posterior
fit_optim <- mod$optimize(data = my_data_file, jacobian = TRUE)
-#> Initial log joint probability = -11.84
+#> Initial log joint probability = -7.17234
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 5 -6.74802 0.00117606 2.01092e-05 1 1 8
+#> 5 -6.74802 0.000196979 1.66919e-07 1 1 8
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
#> Finished in 0.1 seconds.
@@ -569,9 +569,9 @@ Examples
#> # A tibble: 3 × 7
#> variable mean median sd mad q5 q95
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -7.23 -6.96 0.703 0.291 -8.51 -6.75
-#> 2 lp_approx__ -0.490 -0.218 0.693 0.294 -1.85 -0.00308
-#> 3 theta 0.268 0.247 0.122 0.119 0.0992 0.495
+#> 1 lp__ -7.26 -6.98 0.759 0.313 -8.67 -6.75
+#> 2 lp_approx__ -0.521 -0.232 0.759 0.318 -2.07 -0.00238
+#> 3 theta 0.266 0.248 0.125 0.123 0.0975 0.496
# Run 'variational' method to use ADVI to approximate posterior
fit_vb <- mod$variational(data = stan_data, seed = 123)
@@ -580,8 +580,8 @@ Examples
#> This procedure has not been thoroughly tested and may be unstable
#> or buggy. The interface is subject to change.
#> ------------------------------------------------------------
-#> Gradient evaluation took 8e-06 seconds
-#> 1000 transitions using 10 leapfrog steps per transition would take 0.08 seconds.
+#> Gradient evaluation took 6e-06 seconds
+#> 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.
#> Adjust your expectations accordingly!
#> Begin eta adaptation.
#> Iteration: 1 / 250 [ 0%] (Adaptation)
@@ -640,6 +640,53 @@ Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
+# Run 'pathfinder' again with more paths, fewer draws per path,
+# better covariance approximation, and fewer LBFGSs iterations
+fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40,
+ history_size=50, max_lbfgs_iters=100)
+#> Path [1] :Initial log joint density = -16.937625
+#> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.488e-03 4.162e-05 1.000e+00 1.000e+00 126 -6.227e+00 -6.227e+00
+#> Path [1] :Best Iter: [2] ELBO (-6.211714) evaluations: (126)
+#> Path [2] :Initial log joint density = -6.798413
+#> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 3 -6.748e+00 3.762e-03 4.627e-05 9.519e-01 9.519e-01 76 -6.195e+00 -6.195e+00
+#> Path [2] :Best Iter: [3] ELBO (-6.194747) evaluations: (76)
+#> Path [3] :Initial log joint density = -7.054440
+#> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 4 -6.748e+00 2.741e-03 5.225e-05 1.000e+00 1.000e+00 101 -6.187e+00 -6.187e+00
+#> Path [3] :Best Iter: [4] ELBO (-6.186757) evaluations: (101)
+#> Path [4] :Initial log joint density = -7.467690
+#> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.049e-04 4.080e-07 1.000e+00 1.000e+00 126 -6.224e+00 -6.224e+00
+#> Path [4] :Best Iter: [2] ELBO (-6.213804) evaluations: (126)
+#> Path [5] :Initial log joint density = -14.817294
+#> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 2.041e-03 5.999e-05 1.000e+00 1.000e+00 126 -6.271e+00 -6.271e+00
+#> Path [5] :Best Iter: [3] ELBO (-6.188344) evaluations: (126)
+#> Path [6] :Initial log joint density = -7.375208
+#> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 5.530e-04 1.038e-06 1.000e+00 1.000e+00 126 -6.229e+00 -6.229e+00
+#> Path [6] :Best Iter: [2] ELBO (-6.203592) evaluations: (126)
+#> Path [7] :Initial log joint density = -6.748023
+#> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 2 -6.748e+00 9.521e-04 6.579e-07 1.000e+00 1.000e+00 51 -6.231e+00 -6.231e+00
+#> Path [7] :Best Iter: [2] ELBO (-6.231405) evaluations: (51)
+#> Path [8] :Initial log joint density = -11.312958
+#> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.017e-03 1.576e-05 1.000e+00 1.000e+00 126 -6.304e+00 -6.304e+00
+#> Path [8] :Best Iter: [3] ELBO (-6.185214) evaluations: (126)
+#> Path [9] :Initial log joint density = -6.881067
+#> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 4 -6.748e+00 9.878e-04 9.538e-06 1.000e+00 1.000e+00 101 -6.173e+00 -6.173e+00
+#> Path [9] :Best Iter: [4] ELBO (-6.173184) evaluations: (101)
+#> Path [10] :Initial log joint density = -7.173191
+#> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.980e-04 1.685e-07 1.000e+00 1.000e+00 126 -6.176e+00 -6.176e+00
+#> Path [10] :Best Iter: [5] ELBO (-6.175625) evaluations: (126)
+#> Total log probability function evaluations:1235
+#> Finished in 0.1 seconds.
+
# Specifying initial values as a function
fit_mcmc_w_init_fun <- mod$sample(
data = stan_data,
diff --git a/docs/reference/model-method-pathfinder.html b/docs/reference/model-method-pathfinder.html
index f6423f16..e5caa27c 100644
--- a/docs/reference/model-method-pathfinder.html
+++ b/docs/reference/model-method-pathfinder.html
@@ -2,12 +2,15 @@
Run Stan's Pathfinder Variational Inference Algorithm — model-method-pathfinder • cmdstanr CmdStanModel object runs
Stan's Pathfinder algorithms. Pathfinder is a variational method for
approximately sampling from differentiable log densities. Starting from a
-random initialization, Pathfinder locates normal approximations to the
-target density along a quasi-Newton optimization path, with local
-covariance estimated using the negative inverse Hessian estimates produced
-by the L-BFGS optimizer. Pathfinder returns draws from the Gaussian
-approximation with the lowest estimated Kullback-Leibler (KL) divergence to
-the true posterior. See the
+random initialization, Pathfinder locates normal approximations
+to the target density along a quasi-Newton optimization path in
+the unconstrained space, with local covariance estimated using
+the negative inverse Hessian estimates produced by the LBFGS
+optimizer. Pathfinder selects the normal approximation with the
+lowest estimated Kullback-Leibler (KL) divergence to the true
+posterior. Finally Pathfinder draws from that normal
+approximation and returns the draws transformed to the
+constrained scale. See the
CmdStan User’s Guide
for more details.
Any argument left as NULL
will default to the default value used by the
@@ -203,10 +209,10 @@
Arguments
write_stan_json()
to write R objects to JSON files compatible with
CmdStan.
A list of lists containing initial values for all or some parameters. For
-MCMC the list should contain a sublist for each chain. For optimization and
-variational inference there should be just one sublist. The sublists should
-have named elements corresponding to the parameters for which you are
-specifying initial values. See Examples.
+MCMC the list should contain a sublist for each chain. For other model
+fitting methods there should be just one sublist. The sublists should have
+named elements corresponding to the parameters for which you are specifying
+initial values. See Examples.
A function that returns a single list with names corresponding to the
parameters for which you are specifying initial values. The function can
take no arguments or a single argument chain_id
. For MCMC, if the function
@@ -310,8 +316,9 @@
Arguments
draws
(positive integer) Number of draws to return after performing
-pareto smooted importance sampling (PSIS). This must be smaller than
-single_path_draws * num_paths
.
+pareto smooted importance sampling (PSIS). This should be smaller than
+single_path_draws * num_paths
(future versions of CmdStan will throw a
+warning).
num_paths
@@ -548,12 +555,12 @@ Examples
#> 1 lp__ -5.00
#> 2 theta 0.2
-# Run 'optimize' again with 'jacobian=TRUE' and then draw from laplace approximation
+# Run 'optimize' again with 'jacobian=TRUE' and then draw from Laplace approximation
# to the posterior
fit_optim <- mod$optimize(data = my_data_file, jacobian = TRUE)
-#> Initial log joint probability = -8.53772
+#> Initial log joint probability = -11.5709
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 5 -6.74802 0.000313669 2.44314e-06 1 1 8
+#> 5 -6.74802 0.00107647 1.72219e-05 1 1 8
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
#> Finished in 0.1 seconds.
@@ -584,11 +591,11 @@ Examples
#> Finished in 0.1 seconds.
fit_laplace$summary()
#> # A tibble: 3 × 7
-#> variable mean median sd mad q5 q95
-#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -7.24 -6.97 0.690 0.299 -8.66 -6.75
-#> 2 lp_approx__ -0.502 -0.223 0.693 0.303 -1.94 -0.00213
-#> 3 theta 0.267 0.247 0.123 0.119 0.0995 0.501
+#> variable mean median sd mad q5 q95
+#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 lp__ -7.23 -6.99 0.637 0.323 -8.54 -6.75
+#> 2 lp_approx__ -0.486 -0.238 0.644 0.323 -1.80 -0.00166
+#> 3 theta 0.268 0.252 0.121 0.126 0.104 0.492
# Run 'variational' method to use ADVI to approximate posterior
fit_vb <- mod$variational(data = stan_data, seed = 123)
@@ -597,8 +604,8 @@ Examples
#> This procedure has not been thoroughly tested and may be unstable
#> or buggy. The interface is subject to change.
#> ------------------------------------------------------------
-#> Gradient evaluation took 7e-06 seconds
-#> 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds.
+#> Gradient evaluation took 6e-06 seconds
+#> 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.
#> Adjust your expectations accordingly!
#> Begin eta adaptation.
#> Iteration: 1 / 250 [ 0%] (Adaptation)
@@ -657,6 +664,53 @@ Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
+# Run 'pathfinder' again with more paths, fewer draws per path,
+# better covariance approximation, and fewer LBFGSs iterations
+fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40,
+ history_size=50, max_lbfgs_iters=100)
+#> Path [1] :Initial log joint density = -14.470660
+#> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 2.026e-03 5.797e-05 1.000e+00 1.000e+00 126 -6.259e+00 -6.259e+00
+#> Path [1] :Best Iter: [4] ELBO (-6.211388) evaluations: (126)
+#> Path [2] :Initial log joint density = -9.064681
+#> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 3.457e-04 2.927e-06 1.000e+00 1.000e+00 126 -6.253e+00 -6.253e+00
+#> Path [2] :Best Iter: [3] ELBO (-6.227371) evaluations: (126)
+#> Path [3] :Initial log joint density = -15.152638
+#> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 2.028e-03 6.063e-05 1.000e+00 1.000e+00 126 -6.230e+00 -6.230e+00
+#> Path [3] :Best Iter: [4] ELBO (-6.211247) evaluations: (126)
+#> Path [4] :Initial log joint density = -10.220491
+#> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 7.043e-04 8.900e-06 1.000e+00 1.000e+00 126 -6.194e+00 -6.194e+00
+#> Path [4] :Best Iter: [5] ELBO (-6.193620) evaluations: (126)
+#> Path [5] :Initial log joint density = -6.766009
+#> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 3 -6.748e+00 2.724e-03 1.458e-04 1.000e+00 1.000e+00 76 -6.232e+00 -6.232e+00
+#> Path [5] :Best Iter: [3] ELBO (-6.232284) evaluations: (76)
+#> Path [6] :Initial log joint density = -7.304442
+#> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 4.014e-04 5.879e-07 1.000e+00 1.000e+00 126 -6.247e+00 -6.247e+00
+#> Path [6] :Best Iter: [4] ELBO (-6.212233) evaluations: (126)
+#> Path [7] :Initial log joint density = -7.233791
+#> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 2.804e-04 3.115e-07 1.000e+00 1.000e+00 126 -6.275e+00 -6.275e+00
+#> Path [7] :Best Iter: [4] ELBO (-6.122234) evaluations: (126)
+#> Path [8] :Initial log joint density = -11.942008
+#> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.223e-03 2.161e-05 1.000e+00 1.000e+00 126 -6.232e+00 -6.232e+00
+#> Path [8] :Best Iter: [3] ELBO (-6.217220) evaluations: (126)
+#> Path [9] :Initial log joint density = -7.438064
+#> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 9.817e-05 3.665e-07 1.000e+00 1.000e+00 126 -6.268e+00 -6.268e+00
+#> Path [9] :Best Iter: [3] ELBO (-6.213533) evaluations: (126)
+#> Path [10] :Initial log joint density = -8.992806
+#> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 3.448e-04 2.904e-06 1.000e+00 1.000e+00 126 -6.247e+00 -6.247e+00
+#> Path [10] :Best Iter: [2] ELBO (-6.141839) evaluations: (126)
+#> Total log probability function evaluations:1360
+#> Finished in 0.1 seconds.
+
# Specifying initial values as a function
fit_mcmc_w_init_fun <- mod$sample(
data = stan_data,
diff --git a/docs/reference/model-method-sample.html b/docs/reference/model-method-sample.html
index 02207960..7925e4b4 100644
--- a/docs/reference/model-method-sample.html
+++ b/docs/reference/model-method-sample.html
@@ -210,10 +210,10 @@ Arguments
write_stan_json()
to write R objects to JSON files compatible with
CmdStan.
A list of lists containing initial values for all or some parameters. For
-MCMC the list should contain a sublist for each chain. For optimization and
-variational inference there should be just one sublist. The sublists should
-have named elements corresponding to the parameters for which you are
-specifying initial values. See Examples.
+MCMC the list should contain a sublist for each chain. For other model
+fitting methods there should be just one sublist. The sublists should have
+named elements corresponding to the parameters for which you are specifying
+initial values. See Examples.
A function that returns a single list with names corresponding to the
parameters for which you are specifying initial values. The function can
take no arguments or a single argument chain_id
. For MCMC, if the function
@@ -659,12 +659,12 @@
Examples
#> 1 lp__ -5.00
#> 2 theta 0.2
-# Run 'optimize' again with 'jacobian=TRUE' and then draw from laplace approximation
+# Run 'optimize' again with 'jacobian=TRUE' and then draw from Laplace approximation
# to the posterior
fit_optim <- mod$optimize(data = my_data_file, jacobian = TRUE)
-#> Initial log joint probability = -7.01351
+#> Initial log joint probability = -11.0695
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 4 -6.74802 0.000544739 0.000133582 0.9055 0.9055 7
+#> 5 -6.74802 0.000954615 1.42918e-05 1 1 8
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
#> Finished in 0.1 seconds.
@@ -695,11 +695,11 @@ Examples
#> Finished in 0.1 seconds.
fit_laplace$summary()
#> # A tibble: 3 × 7
-#> variable mean median sd mad q5 q95
-#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -7.24 -6.98 0.692 0.314 -8.61 -6.75
-#> 2 lp_approx__ -0.500 -0.233 0.688 0.317 -1.89 -0.00172
-#> 3 theta 0.269 0.248 0.123 0.122 0.0989 0.503
+#> variable mean median sd mad q5 q95
+#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 lp__ -7.23 -6.97 0.710 0.297 -8.57 -6.75
+#> 2 lp_approx__ -0.490 -0.220 0.696 0.300 -1.90 -0.00171
+#> 3 theta 0.270 0.252 0.123 0.120 0.102 0.495
# Run 'variational' method to use ADVI to approximate posterior
fit_vb <- mod$variational(data = stan_data, seed = 123)
@@ -708,8 +708,8 @@ Examples
#> This procedure has not been thoroughly tested and may be unstable
#> or buggy. The interface is subject to change.
#> ------------------------------------------------------------
-#> Gradient evaluation took 7e-06 seconds
-#> 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds.
+#> Gradient evaluation took 6e-06 seconds
+#> 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.
#> Adjust your expectations accordingly!
#> Begin eta adaptation.
#> Iteration: 1 / 250 [ 0%] (Adaptation)
@@ -768,6 +768,53 @@ Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
+# Run 'pathfinder' again with more paths, fewer draws per path,
+# better covariance approximation, and fewer LBFGSs iterations
+fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40,
+ history_size=50, max_lbfgs_iters=100)
+#> Path [1] :Initial log joint density = -10.398597
+#> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 7.601e-04 1.002e-05 1.000e+00 1.000e+00 126 -6.246e+00 -6.246e+00
+#> Path [1] :Best Iter: [4] ELBO (-6.213236) evaluations: (126)
+#> Path [2] :Initial log joint density = -7.343771
+#> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 4 -6.748e+00 5.658e-03 1.740e-04 1.000e+00 1.000e+00 101 -6.270e+00 -6.270e+00
+#> Path [2] :Best Iter: [3] ELBO (-6.236555) evaluations: (101)
+#> Path [3] :Initial log joint density = -7.253954
+#> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 4 -6.748e+00 4.780e-03 1.316e-04 1.000e+00 1.000e+00 101 -6.293e+00 -6.293e+00
+#> Path [3] :Best Iter: [3] ELBO (-6.210231) evaluations: (101)
+#> Path [4] :Initial log joint density = -6.884985
+#> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 4 -6.748e+00 1.025e-03 1.015e-05 1.000e+00 1.000e+00 101 -6.254e+00 -6.254e+00
+#> Path [4] :Best Iter: [4] ELBO (-6.254382) evaluations: (101)
+#> Path [5] :Initial log joint density = -10.549385
+#> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 8.063e-04 1.099e-05 1.000e+00 1.000e+00 126 -6.155e+00 -6.155e+00
+#> Path [5] :Best Iter: [5] ELBO (-6.154812) evaluations: (126)
+#> Path [6] :Initial log joint density = -11.021697
+#> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 9.418e-04 1.400e-05 1.000e+00 1.000e+00 126 -6.261e+00 -6.261e+00
+#> Path [6] :Best Iter: [4] ELBO (-6.204645) evaluations: (126)
+#> Path [7] :Initial log joint density = -10.721189
+#> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 8.573e-04 1.209e-05 1.000e+00 1.000e+00 126 -6.195e+00 -6.195e+00
+#> Path [7] :Best Iter: [5] ELBO (-6.194637) evaluations: (126)
+#> Path [8] :Initial log joint density = -11.729882
+#> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.125e-03 1.854e-05 1.000e+00 1.000e+00 126 -6.195e+00 -6.195e+00
+#> Path [8] :Best Iter: [4] ELBO (-6.193964) evaluations: (126)
+#> Path [9] :Initial log joint density = -8.375820
+#> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 2.924e-04 2.169e-06 1.000e+00 1.000e+00 126 -6.198e+00 -6.198e+00
+#> Path [9] :Best Iter: [2] ELBO (-6.188312) evaluations: (126)
+#> Path [10] :Initial log joint density = -7.041152
+#> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 4 -6.748e+00 2.604e-03 4.795e-05 1.000e+00 1.000e+00 101 -6.233e+00 -6.233e+00
+#> Path [10] :Best Iter: [2] ELBO (-6.214834) evaluations: (101)
+#> Total log probability function evaluations:1310
+#> Finished in 0.1 seconds.
+
# Specifying initial values as a function
fit_mcmc_w_init_fun <- mod$sample(
data = stan_data,
diff --git a/docs/reference/model-method-sample_mpi.html b/docs/reference/model-method-sample_mpi.html
index 5dd06c42..6247b07a 100644
--- a/docs/reference/model-method-sample_mpi.html
+++ b/docs/reference/model-method-sample_mpi.html
@@ -1,7 +1,7 @@
Run Stan's MCMC algorithms with MPI — model-method-sample_mpi • cmdstanr
The $sample_mpi()
method of a CmdStanModel
object is
identical to the $sample()
method but with support for
-MPI. The target audience for MPI are
+MPI (message passing interface). The target audience for MPI are
those with large computer clusters. For other users, the
$sample()
method provides both parallelization of
chains and threading support for within-chain parallelization.
@@ -247,10 +247,10 @@ Arguments
write_stan_json()
to write R objects to JSON files compatible with
CmdStan.
A list of lists containing initial values for all or some parameters. For
-MCMC the list should contain a sublist for each chain. For optimization and
-variational inference there should be just one sublist. The sublists should
-have named elements corresponding to the parameters for which you are
-specifying initial values. See Examples.
+MCMC the list should contain a sublist for each chain. For other model
+fitting methods there should be just one sublist. The sublists should have
+named elements corresponding to the parameters for which you are specifying
+initial values. See Examples.
A function that returns a single list with names corresponding to the
parameters for which you are specifying initial values. The function can
take no arguments or a single argument chain_id
. For MCMC, if the function
@@ -467,8 +467,8 @@
See also
documentation and tutorials.
The Stan and CmdStan documentation:
Stan documentation: mc-stan.org/users/documentation
CmdStan User’s Guide: mc-stan.org/docs/cmdstan-guide
-
The Stan Math Library's MPI documentation
-(mc-stan.org/math/mpi) for more
+
The Stan Math Library's documentation
+(mc-stan.org/math) for more
details on MPI support in Stan.
Other CmdStanModel methods:
model-method-check_syntax
,
diff --git a/docs/reference/model-method-variational.html b/docs/reference/model-method-variational.html
index 7aee6bce..ed9fcbc4 100644
--- a/docs/reference/model-method-variational.html
+++ b/docs/reference/model-method-variational.html
@@ -197,10 +197,10 @@
Arguments
write_stan_json()
to write R objects to JSON files compatible with
CmdStan.
A list of lists containing initial values for all or some parameters. For
-MCMC the list should contain a sublist for each chain. For optimization and
-variational inference there should be just one sublist. The sublists should
-have named elements corresponding to the parameters for which you are
-specifying initial values. See Examples.
+MCMC the list should contain a sublist for each chain. For other model
+fitting methods there should be just one sublist. The sublists should have
+named elements corresponding to the parameters for which you are specifying
+initial values. See Examples.
A function that returns a single list with names corresponding to the
parameters for which you are specifying initial values. The function can
take no arguments or a single argument chain_id
. For MCMC, if the function
@@ -534,12 +534,12 @@
Examples
#> 1 lp__ -5.00
#> 2 theta 0.2
-# Run 'optimize' again with 'jacobian=TRUE' and then draw from laplace approximation
+# Run 'optimize' again with 'jacobian=TRUE' and then draw from Laplace approximation
# to the posterior
fit_optim <- mod$optimize(data = my_data_file, jacobian = TRUE)
-#> Initial log joint probability = -7.23249
+#> Initial log joint probability = -11.7793
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
-#> 4 -6.74802 0.00456563 0.000121975 1 1 7
+#> 5 -6.74802 0.00114772 1.92382e-05 1 1 8
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
#> Finished in 0.1 seconds.
@@ -572,9 +572,9 @@ Examples
#> # A tibble: 3 × 7
#> variable mean median sd mad q5 q95
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 lp__ -7.25 -6.99 0.712 0.326 -8.66 -6.75
-#> 2 lp_approx__ -0.506 -0.244 0.715 0.329 -1.94 -0.00187
-#> 3 theta 0.269 0.250 0.124 0.126 0.101 0.500
+#> 1 lp__ -7.22 -6.96 0.669 0.294 -8.51 -6.75
+#> 2 lp_approx__ -0.470 -0.213 0.645 0.295 -1.81 -0.00204
+#> 3 theta 0.267 0.247 0.121 0.118 0.104 0.493
# Run 'variational' method to use ADVI to approximate posterior
fit_vb <- mod$variational(data = stan_data, seed = 123)
@@ -583,8 +583,8 @@ Examples
#> This procedure has not been thoroughly tested and may be unstable
#> or buggy. The interface is subject to change.
#> ------------------------------------------------------------
-#> Gradient evaluation took 7e-06 seconds
-#> 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds.
+#> Gradient evaluation took 5e-06 seconds
+#> 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds.
#> Adjust your expectations accordingly!
#> Begin eta adaptation.
#> Iteration: 1 / 250 [ 0%] (Adaptation)
@@ -643,6 +643,54 @@ Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
+# Run 'pathfinder' again with more paths, fewer draws per path,
+# better covariance approximation, and fewer LBFGSs iterations
+fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40,
+ history_size=50, max_lbfgs_iters=100)
+#> Path [1] :Initial log joint density = -7.711026
+#> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.614e-04 8.188e-07 1.000e+00 1.000e+00 126 -6.206e+00 -6.206e+00
+#> Path [1] :Best Iter: [5] ELBO (-6.205511) evaluations: (126)
+#> Path [2] :Initial log joint density = -12.450513
+#> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.452e-03 2.960e-05 1.000e+00 1.000e+00 126 -6.251e+00 -6.251e+00
+#> Path [2] :Best Iter: [4] ELBO (-6.229238) evaluations: (126)
+#> Path [3] :Initial log joint density = -7.647405
+#> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.466e-04 7.009e-07 1.000e+00 1.000e+00 126 -6.193e+00 -6.193e+00
+#> Path [3] :Best Iter: [3] ELBO (-6.164986) evaluations: (126)
+#> Path [4] :Initial log joint density = -15.036045
+#> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 2.036e-03 6.056e-05 1.000e+00 1.000e+00 126 -6.235e+00 -6.235e+00
+#> Path [4] :Best Iter: [2] ELBO (-6.225650) evaluations: (126)
+#> Path [5] :Initial log joint density = -6.760365
+#> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 3 -6.748e+00 1.911e-03 8.518e-05 1.000e+00 1.000e+00 76 -6.247e+00 -6.247e+00
+#> Path [5] :Best Iter: [3] ELBO (-6.246721) evaluations: (76)
+#> Path [6] :Initial log joint density = -6.826898
+#> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 3 -6.748e+00 5.423e-03 1.282e-04 9.360e-01 9.360e-01 76 -6.169e+00 -6.169e+00
+#> Path [6] :Best Iter: [3] ELBO (-6.168890) evaluations: (76)
+#> Path [7] :Initial log joint density = -8.134235
+#> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 2.517e-04 1.691e-06 1.000e+00 1.000e+00 126 -6.243e+00 -6.243e+00
+#> Path [7] :Best Iter: [3] ELBO (-6.175493) evaluations: (126)
+#> Path [8] :Initial log joint density = -7.511494
+#> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 9.446e-04 2.687e-06 1.000e+00 1.000e+00 126 -6.214e+00 -6.214e+00
+#> Path [8] :Best Iter: [2] ELBO (-6.197279) evaluations: (126)
+#> Path [9] :Initial log joint density = -11.516990
+#> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.065e-03 1.693e-05 1.000e+00 1.000e+00 126 -6.244e+00 -6.244e+00
+#> Path [9] :Best Iter: [3] ELBO (-6.194623) evaluations: (126)
+#> Path [10] :Initial log joint density = -17.778190
+#> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes
+#> 5 -6.748e+00 1.013e-03 2.414e-05 1.000e+00 1.000e+00 126 -6.262e+00 -6.262e+00
+#> Path [10] :Best Iter: [4] ELBO (-6.170410) evaluations: (126)
+#> Total log probability function evaluations:1310
+#> Pareto k value (0.820024) is greater than 0.7. Importance resampling was not able to improve the approximation, which may indicate that the approximation itself is poor.
+#> Finished in 0.1 seconds.
+
# Specifying initial values as a function
fit_mcmc_w_init_fun <- mod$sample(
data = stan_data,
diff --git a/docs/reference/read_cmdstan_csv.html b/docs/reference/read_cmdstan_csv.html
index d5b0c50d..d6b8fb74 100644
--- a/docs/reference/read_cmdstan_csv.html
+++ b/docs/reference/read_cmdstan_csv.html
@@ -223,10 +223,10 @@ Examples
fit1 <- cmdstanr_example("logistic", method = "sample", save_warmup = TRUE)
csv_files <- fit1$output_files()
print(csv_files)
-#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081035-1-32a06f.csv"
-#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081035-2-32a06f.csv"
-#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081035-3-32a06f.csv"
-#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-202311081035-4-32a06f.csv"
+#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131008-1-642e8e.csv"
+#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131008-2-642e8e.csv"
+#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131008-3-642e8e.csv"
+#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-202312131008-4-642e8e.csv"
# Creating fitting model objects
@@ -234,9 +234,9 @@ Examples
fit2 <- as_cmdstan_fit(csv_files)
fit2$print("beta")
#> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail
-#> beta[1] -0.67 -0.66 0.25 0.24 -1.08 -0.28 1.00 4402 2852
-#> beta[2] -0.27 -0.27 0.22 0.22 -0.65 0.09 1.00 4396 2793
-#> beta[3] 0.68 0.67 0.27 0.26 0.27 1.12 1.00 4545 3039
+#> beta[1] -0.67 -0.66 0.25 0.25 -1.09 -0.26 1.00 4234 3123
+#> beta[2] -0.28 -0.27 0.23 0.23 -0.65 0.09 1.00 4067 3185
+#> beta[3] 0.69 0.67 0.27 0.27 0.26 1.14 1.00 4291 3208
# Using read_cmdstan_csv
#
@@ -248,7 +248,7 @@ Examples
#> ..$ stan_version_major : num 2
#> ..$ stan_version_minor : num 33
#> ..$ stan_version_patch : num 0
-#> ..$ start_datetime : chr "2023-11-08 17:35:02 UTC"
+#> ..$ start_datetime : chr "2023-12-13 17:08:27 UTC"
#> ..$ method : chr "sample"
#> ..$ save_warmup : num 1
#> ..$ thin : num 1
@@ -265,14 +265,14 @@ Examples
#> ..$ num_chains : num 1
#> ..$ id : num [1:4] 1 2 3 4
#> ..$ init : num [1:4] 2 2 2 2
-#> ..$ seed : num 1.63e+09
+#> ..$ seed : num 1.1e+09
#> ..$ refresh : num 100
#> ..$ sig_figs : num -1
-#> ..$ profile_file : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/logistic-profile-202311081035-1-02259b.csv"
+#> ..$ profile_file : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/logistic-profile-202312131008-1-0e2cb1.csv"
#> ..$ stanc_version : chr "stanc3 v2.33.1"
#> ..$ sampler_diagnostics : chr [1:6] "accept_stat__" "stepsize__" "treedepth__" "n_leapfrog__" ...
#> ..$ variables : chr [1:105] "lp__" "alpha" "beta[1]" "beta[2]" ...
-#> ..$ step_size_adaptation: num [1:4] 0.731 0.842 0.658 0.727
+#> ..$ step_size_adaptation: num [1:4] 0.761 0.758 0.859 0.765
#> ..$ model_name : chr "logistic_model"
#> ..$ adapt_engaged : num 1
#> ..$ adapt_delta : num 0.8
@@ -283,9 +283,9 @@ Examples
#> ..$ threads_per_chain : num 1
#> ..$ time :'data.frame': 4 obs. of 4 variables:
#> .. ..$ chain_id: num [1:4] 1 2 3 4
-#> .. ..$ warmup : num [1:4] 0.071 0.073 0.078 0.075
-#> .. ..$ sampling: num [1:4] 0.075 0.089 0.078 0.073
-#> .. ..$ total : num [1:4] 0.146 0.162 0.156 0.148
+#> .. ..$ warmup : num [1:4] 0.071 0.073 0.072 0.069
+#> .. ..$ sampling: num [1:4] 0.068 0.068 0.065 0.068
+#> .. ..$ total : num [1:4] 0.139 0.141 0.137 0.137
#> ..$ stan_variable_sizes :List of 4
#> .. ..$ lp__ : num 1
#> .. ..$ alpha : num 1
@@ -297,35 +297,35 @@ Examples
#> ..$ total : int NA
#> ..$ chains:'data.frame': 4 obs. of 4 variables:
#> .. ..$ chain_id: num [1:4] 1 2 3 4
-#> .. ..$ warmup : num [1:4] 0.071 0.073 0.078 0.075
-#> .. ..$ sampling: num [1:4] 0.075 0.089 0.078 0.073
-#> .. ..$ total : num [1:4] 0.146 0.162 0.156 0.148
+#> .. ..$ warmup : num [1:4] 0.071 0.073 0.072 0.069
+#> .. ..$ sampling: num [1:4] 0.068 0.068 0.065 0.068
+#> .. ..$ total : num [1:4] 0.139 0.141 0.137 0.137
#> $ inv_metric :List of 4
-#> ..$ 1: num [1:4] 0.0464 0.0532 0.0478 0.0741
-#> ..$ 2: num [1:4] 0.0374 0.0624 0.0482 0.0688
-#> ..$ 3: num [1:4] 0.042 0.0545 0.0473 0.0754
-#> ..$ 4: num [1:4] 0.0411 0.0563 0.0539 0.0609
+#> ..$ 1: num [1:4] 0.0469 0.0641 0.0523 0.0688
+#> ..$ 2: num [1:4] 0.0438 0.0555 0.0497 0.0685
+#> ..$ 3: num [1:4] 0.0457 0.0612 0.0451 0.0706
+#> ..$ 4: num [1:4] 0.0436 0.0627 0.0506 0.0832
#> $ step_size :List of 4
-#> ..$ 1: num 0.731
-#> ..$ 2: num 0.842
-#> ..$ 3: num 0.658
-#> ..$ 4: num 0.727
-#> $ warmup_draws : 'draws_array' num [1:1000, 1:4, 1:105] -78.1 -78.1 -78.1 -64.4 -66.7 ...
+#> ..$ 1: num 0.761
+#> ..$ 2: num 0.758
+#> ..$ 3: num 0.859
+#> ..$ 4: num 0.765
+#> $ warmup_draws : 'draws_array' num [1:1000, 1:4, 1:105] -72 -72 -72 -71.3 -68.2 ...
#> ..- attr(*, "dimnames")=List of 3
#> .. ..$ iteration: chr [1:1000] "1" "2" "3" "4" ...
#> .. ..$ chain : chr [1:4] "1" "2" "3" "4"
#> .. ..$ variable : chr [1:105] "lp__" "alpha" "beta[1]" "beta[2]" ...
-#> $ post_warmup_draws : 'draws_array' num [1:1000, 1:4, 1:105] -68.5 -66.2 -68 -68.3 -67.2 ...
+#> $ post_warmup_draws : 'draws_array' num [1:1000, 1:4, 1:105] -64.3 -64.3 -65.7 -67.2 -66 ...
#> ..- attr(*, "dimnames")=List of 3
#> .. ..$ iteration: chr [1:1000] "1" "2" "3" "4" ...
#> .. ..$ chain : chr [1:4] "1" "2" "3" "4"
#> .. ..$ variable : chr [1:105] "lp__" "alpha" "beta[1]" "beta[2]" ...
-#> $ warmup_sampler_diagnostics : 'draws_array' num [1:1000, 1:4, 1:6] 1 0 0 1 0.515 ...
+#> $ warmup_sampler_diagnostics : 'draws_array' num [1:1000, 1:4, 1:6] 1 0 0 0.597 1 ...
#> ..- attr(*, "dimnames")=List of 3
#> .. ..$ iteration: chr [1:1000] "1" "2" "3" "4" ...
#> .. ..$ chain : chr [1:4] "1" "2" "3" "4"
#> .. ..$ variable : chr [1:6] "accept_stat__" "stepsize__" "treedepth__" "n_leapfrog__" ...
-#> $ post_warmup_sampler_diagnostics: 'draws_array' num [1:1000, 1:4, 1:6] 0.856 1 0.856 0.984 1 ...
+#> $ post_warmup_sampler_diagnostics: 'draws_array' num [1:1000, 1:4, 1:6] 0.971 0.97 0.742 0.882 0.87 ...
#> ..- attr(*, "dimnames")=List of 3
#> .. ..$ iteration: chr [1:1000] "1" "2" "3" "4" ...
#> .. ..$ chain : chr [1:4] "1" "2" "3" "4"
diff --git a/docs/reference/write_stan_file.html b/docs/reference/write_stan_file.html
index 10ffeb6e..e1459132 100644
--- a/docs/reference/write_stan_file.html
+++ b/docs/reference/write_stan_file.html
@@ -188,7 +188,7 @@ Examples
f <- write_stan_file(stan_program)
print(f)
-#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpGCiVFY/model_7f12fc190dd23b0e462f7d73040dd97e.stan"
+#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpAMFHpW/model_7f12fc190dd23b0e462f7d73040dd97e.stan"
lines <- readLines(f)
print(lines)
diff --git a/docs/reference/write_stan_json.html b/docs/reference/write_stan_json.html
index d09ca22c..b7b128ef 100644
--- a/docs/reference/write_stan_json.html
+++ b/docs/reference/write_stan_json.html
@@ -167,13 +167,13 @@ Examples
#> "N": 5,
#> "K": 2,
#> "x": [
-#> [0.539316345307751, 1.20165111819522],
-#> [0.027826781785157, -0.219847554976374],
-#> [-0.171509078741447, 1.08053600860179],
-#> [1.01158266854045, 0.0611935712707024],
-#> [-0.426238537104135, 0.270940591850318]
+#> [0.281077678546936, -1.18908686575029],
+#> [0.858726751146771, 0.46461805175525],
+#> [-0.700205759803986, -0.115709696625946],
+#> [1.45853659080418, 0.995745564145492],
+#> [-0.671485199795285, -0.298752493529616]
#> ],
-#> "y": [10, 8, 13, 10, 12],
+#> "y": [12, 6, 11, 9, 11],
#> "z": [1, 0]
#> }
diff --git a/docs/sitemap.xml b/docs/sitemap.xml
index 6866e056..74c96150 100644
--- a/docs/sitemap.xml
+++ b/docs/sitemap.xml
@@ -3,6 +3,9 @@
https://mc-stan.org/cmdstanr/404.html
+
+ https://mc-stan.org/cmdstanr/CONTRIBUTING.html
+
https://mc-stan.org/cmdstanr/LICENSE-text.html