diff --git a/docs/404.html b/docs/404.html index becc3d451..692fbba97 100644 --- a/docs/404.html +++ b/docs/404.html @@ -39,7 +39,7 @@ diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html index af3c28f4c..50f352cb8 100644 --- a/docs/CONTRIBUTING.html +++ b/docs/CONTRIBUTING.html @@ -17,7 +17,7 @@ diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 347bf2725..844078cec 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -17,7 +17,7 @@ diff --git a/docs/LICENSE.html b/docs/LICENSE.html index 8cb6242d8..c81b1727a 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -17,7 +17,7 @@ diff --git a/docs/articles/articles-online-only/opencl.html b/docs/articles/articles-online-only/opencl.html index df160a0ad..316998bfe 100644 --- a/docs/articles/articles-online-only/opencl.html +++ b/docs/articles/articles-online-only/opencl.html @@ -40,7 +40,7 @@ diff --git a/docs/articles/cmdstanr-internals.html b/docs/articles/cmdstanr-internals.html index d034b3188..1b68fe28c 100644 --- a/docs/articles/cmdstanr-internals.html +++ b/docs/articles/cmdstanr-internals.html @@ -40,7 +40,7 @@ @@ -183,10 +183,10 @@
mod$stan_file()[1] "/Users/jgabry/.cmdstan/cmdstan-2.35.0/examples/bernoulli/bernoulli.stan"
+[1] "/Users/jgabry/.cmdstan/cmdstan-2.36.0/examples/bernoulli/bernoulli.stan"
mod$exe_file()[1] "/Users/jgabry/.cmdstan/cmdstan-2.35.0/examples/bernoulli/bernoulli"
+[1] "/Users/jgabry/.cmdstan/cmdstan-2.36.0/examples/bernoulli/bernoulli"
Subsequently, if you create a CmdStanModel object from
the same Stan file then compilation will be skipped (assuming the file
hasn’t changed).
mod$compile()
mod$exe_file()
-[1] "/Users/jgabry/.cmdstan/cmdstan-2.35.0/examples/bernoulli/bernoulli"
+[1] "/Users/jgabry/.cmdstan/cmdstan-2.36.0/examples/bernoulli/bernoulli"
mod_pedantic <- cmdstan_model(stan_file_pedantic, pedantic = TRUE) -Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/model-9a1418059d6f.stan', line 11, column 14: A +Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/model-d1b6650db73c.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/Rtmp2hQnhs/model_febb1e69c7387a0e64cf13583e078104.stan', line 11, column 14: A +Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/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 @@ -300,18 +300,18 @@Pedantic check -
+[1] TRUE +rm(mod_pedantic) + +mod_pedantic <- cmdstan_model(stan_file_pedantic, compile = FALSE) +mod_pedantic$check_syntax(pedantic = TRUE) +Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/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 + provided, or the prior(s) depend on data variables. In the later case, + this may be a false positive. +Stan program is syntactically correctrm(mod_pedantic) - -mod_pedantic <- cmdstan_model(stan_file_pedantic, compile = FALSE) -mod_pedantic$check_syntax(pedantic = TRUE) -Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/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 - provided, or the prior(s) depend on data variables. In the later case, - this may be a false positive. -Stan program is syntactically correct
+stan_file_variables <- write_stan_file(" data { int<lower=1> J; @@ -351,47 +351,47 @@Stan model variables
+names(variables)-[1] "parameters" "included_files" "data" [4] "transformed_parameters" "generated_quantities"+names(variables$data)-[1] "J" "sigma" "y"+names(variables$parameters)-[1] "mu" "tau" "theta_raw"@@ -288,7 +288,7 @@+names(variables$transformed_parameters)-[1] "theta"diff --git a/docs/reference/index.html b/docs/reference/index.html index 34e0d0721..5537abbbe 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -17,7 +17,7 @@+names(variables$generated_quantities)character(0)Each variable is represented as a list containing the type information (currently limited to
-realorint) and the number of dimensions.diff --git a/docs/reference/fit-method-variable_skeleton.html b/docs/reference/fit-method-variable_skeleton.html index 41318d097..defab3ed4 100644 --- a/docs/reference/fit-method-variable_skeleton.html +++ b/docs/reference/fit-method-variable_skeleton.html @@ -19,7 +19,7 @@+variables$data$J-$type [1] "int" $dimensions [1] 0diff --git a/docs/reference/fit-method-unconstrain_variables.html b/docs/reference/fit-method-unconstrain_variables.html index 9ad0b93be..1d18cd8ee 100644 --- a/docs/reference/fit-method-unconstrain_variables.html +++ b/docs/reference/fit-method-unconstrain_variables.html @@ -18,7 +18,7 @@+variables$data$sigma-$type [1] "real" $dimensions [1] 1@@ -427,7 +427,7 @@+variables$parameters$tau-$type [1] "real" $dimensions [1] 0+variables$transformed_parameters$theta$type [1] "real" @@ -405,7 +405,7 @@Executable location
+mod <- cmdstan_model(stan_file, dir = "path/to/directory/for/executable")Named list of R objectsN, the number of data points, and
yan integer array of observations. -diff --git a/docs/reference/fit-method-unconstrain_draws.html b/docs/reference/fit-method-unconstrain_draws.html index 761b9f8e3..33a5af95d 100644 --- a/docs/reference/fit-method-unconstrain_draws.html +++ b/docs/reference/fit-method-unconstrain_draws.html @@ -22,7 +22,7 @@+mod$print()-data { int<lower=0> N; @@ -440,7 +440,7 @@Named list of R objects
@@ -140,36 +140,36 @@+@@ -448,7 +448,7 @@# data block has 'N' and 'y' data_list <- list(N = 10, y = c(0,1,0,0,0,0,0,0,0,1)) fit <- mod$sample(data = data_list)Named list of R objectswrite_stan_json(). This happens internally, but it is also possible to call
write_stan_json()directly. -@@ -163,53 +163,53 @@+data_list <- list(N = 10, y = c(0,1,0,0,0,0,0,0,0,1)) json_file <- tempfile(fileext = ".json") write_stan_json(data_list, json_file) @@ -465,7 +465,7 @@: -JSON filewrite_stan_json()
+fit <- mod$sample(data = json_file)@@ -475,7 +475,7 @@@@ -113,6 +116,9 @@R dump filerstan::stan_rdump(): -
@@ -130,9 +130,7 @@+@@ -176,35 +176,35 @@rdump_file <- tempfile(fileext = ".data.R") rstan::stan_rdump(names(data_list), file = rdump_file, envir = list2env(data_list)) cat(readLines(rdump_file), sep = "\n") @@ -488,31 +488,31 @@Writing CmdStan output to CSV
Default temporary files
-@@ -122,10 +122,10 @@+When fitting a model, the default behavior is to write the output from CmdStan to CSV files in a temporary directory.
-diff --git a/docs/reference/fit-method-loo.html b/docs/reference/fit-method-loo.html index dcb5e515f..30281bc5c 100644 --- a/docs/reference/fit-method-loo.html +++ b/docs/reference/fit-method-loo.html @@ -21,7 +21,7 @@+-fit$output_files()+[1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/bernoulli-202407021546-1-2808db.csv" -[2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/bernoulli-202407021546-2-2808db.csv" -[3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/bernoulli-202407021546-3-2808db.csv" -[4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/bernoulli-202407021546-4-2808db.csv"[1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/bernoulli-202503310850-1-5c7cee.csv" +[2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/bernoulli-202503310850-2-5c7cee.csv" +[3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/bernoulli-202503310850-3-5c7cee.csv" +[4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/bernoulli-202503310850-4-5c7cee.csv"These files will be lost if you end your R session or if you remove the
-fitobject and force (or wait for) garbage collection.@@ -139,76 +139,76 @@+files <- fit$output_files() file.exists(files)-[1] TRUE TRUE TRUE TRUEdiff --git a/docs/reference/fit-method-inv_metric.html b/docs/reference/fit-method-inv_metric.html index 56268463d..1a8c8a7e2 100644 --- a/docs/reference/fit-method-inv_metric.html +++ b/docs/reference/fit-method-inv_metric.html @@ -17,7 +17,7 @@+ --used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) -Ncells 1155803 61.8 2350794 125.6 NA 1542121 82.4 -Vcells 2048173 15.7 8388608 64.0 32768 2851724 21.8@@ -523,10 +523,10 @@++used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) +Ncells 1161565 62.1 2340494 125 NA 1595651 85.3 +Vcells 2051945 15.7 8388608 64 32768 4957304 37.9file.exists(files)[1] FALSE FALSE FALSE FALSENon-temporary files
+-# see ?save_output_files for info on optional arguments fit$save_output_files(dir = "path/to/directory")@@ -140,11 +140,11 @@+diff --git a/docs/reference/fit-method-init.html b/docs/reference/fit-method-init.html index 10e3fac7a..4d0449d46 100644 --- a/docs/reference/fit-method-init.html +++ b/docs/reference/fit-method-init.html @@ -22,7 +22,7 @@fit <- mod$sample( data = data_list, output_dir = "path/to/directory" @@ -546,7 +546,7 @@object, notice how theLazy CSV readingfit
Privateslotdraws_isNULL, indicating that the CSV files haven’t yet been read into R. -diff --git a/docs/reference/fit-method-hessian.html b/docs/reference/fit-method-hessian.html index 0e80242bd..4cc7fea86 100644 --- a/docs/reference/fit-method-hessian.html +++ b/docs/reference/fit-method-hessian.html @@ -18,7 +18,7 @@+str(fit)Classes 'CmdStanMCMC', 'CmdStanFit', 'R6' <CmdStanMCMC> Inherits from: <CmdStanFit> @@ -605,13 +605,13 @@Lazy CSV reading
After we call a method that requires the draws then if we reexamine the structure of the object we will see that the
-draws_slot inPrivateis no longer empty.@@ -132,10 +132,10 @@+draws <- fit$draws() # force CSVs to be read into R str(fit)Classes 'CmdStanMCMC', 'CmdStanFit', 'R6' <CmdStanMCMC> @@ -663,7 +663,7 @@Lazy CSV readingLazy CSV reading
For models with many parameters, transformed parameters, or generated @@ -686,7 +686,7 @@
read_cmdstan_csv()read_cmdstan_csv() function is used to read the CmdStan CSV files into R. This function is exposed to users, so you can also call it directly. -
diff --git a/docs/reference/fit-method-gradients.html b/docs/reference/fit-method-gradients.html index 3e3e1e00e..c331800f7 100644 --- a/docs/reference/fit-method-gradients.html +++ b/docs/reference/fit-method-gradients.html @@ -18,7 +18,7 @@+@@ -161,33 +161,33 @@# see ?read_cmdstan_csv for info on optional arguments controlling # what information is read in csv_contents <- read_cmdstan_csv(fit$output_files()) @@ -694,9 +694,9 @@read_cmdstan_csv()read_cmdstan_csv()read_cmdstan_csv()read_cmdstan_csv()as_cmdstan_fit()
If you need to manually create fitted model objects from CmdStan CSV files use
-as_cmdstan_fit().diff --git a/docs/reference/fit-method-diagnostic_summary.html b/docs/reference/fit-method-diagnostic_summary.html index a3208753e..d7d13b7c6 100644 --- a/docs/reference/fit-method-diagnostic_summary.html +++ b/docs/reference/fit-method-diagnostic_summary.html @@ -24,7 +24,7 @@+fit2 <- as_cmdstan_fit(fit$output_files())This is pointless in our case since we have the original
fitobject, but this function can be used to create fitted @@ -793,32 +793,32 @@Saving and
CmdStanR does not yet provide a special method for processing these files but they can be read into R using R’s standard CSV reading functions.
-+-fit <- mod$sample(data = data_list, save_latent_dynamics = TRUE)-+-fit$latent_dynamics_files()-[1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/bernoulli-diagnostic-202407021546-1-54a823.csv" -[2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/bernoulli-diagnostic-202407021546-2-54a823.csv" -[3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/bernoulli-diagnostic-202407021546-3-54a823.csv" -[4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/bernoulli-diagnostic-202407021546-4-54a823.csv"++[1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/bernoulli-diagnostic-202503310850-1-060b43.csv" +[2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/bernoulli-diagnostic-202503310850-2-060b43.csv" +[3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/bernoulli-diagnostic-202503310850-3-060b43.csv" +[4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/bernoulli-diagnostic-202503310850-4-060b43.csv"# read one of the files in x <- utils::read.csv(fit$latent_dynamics_files()[1], comment.char = "#") head(x)+1 7.05933 -0.633893 0.440038 1.159540 +2 7.38011 -0.432323 -0.558539 1.722860 +3 7.12220 -0.836018 -1.062060 0.628489 +4 6.85073 -0.850225 0.342380 0.592629 +5 6.85434 -1.166260 0.623978 -0.149621 +6 6.92007 -0.744453 0.296526 0.864374lp__ accept_stat__ stepsize__ treedepth__ n_leapfrog__ divergent__ -1 -6.77025 0.987691 0.980824 2 3 0 -2 -7.20991 0.932461 0.980824 2 3 0 -3 -7.66830 0.933065 0.980824 1 1 0 -4 -7.37078 1.000000 0.980824 1 1 0 -5 -7.59961 0.948892 0.980824 2 3 0 -6 -7.95801 0.940559 0.980824 2 3 0 +1 -7.00899 0.935119 1.06923 1 3 0 +2 -7.29900 0.886772 1.06923 1 1 0 +3 -6.82892 1.000000 1.06923 1 1 0 +4 -6.82025 1.000000 1.06923 1 1 0 +5 -6.75311 0.993504 1.06923 2 3 0 +6 -6.89721 0.960772 1.06923 1 3 0 energy__ theta p_theta g_theta -1 7.08007 -0.959636 -1.160790 0.323414 -2 7.21726 -1.779880 0.178790 -1.268180 -3 7.67261 -2.089350 -0.136971 -1.678370 -4 7.66302 -1.898700 -1.127370 -1.436940 -5 8.20617 -2.047820 -1.624180 -1.628720 -6 8.67205 -2.252980 1.762220 -1.858880The column
lp__is also provided viafit$draws(), and the columnsaccept_stat__,stepsize__,treedepth__, @@ -826,15 +826,15 @@Saving and
energy__are also provided byfit$sampler_diagnostics(), but there are several columns unique to the latent dynamics file. -++1 -0.633893 0.440038 1.159540 +2 -0.432323 -0.558539 1.722860 +3 -0.836018 -1.062060 0.628489 +4 -0.850225 0.342380 0.592629 +5 -1.166260 0.623978 -0.149621 +6 -0.744453 0.296526 0.864374theta p_theta g_theta -1 -0.959636 -1.160790 0.323414 -2 -1.779880 0.178790 -1.268180 -3 -2.089350 -0.136971 -1.678370 -4 -1.898700 -1.127370 -1.436940 -5 -2.047820 -1.624180 -1.628720 -6 -2.252980 1.762220 -1.858880Our model has a single parameter
thetaand the three columns above correspond tothetain the unconstrained space (thetaon the constrained @@ -877,24 +877,24 @@Troubleshooting and debugging to
TRUE. -+options("cmdstanr_verbose"=TRUE) mod <- cmdstan_model(stan_file, force_recompile = TRUE)-Running make \ - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/model-9a14560da326 \ + /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/model-d1b65860dc19 \ "STANCFLAGS += --name='bernoulli_model'" --- Translating Stan model to C++ code --- -bin/stanc --name='bernoulli_model' --o=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/model-9a14560da326.hpp /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/model-9a14560da326.stan +bin/stanc --name='bernoulli_model' --o=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/model-d1b65860dc19.hpp /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/model-d1b65860dc19.stan --- Compiling C++ code --- -clang++ -Wno-deprecated-declarations -Wno-deprecated-declarations -std=c++17 -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.84.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.hpp.gch/model_header_15_0.hpp.gch -x c++ -o /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/model-9a14560da326.o /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/model-9a14560da326.hpp +clang++ -O3 -march=native -mtune=native -Wno-deprecated-declarations -std=c++17 -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.84.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.hpp.gch/model_header_16_0.hpp.gch -x c++ -o /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/model-d1b65860dc19.o /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/model-d1b65860dc19.hpp --- Linking model --- -clang++ -Wno-deprecated-declarations -Wno-deprecated-declarations -std=c++17 -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.84.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.35.0/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/jgabry/.cmdstan/cmdstan-2.35.0/stan/lib/stan_math/lib/tbb" /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/model-9a14560da326.o src/cmdstan/main.o -ltbb 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/Rtmp2hQnhs/model-9a14560da326 -rm /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/model-9a14560da326.hpp /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/model-9a14560da326.o@@ -214,10 +214,10 @@+clang++ -O3 -march=native -mtune=native -Wno-deprecated-declarations -std=c++17 -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.84.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.36.0/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/jgabry/.cmdstan/cmdstan-2.36.0/stan/lib/stan_math/lib/tbb" /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/model-d1b65860dc19.o src/cmdstan/main.o -ltbb 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/RtmpI5U8HG/model-d1b65860dc19 +rm /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/model-d1b65860dc19.o /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/model-d1b65860dc19.hpp+fit <- mod$sample( data = data_list, chains = 1, @@ -903,11 +903,11 @@Troubleshooting and debugging)
Running MCMC with 1 chain... -Running ./bernoulli 'id=1' random 'seed=707272264' data \ - 'file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/standata-9a144d3dc244.json' \ +Running ./bernoulli 'id=1' random 'seed=1376020223' data \ + 'file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/standata-d1b61e77387.json' \ output \ - 'file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/bernoulli-202407021546-1-38ac27.csv' \ - 'profile_file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2hQnhs/bernoulli-profile-202407021546-1-910909.csv' \ + 'file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/bernoulli-202503310850-1-1ead10.csv' \ + 'profile_file=/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpI5U8HG/bernoulli-profile-202503310850-1-3e64eb.csv' \ 'method=sample' 'num_samples=100' 'num_warmup=100' 'save_warmup=0' \ 'algorithm=hmc' 'engine=nuts' adapt 'engaged=1' Chain 1 method = sample (Default) @@ -938,20 +938,20 @@Troubleshooting and debuggingTroubleshooting and debugging cmdstanr - 0.8.1 + 0.9.0
Installing CmdStancmdstan_version(): -
+[1] "/Users/jgabry/.cmdstan/cmdstan-2.35.0"-[1] "/Users/jgabry/.cmdstan/cmdstan-2.36.0"+[1] "2.35.0"[1] "2.36.0"-Compiling a model @@ -254,7 +254,7 @@
Compiling a model
mod$exe_file()+[1] "/Users/jgabry/.cmdstan/cmdstan-2.35.0/examples/bernoulli/bernoulli"[1] "/Users/jgabry/.cmdstan/cmdstan-2.36.0/examples/bernoulli/bernoulli"Running MCMC @@ -348,16 +348,16 @@
Summaries from the posterior packa extra_quantiles = ~posterior::quantile2(., probs = c(.0275, .975)) )
+1 lp__ -7.30 -6.99 0.79 0.33 -8.927 -6.75 1 1769 1938 +2 theta 0.25 0.24 0.12 0.12 0.078 0.48 1 1228 1521variable mean median sd mad q5 q95 rhat ess_bulk ess_tail -1 lp__ -7.31 -7.01 0.81 0.34 -8.871 -6.75 1 1404 1631 -2 theta 0.26 0.24 0.13 0.13 0.079 0.49 1 1130 1314+1 theta 0.25 0.12 +2 lp__ -7.30 0.79variable mean sd -1 theta 0.26 0.13 -2 lp__ -7.31 0.81variable pr_lt_half 1 theta 0.96+1 lp__ -7.30 -6.99 0.79 0.33 -8.927 -6.75 -9.429 -6.75 +2 theta 0.25 0.24 0.12 0.12 0.078 0.48 0.062 0.54variable mean median sd mad q5 q95 q2.75 q97.5 -1 lp__ -7.31 -7.01 0.81 0.34 -8.871 -6.75 -9.443 -6.75 -2 theta 0.26 0.24 0.13 0.13 0.079 0.49 0.063 0.54CmdStan’s stansummary utility @@ -491,7 +491,7 @@
Sampler diagnostic warnings a [1] 0 0 0 0 $ebfmi -[1] 1.11 0.80 1.05 0.95 +[1] 1.11 0.76 1.19 1.08
We see the number of divergences for each of the four chains, the number of times the maximum treedepth was hit for each chain, and the E-BFMI for each chain.
@@ -500,7 +500,7 @@Sampler diagnostic warnings a suffers from divergences.
-fit_with_warning <- cmdstanr_example("schools")Warning: 374 of 4000 (9.0%) transitions ended with a divergence. +Warning: 143 of 4000 (4.0%) transitions ended with a divergence. See https://mc-stan.org/misc/warnings for details.@@ -509,24 +509,24 @@Warning: 1 of 4 chains had an E-BFMI less than 0.3. See https://mc-stan.org/misc/warnings for details.Sampler diagnostic warnings a
fit$diagnostic_summary().-diagnostics <- fit_with_warning$diagnostic_summary()Warning: 374 of 4000 (9.0%) transitions ended with a divergence. +Warning: 143 of 4000 (4.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.3. See https://mc-stan.org/misc/warnings for details.print(diagnostics)+[1] 0.17 0.35 0.34 0.42$num_divergent -[1] 269 29 11 65 +[1] 1 37 75 30 $num_max_treedepth [1] 0 0 0 0 $ebfmi -[1] 0.15 0.34 0.38 0.37-# number of divergences reported in warning is the sum of the per chain values sum(diagnostics$num_divergent)+[1] 374[1] 143-Create a
-stanfitobject -If you have RStan installed then it is also possible to create a -
-stanfitobject from the csv output files written by -CmdStan. This can be done by usingrstan::read_stan_csv()-in combination with the$output_files()method of the -CmdStanMCMCobject. This is only needed if you want to fit -a model with CmdStanR but already have a lot of post-processing code -that assumes astanfitobject. Otherwise we recommend using -the post-processing functionality provided by CmdStanR itself.--stanfit <- rstan::read_stan_csv(fit$output_files())diff --git a/docs/reference/fit-method-constrain_variables.html b/docs/reference/fit-method-constrain_variables.html index ed77fc8a5..16dac657c 100644 --- a/docs/reference/fit-method-constrain_variables.html +++ b/docs/reference/fit-method-constrain_variables.html @@ -18,7 +18,7 @@Running optimization and variational inference @@ -565,7 +551,7 @@
Optimization
$optimize(). -@@ -149,8 +149,6 @@+fit_mle <- mod$optimize(data = data_list, seed = 123)Initial log joint probability = -16.144 Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes @@ -573,18 +559,18 @@Optimization
+fit_mle$print() # includes lp__ (log prob calculated by Stan program)-variable estimate lp__ -5.00 theta 0.20diff --git a/docs/reference/fit-method-cmdstan_summary.html b/docs/reference/fit-method-cmdstan_summary.html index 6bbc27276..32f0e4859 100644 --- a/docs/reference/fit-method-cmdstan_summary.html +++ b/docs/reference/fit-method-cmdstan_summary.html @@ -28,7 +28,7 @@+fit_mle$mle("theta")theta 0.2Here’s a plot comparing the penalized MLE to the posterior distribution of
-theta.@@ -166,10 +166,10 @@+@@ -595,7 +581,7 @@
OptimizationMaximum Likelihood Estimation section of the CmdStan User’s Guide for more details. -
@@ -120,6 +120,8 @@+@@ -187,18 +187,18 @@fit_map <- mod$optimize( data = data_list, jacobian = TRUE, @@ -606,7 +592,7 @@argument. IfOptimization
Laplace Approximation @@ -624,7 +610,7 @@
Laplace Approximationmode
modeis omitted then optimization will be run internally before taking draws from the normal approximation. -@@ -211,7 +211,7 @@+@@ -185,7 +185,7 @@-fit_laplace <- mod$laplace( mode = fit_map, draws = 4000, @@ -640,11 +626,11 @@Laplace Approximation
diff --git a/docs/reference/cmdstan_model-1.png b/docs/reference/cmdstan_model-1.png index aa185638c..35206a7af 100644 Binary files a/docs/reference/cmdstan_model-1.png and b/docs/reference/cmdstan_model-1.png differ diff --git a/docs/reference/cmdstan_model-2.png b/docs/reference/cmdstan_model-2.png index 4cf81fa80..b078570c6 100644 Binary files a/docs/reference/cmdstan_model-2.png and b/docs/reference/cmdstan_model-2.png differ diff --git a/docs/reference/cmdstan_model-3.png b/docs/reference/cmdstan_model-3.png index c67b37ed1..35367ed42 100644 Binary files a/docs/reference/cmdstan_model-3.png and b/docs/reference/cmdstan_model-3.png differ diff --git a/docs/reference/cmdstan_model.html b/docs/reference/cmdstan_model.html index feabb6046..f3966bc19 100644 --- a/docs/reference/cmdstan_model.html +++ b/docs/reference/cmdstan_model.html @@ -23,7 +23,7 @@+fit_laplace$print("theta")-variable mean median sd mad q5 q95 theta 0.27 0.25 0.12 0.12 0.10 0.51@@ -655,7 +641,7 @@+mcmc_hist(fit_laplace$draws("theta"), binwidth = 0.025)
Variational (ADVI)
$variational()method. For details on the ADVI algorithm see the CmdStan User’s Guide. -diff --git a/docs/reference/cmdstan_default_path.html b/docs/reference/cmdstan_default_path.html index 826c04c68..7f87720a5 100644 --- a/docs/reference/cmdstan_default_path.html +++ b/docs/reference/cmdstan_default_path.html @@ -18,7 +18,7 @@+diff --git a/docs/reference/cmdstan_default_install_path.html b/docs/reference/cmdstan_default_install_path.html index d8ecd6d6a..e4039b788 100644 --- a/docs/reference/cmdstan_default_install_path.html +++ b/docs/reference/cmdstan_default_install_path.html @@ -17,7 +17,7 @@fit_vb <- mod$variational( data = data_list, seed = 123, @@ -666,8 +652,8 @@Variational (ADVI)Variational (ADVI)
+fit_vb$print("theta")-variable mean median sd mad q5 q95 theta 0.26 0.24 0.11 0.11 0.11 0.46@@ -700,7 +686,7 @@+mcmc_hist(fit_vb$draws("theta"), binwidth = 0.025)
Variational (Pathfinder)CmdStan User’s Guide. Pathfinder is run using the
$pathfinder()method. -diff --git a/docs/reference/cmdstan_coercion.html b/docs/reference/cmdstan_coercion.html index f0de95037..c1af8993c 100644 --- a/docs/reference/cmdstan_coercion.html +++ b/docs/reference/cmdstan_coercion.html @@ -19,7 +19,7 @@+@@ -158,41 +158,41 @@-fit_pf <- mod$pathfinder( data = data_list, seed = 123, @@ -724,7 +710,7 @@Variational (Pathfinder)
diff --git a/docs/reference/as_draws.CmdStanMCMC.html b/docs/reference/as_draws.CmdStanMCMC.html index b04631b25..691170a8b 100644 --- a/docs/reference/as_draws.CmdStanMCMC.html +++ b/docs/reference/as_draws.CmdStanMCMC.html @@ -19,7 +19,7 @@+fit_pf$print("theta")@@ -732,22 +718,22 @@variable mean median sd mad q5 q95 theta 0.25 0.24 0.12 0.12 0.08 0.47Variational (Pathfinder) -
diff --git a/docs/reference/CmdStanVB.html b/docs/reference/CmdStanVB.html index 86708be79..b6e635111 100644 --- a/docs/reference/CmdStanVB.html +++ b/docs/reference/CmdStanVB.html @@ -19,7 +19,7 @@+mcmc_hist(fit_pf$draws("theta"), binwidth = 0.025) + ggplot2::labs(subtitle = "Approximate posterior from pathfinder") + ggplot2::xlim(0, 1)-
@@ -150,7 +150,7 @@+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)-
@@ -147,82 +147,80 @@+@@ -771,7 +757,7 @@mcmc_hist(fit$draws("theta"), binwidth = 0.025) + ggplot2::labs(subtitle = "Posterior from MCMC") + ggplot2::xlim(0, 1)Saving fitted model objects
+diff --git a/docs/articles/posterior.html b/docs/articles/posterior.html index a614e8890..a62f39624 100644 --- a/docs/articles/posterior.html +++ b/docs/articles/posterior.html @@ -40,7 +40,7 @@fit$save_object(file = "fit.RDS") # can be read back in using readRDS @@ -783,7 +769,7 @@Saving fitted model objects
$save_object()and replacesaveRDSwith the much fasterqsave()function from theqspackage. -++fit2 <- qs::qread("fit.qs")# 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. @@ -791,23 +777,23 @@Saving fitted model objectstry(fit$profiles(), silent = TRUE) # Load profiling samples. # Save the object to a file. -qs::qsave(x = fit, file = "fit.qs") +qs::qsave(x = fit, file = "fit.qs") # Read the object. -fit2 <- qs::qread("fit.qs")
Storage is even faster if you discard results you do not need to save. The following example saves only posterior draws and discards sampler diagnostics, user-specified initial values, and profiling data.
-++fit2 <- qs::qread("fit.qs")# Load posterior draws into the fitted model object and omit other output. fit$draws() # Save the object to a file. -qs::qsave(x = fit, file = "fit.qs") +qs::qsave(x = fit, file = "fit.qs") # Read the object. -fit2 <- qs::qread("fit.qs")See the vignette How does CmdStanR work? for more information about the composition of CmdStanR objects.
diff --git a/docs/articles/cmdstanr_files/figure-html/plot-compare-mcmc-1.png b/docs/articles/cmdstanr_files/figure-html/plot-compare-mcmc-1.png index 6b4765df4..6354bf17d 100644 Binary files a/docs/articles/cmdstanr_files/figure-html/plot-compare-mcmc-1.png and b/docs/articles/cmdstanr_files/figure-html/plot-compare-mcmc-1.png differ diff --git a/docs/articles/cmdstanr_files/figure-html/plot-mle-1.png b/docs/articles/cmdstanr_files/figure-html/plot-mle-1.png index 8a373b96b..978cbe60e 100644 Binary files a/docs/articles/cmdstanr_files/figure-html/plot-mle-1.png and b/docs/articles/cmdstanr_files/figure-html/plot-mle-1.png differ diff --git a/docs/articles/cmdstanr_files/figure-html/plots-1.png b/docs/articles/cmdstanr_files/figure-html/plots-1.png index 03122c055..eb6c5d384 100644 Binary files a/docs/articles/cmdstanr_files/figure-html/plots-1.png and b/docs/articles/cmdstanr_files/figure-html/plots-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index c7286099d..24e6ec31f 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -17,7 +17,7 @@Summary statistics
fit <- cmdstanr::cmdstanr_example("schools", method = "sample")Warning: 124 of 4000 (3.0%) transitions ended with a divergence. +-Warning: 145 of 4000 (4.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.3. -See https://mc-stan.org/misc/warnings for details.@@ -106,7 +111,12 @@+-fit$summary()variable mean median sd mad q5 q95 -1 lp__ -58.697829 -58.911800 5.056327 5.134318 -66.6875850 -49.89660 -2 mu 6.353763 6.597480 4.381424 4.372565 -1.2281605 13.23484 -3 tau 5.604807 4.871790 3.537844 3.371217 1.4006485 12.28454 -4 theta[1] 9.416434 8.789030 7.469694 6.297677 -1.7534945 22.77244 -5 theta[2] 6.708629 6.756395 5.775008 5.428570 -2.7675325 16.09375 -6 theta[3] 5.013658 5.633410 7.082039 6.055554 -7.5991140 15.69620 -7 theta[4] 6.479275 6.629210 6.113995 5.602212 -3.7474250 16.47548 -8 theta[5] 4.415845 4.751705 5.837104 5.557445 -5.7668200 13.46467 -9 theta[6] 5.316444 5.776025 6.132648 5.695771 -5.1632545 14.89951 -10 theta[7] 9.159755 8.682990 6.276413 5.676549 -0.3210604 20.38977 -11 theta[8] 7.114358 7.154305 6.994382 6.108230 -4.2959180 18.25591 ++1 1.029985 154.8234 166.9326 +2 1.004450 669.4002 1293.6704 +3 1.029747 147.4551 128.0359 +4 1.006213 1068.8761 2337.7828 +5 1.002627 1067.0310 2241.5417 +6 1.004902 1217.1050 1912.7529 +7 1.002033 1030.8586 1665.2932 +8 1.009740 637.5400 1725.4378 +9 1.003866 1129.6591 2064.6751 +10 1.003642 989.5674 1661.8675 +11 1.005570 1163.3998 1970.5629variable mean median sd mad q5 q95 +1 lp__ -58.189615 -58.233950 4.983507 5.199033 -66.09672000 -49.48569 +2 mu 6.770868 6.720615 4.160694 4.104430 0.05392642 13.50031 +3 tau 5.360230 4.524270 3.536662 3.128657 1.41195350 12.01772 +4 theta[1] 9.538150 8.703025 6.992732 6.139536 -0.46183645 21.76395 +5 theta[2] 7.037750 7.084940 5.672420 5.463211 -1.89471350 16.19477 +6 theta[3] 5.865357 5.940265 6.567071 5.598943 -4.94042600 15.87788 +7 theta[4] 7.096898 7.021110 5.846662 5.507303 -2.11556450 16.63653 +8 theta[5] 4.905340 5.104415 5.567945 5.102183 -4.69825650 13.42720 +9 theta[6] 5.743860 5.979900 5.965230 5.476702 -4.29255000 15.06765 +10 theta[7] 9.332145 8.785955 5.911919 5.517199 0.73314065 20.11738 +11 theta[8] 7.283320 7.100935 6.510593 5.937568 -3.18226350 18.23657 rhat ess_bulk ess_tail -1 1.018582 172.4200 135.9782 -2 1.008425 635.3354 1168.1366 -3 1.021625 165.4672 120.1282 -4 1.003830 1073.3788 1319.6507 -5 1.004990 1050.8445 1693.6799 -6 1.007712 871.0003 1537.3018 -7 1.003560 1027.3246 1869.0154 -8 1.007430 780.1467 1587.7245 -9 1.007162 917.8167 1453.6511 -10 1.003741 956.3136 1718.3496 -11 1.002369 1338.3238 1986.1357By default all variables are summaries with the follow functions:
-diff --git a/docs/reference/CmdStanMLE.html b/docs/reference/CmdStanMLE.html index 15e511707..025570d1e 100644 --- a/docs/reference/CmdStanMLE.html +++ b/docs/reference/CmdStanMLE.html @@ -1,6 +1,11 @@+posterior::default_summary_measures()[1] "mean" "median" "sd" "mad" "quantile2"To change the variables summarized, we use the variables argument
-diff --git a/docs/reference/CmdStanMCMC.html b/docs/reference/CmdStanMCMC.html index 9b2b7b9c0..a74ccf1d6 100644 --- a/docs/reference/CmdStanMCMC.html +++ b/docs/reference/CmdStanMCMC.html @@ -20,7 +20,7 @@+-fit$summary(variables = c("mu", "tau"))variable mean median sd mad q5 q95 rhat -1 mu 6.353763 6.59748 4.381424 4.372565 -1.228160 13.23484 1.008425 -2 tau 5.604807 4.87179 3.537844 3.371217 1.400649 12.28454 1.021625 ++1 669.4002 1293.6704 +2 147.4551 128.0359variable mean median sd mad q5 q95 rhat +1 mu 6.770868 6.720615 4.160694 4.104430 0.05392642 13.50031 1.004450 +2 tau 5.360230 4.524270 3.536662 3.128657 1.41195350 12.01772 1.029747 ess_bulk ess_tail -1 635.3354 1168.1366 -2 165.4672 120.1282We can additionally change which functions are used
-@@ -177,7 +177,7 @@+fit$summary(variables = c("mu", "tau"), mean, sd)+1 mu 6.770868 4.160694 +2 tau 5.360230 3.536662variable mean sd -1 mu 6.353763 4.381424 -2 tau 5.604807 3.537844To summarize all variables with non-default functions, it is necessary to set explicitly set the variables argument, either to
-NULLor 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]"@@ -102,6 +102,40 @@+fit$summary(variables = NULL, "mean", "median")+1 lp__ -58.189615 -58.233950 +2 mu 6.770868 6.720615 +3 tau 5.360230 4.524270 +4 theta[1] 9.538150 8.703025 +5 theta[2] 7.037750 7.084940 +6 theta[3] 5.865357 5.940265 +7 theta[4] 7.096898 7.021110 +8 theta[5] 4.905340 5.104415 +9 theta[6] 5.743860 5.979900 +10 theta[7] 9.332145 8.785955 +11 theta[8] 7.283320 7.100935variable mean median -1 lp__ -58.697829 -58.911800 -2 mu 6.353763 6.597480 -3 tau 5.604807 4.871790 -4 theta[1] 9.416434 8.789030 -5 theta[2] 6.708629 6.756395 -6 theta[3] 5.013658 5.633410 -7 theta[4] 6.479275 6.629210 -8 theta[5] 4.415845 4.751705 -9 theta[6] 5.316444 5.776025 -10 theta[7] 9.159755 8.682990 -11 theta[8] 7.114358 7.154305Summary 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.diff --git a/docs/news/index.html b/docs/news/index.html index b66cb1ab7..6fd3e6cd7 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -17,7 +17,7 @@+-my_sd <- function(x) c(My_SD = sd(x)) fit$summary( c("mu", "tau"), @@ -232,45 +230,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.353763 6.59748 4.381424 0.756247 11.71914 -9.340540 -2 tau 5.604807 4.87179 3.537844 1.723530 10.46083 0.749924variable MEAN median My_SD 10% 90% Minimum +1 mu 6.770868 6.720615 4.160694 1.577812 12.27689 -7.905940 +2 tau 5.360230 4.524270 3.536662 1.751609 10.20606 0.836362Arguments to all summary functions can also be specified with
-.args.+ -+variable 2.5% 5% 95% 97.5% -1 mu -2.926103 -1.228160 13.23484 14.96275 -2 tau 1.106000 1.400649 12.28454 14.09220variable 2.5% 5% 95% 97.5% +1 mu -1.320617 0.05392642 13.50031 14.99084 +2 tau 1.176680 1.41195350 12.01772 13.99329The summary functions are applied to the array of sample values, with dimension
-iter_samplingxchains.+fit$summary(variables = NULL, dim, colMeans)+1 lp__ 1000 4 -59.512825 -57.501953 -58.519416 -57.224267 +2 mu 1000 4 6.687580 7.323996 6.485391 6.586506 +3 tau 1000 4 6.113202 4.991316 5.617574 4.718827 +4 theta[1] 1000 4 9.845526 10.063756 9.480842 8.762475 +5 theta[2] 1000 4 7.109487 7.340212 6.950864 6.750437 +6 theta[3] 1000 4 5.614556 6.465821 5.368069 6.012981 +7 theta[4] 1000 4 7.095362 7.575608 6.862193 6.854430 +8 theta[5] 1000 4 4.335314 5.915169 4.347114 5.023764 +9 theta[6] 1000 4 5.495814 6.275650 5.270746 5.933231 +10 theta[7] 1000 4 9.739179 9.685921 9.144607 8.758873 +11 theta[8] 1000 4 7.154340 7.740947 7.134879 7.103115variable dim.1 dim.2 1 2 3 4 -1 lp__ 1000 4 -57.746884 -58.396713 -59.488281 -59.159440 -2 mu 1000 4 6.886773 6.098293 6.275602 6.154385 -3 tau 1000 4 4.969696 5.504146 6.035791 5.909594 -4 theta[1] 1000 4 9.584919 8.855289 9.788069 9.437459 -5 theta[2] 1000 4 7.218764 6.441512 6.701321 6.472920 -6 theta[3] 1000 4 6.039431 4.880572 4.532884 4.601744 -7 theta[4] 1000 4 6.923818 6.048362 6.708068 6.236851 -8 theta[5] 1000 4 5.339809 4.243510 3.959413 4.120650 -9 theta[6] 1000 4 5.971513 4.851822 5.284337 5.158102 -10 theta[7] 1000 4 9.310560 8.904282 9.350879 9.073298 -11 theta[8] 1000 4 7.380020 7.069916 7.245772 6.761726For this reason users may have unexpected results if they use
-stats::var()directly, as it will return a covariance matrix. An alternative is thedistributional::variance()function, which can also be accessed viaposterior::variance().++1 mu 17.31137 17.31137 +2 tau 12.50798 12.50798variable posterior::variance ~var(as.vector(.x)) -1 mu 19.19687 19.19687 -2 tau 12.51634 12.51634Summary 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 @@ -285,7 +283,7 @@andSummary statistics
+# fit$print(variables = NULL, "Strictly Positive" = strict_pos)For more information, see
@@ -299,49 +297,49 @@posterior::summarise_draws(), which is called by$summary().Extracting posterior draws/samplesdraws_array
draws_dfformats, but the posterior package supports other useful formats as well. -@@ -324,7 +324,7 @@+-# 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] -66.1 -61.6 -58.3 -57.5 -55.3 ... +-'draws_array' num [1:1000, 1:4, 1:11] -60.3 -61 -59.5 -58.6 -64.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: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] -66.1 -61.6 -58.3 -57.5 -55.3 ... - $ mu : num [1:4000] 1.93 8.57 4.05 9.53 9.94 ... - $ tau : num [1:4000] 10.73 6.28 6.1 4.65 3.2 ... - $ theta[1] : num [1:4000] 9.1 21.74 11.18 13.36 9.68 ... - $ theta[2] : num [1:4000] 11.006 5.842 -0.815 17.943 11.148 ... - $ theta[3] : num [1:4000] 0.4 12.17 7.94 6.17 3.94 ... - $ theta[4] : num [1:4000] -3.74 14.86 6.59 9.74 7.95 ... - $ theta[5] : num [1:4000] 12.97 5.5 1.32 8.77 12.83 ... - $ theta[6] : num [1:4000] -11.04 1.81 6.18 6.33 6.56 ... - $ theta[7] : num [1:4000] 22.21 10.53 7.75 14.3 11.54 ... - $ theta[8] : num [1:4000] 14.77 -2.98 11.19 7.25 10.37 ... + $ lp__ : num [1:4000] -60.3 -61 -59.5 -58.6 -64.2 ... + $ mu : num [1:4000] 13.44 3.8 5.99 5.51 10.76 ... + $ tau : num [1:4000] 5.55 7.85 6.33 5.48 8.88 ... + $ theta[1] : num [1:4000] 18.07 3.52 12.12 4.46 13.9 ... + $ theta[2] : num [1:4000] 16.476 -0.445 4.075 3.544 4.102 ... + $ theta[3] : num [1:4000] 11.7279 5.8634 -0.0525 -0.6551 3.4664 ... + $ theta[4] : num [1:4000] 14.84 3.94 -1.12 6.6 -2.9 ... + $ theta[5] : num [1:4000] 12.108 0.652 -2.931 7.275 -6.486 ... + $ theta[6] : num [1:4000] 7.16 9.55 9.69 3.59 6.77 ... + $ theta[7] : num [1:4000] 11.31 11.43 4.64 11.3 5.55 ... + $ theta[8] : num [1:4000] 24.13 -7.81 9.13 -3.8 20.05 ... $ .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 -66 1.9 10.7 9.1 11.01 0.4 -3.7 13.0 -2 -62 8.6 6.3 21.7 5.84 12.2 14.9 5.5 -3 -58 4.1 6.1 11.2 -0.82 7.9 6.6 1.3 -4 -58 9.5 4.6 13.4 17.94 6.2 9.7 8.8 -5 -55 9.9 3.2 9.7 11.15 3.9 7.9 12.8 -6 -55 9.9 4.0 8.5 8.81 6.6 9.8 12.0 -7 -54 9.7 2.7 14.5 10.87 5.8 6.8 10.2 -8 -52 8.7 2.2 10.5 10.42 9.4 9.8 9.4 -9 -57 10.1 5.0 13.4 10.29 11.4 5.8 12.0 -10 -58 10.5 5.5 14.8 9.45 13.9 5.6 12.0 +1 -60 13.4 5.6 18.1 16.48 11.728 14.8 12.11 +2 -61 3.8 7.9 3.5 -0.45 5.863 3.9 0.65 +3 -59 6.0 6.3 12.1 4.08 -0.053 -1.1 -2.93 +4 -59 5.5 5.5 4.5 3.54 -0.655 6.6 7.28 +5 -64 10.8 8.9 13.9 4.10 3.466 -2.9 -6.49 +6 -61 6.6 11.3 19.3 10.54 6.469 5.6 -3.64 +7 -49 7.2 2.1 5.6 6.76 6.771 7.5 7.51 +8 -53 6.8 1.5 6.1 6.97 7.150 3.8 8.49 +9 -53 6.8 1.5 6.1 6.97 7.150 3.8 8.49 +10 -56 6.5 3.8 4.8 3.31 9.891 8.5 4.73 # ... 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 @@ -364,7 +362,7 @@
Structured draws similar to
x. To instead directly access the draws of xwhile maintaining the structure of the matrix useposterior::draws_of(). For example: -@@ -250,11 +250,11 @@+diff --git a/docs/articles/profiling.html b/docs/articles/profiling.html index 2336b31c3..dd98c4330 100644 --- a/docs/articles/profiling.html +++ b/docs/articles/profiling.html @@ -40,7 +40,7 @@draws <- posterior::as_draws_rvars(fit$draws()) x_rvar <- draws$x x_array <- posterior::draws_of(draws$x)Accessing the profiling info
fit$profiles()+1 34865424 17424 1 +2 34848 17424 1[[1]] name thread_id total_time forward_time reverse_time chain_stack -1 priors 0x7ff858f85100 0.00636262 0.0041022 0.00226042 34634 -2 likelihood 0x7ff858f85100 0.92346400 0.7530890 0.17037500 51951 +1 likelihood 0x7ff85af4eb00 0.60053000 0.49063200 0.10989800 52272 +2 priors 0x7ff85af4eb00 0.00611123 0.00426232 0.00184891 34848 no_chain_stack autodiff_calls no_autodiff_calls -1 34634 17317 1 -2 34651317 17317 1The
@@ -297,11 +297,11 @@total_timecolumn 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.Comparing to a faster versio
fit_glm$profiles()+1 17243 17243 1 +2 34486 17243 1[[1]] name thread_id total_time forward_time reverse_time chain_stack -1 priors 0x7ff858f85100 0.00547866 0.00378008 0.00169859 34894 -2 likelihood 0x7ff858f85100 0.55301400 0.55111300 0.00190093 52341 +1 likelihood 0x7ff85af4eb00 0.30010000 0.29864700 0.00145329 51729 +2 priors 0x7ff85af4eb00 0.00520466 0.00393537 0.00126928 34486 no_chain_stack autodiff_calls no_autodiff_calls -1 34894 17447 1 -2 17447 17447 1We can see from the
total_timecolumn that this is much faster than the previous model.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] 3.674205e-07 5.332702e-05[1] 3.446568e-05 3.507363e-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/RtmpEbNhyd/model_6580008f67848265f3dfd0e7ae3b0600-profile-202407021547-1-96d3d3.csv"[1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp2a6FE1/model_6580008f67848265f3dfd0e7ae3b0600-profile-202503310851-1-810271.csv"These can be saved to a more permanent location with the
$save_profile_files()method.@@ -229,14 +229,13 @@diff --git a/docs/articles/r-markdown.html b/docs/articles/r-markdown.html index 2f9ac3f1a..a6d479bac 100644 --- a/docs/articles/r-markdown.html +++ b/docs/articles/r-markdown.html @@ -40,7 +40,7 @@Example #> #> All 4 chains finished successfully. #> Mean chain execution time: 0.0 seconds. -#> Total execution time: 0.7 seconds.
+#> lp__ -1.49 -1.15 1.25 0.98 -4.04 -0.17 1.00 1284 1327 +#> y[1] -0.03 -0.02 1.01 1.02 -1.68 1.62 1.00 2086 1813 +#> y[2] -0.01 -0.05 2.78 1.99 -4.55 4.62 1.00 2015 1281-+#> Total execution time: 0.7 seconds. + print(fit) #> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail -#> lp__ -1.55 -1.24 1.24 1.04 -4.07 -0.18 1.00 1509 1671 -#> y[1] -0.03 -0.03 1.01 0.99 -1.69 1.68 1.00 1852 2195 -#> y[2] -0.13 -0.07 2.92 2.14 -4.92 4.65 1.00 1855 1666-Option 3: Using both RStan and CmdStanR in the same R Markdown @@ -248,26 +247,26 @@
project, the option to use both exists. When registering CmdStanR’s knitr engine, set
override = FALSEto register the engine as acmdstanengine: -+register_knitr_engine(override = FALSE)This will cause
- +stanchunks to be processed by knitr’s built-in, RStan-based engine and only use CmdStanR’s knitr engine forcmdstanchunks:@@ -160,15 +160,15 @@Caching chunks diff --git a/docs/authors.html b/docs/authors.html index fb693ea93..3c863bf25 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -17,7 +17,7 @@
Citation
Gabry J, Češnovar R, Johnson A, Bronder S (2024). +
Gabry J, Češnovar R, Johnson A, Bronder S (2025). cmdstanr: R Interface to 'CmdStan'. -R package version 0.8.1, https://discourse.mc-stan.org, https://mc-stan.org/cmdstanr/. +R package version 0.9.0, https://discourse.mc-stan.org, https://mc-stan.org/cmdstanr/.
@Manual{, title = {cmdstanr: R Interface to 'CmdStan'}, author = {Jonah Gabry and Rok Češnovar and Andrew Johnson and Steve Bronder}, - year = {2024}, - note = {R package version 0.8.1, https://discourse.mc-stan.org}, + year = {2025}, + note = {R package version 0.9.0, https://discourse.mc-stan.org}, url = {https://mc-stan.org/cmdstanr/}, }diff --git a/docs/index.html b/docs/index.html index de070a6d2..2f0377a4d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -40,7 +40,7 @@Changelog
Source:NEWS.md+cmdstanr 0.9.0
+++General Improvements/Changes
+
- Added compatibility for RTools45 (#1066)
+- cmdstanr will now use RTools with no additional toolchain updates needed on Windows (CmdStan 2.35+ only; #1065, #1054)
+- Improve error messages when calling
+sampler_diagnostics()withfixed_param=TRUE+- Improve numerical stability in calculation of effective sample size during
+loomethod (#1057)- Improve numerical stablity with very small log-ratios in calculation of effective sample size during
+loomethod (#1015)- Add warning if input data/inits have been coerced to ints (#994)
+++Bugfixes
+
- Don’t require fixed_param for models with zero parameters (only GQs) for CmdStan >= 2.36 (#1046)
+- Improve detection/handling of
+make(#1036)- Fix saving of model objects to network drive (#1038, thanks to @bschneidr)
+- Update usage of
+untarto fix installation errors (#1034)- Respect compilation flags in
+make/localwhen exposing functions or model methods (#1003)- Fix passing of include paths to CmdStan (#1000)
+- Fix passing of factor data to CmdStan (#999)
+- Fix extraction and passing of array data/parameters as model inits (#993)
+++Documentation Updates
+
- Clarifications to usage of
+optimizeandloomethods (#1060)- Add documentation for faster model saving with large models (#1042)
+- Remove mentions of
+rstan::read_stan_csvdue to incompatibility with newer CmdStan outputs (#1018)- Document global option
+cmdstanr_print_line_numbersfor printing line numbers (#1017)- Change usage of ‘chapter’ to ‘section’ in documentation (#1014)
+- Remove examples of updating removed array syntax as functionality no longer supported in CmdStan (#1008)
+- Change usages of ‘sampling statement’ -> ‘distribution statement’ (#987)
+diff --git a/docs/reference/CmdStanGQ.html b/docs/reference/CmdStanGQ.html index 6c879fc14..4eb00470b 100644 --- a/docs/reference/CmdStanGQ.html +++ b/docs/reference/CmdStanGQ.html @@ -19,7 +19,7 @@cmdstanr 0.8.1
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 427640f5e..2d0ef80ca 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,4 +1,4 @@ -pandoc: 3.1.11 +pandoc: '3.2' pkgdown: 2.0.9 pkgdown_sha: ~ articles: @@ -8,7 +8,7 @@ articles: posterior: posterior.html profiling: profiling.html r-markdown: r-markdown.html -last_built: 2024-07-02T21:30Z +last_built: 2025-03-31T14:41Z 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 8a2a8930b..2efca167b 100644 --- a/docs/reference/CmdStanDiagnose.html +++ b/docs/reference/CmdStanDiagnose.html @@ -18,7 +18,7 @@@@ -137,11 +137,11 @@Examples
# retrieve the gradients test$gradients() -#> param_idx value model finite_diff error -#> 1 0 -0.656568 21.488200 21.488200 -3.43539e-08 -#> 2 1 0.536526 -22.101600 -22.101600 -6.85812e-10 -#> 3 2 1.603540 -33.634400 -33.634400 1.93245e-08 -#> 4 3 0.609685 0.311848 0.311848 -1.15926e-08 +#> param_idx value model finite_diff error +#> 1 0 1.025820 -9.58652 -9.58652 1.06300e-08 +#> 2 1 -1.330520 7.42547 7.42547 3.40819e-08 +#> 3 2 -1.187440 13.23460 13.23460 7.67016e-09 +#> 4 3 0.699258 3.50023 3.50023 6.99257e-09 # }Examples
#> #> All 4 chains finished successfully. #> Mean chain execution time: 0.0 seconds. -#> Total execution time: 0.9 seconds. +#> Total execution time: 0.7 seconds. #> # stan program for standalone generated quantities @@ -206,7 +206,7 @@Examples
#> #> All 4 chains finished successfully. #> Mean chain execution time: 0.0 seconds. -#> Total execution time: 0.6 seconds. +#> Total execution time: 0.5 seconds. str(fit_gq$draws()) #> 'draws_array' int [1:1000, 1:4, 1:10] 0 0 0 1 1 0 1 1 0 1 ... #> - attr(*, "dimnames")=List of 3 @@ -215,7 +215,7 @@Examples
#> ..$ variable : chr [1:10] "y_rep[1]" "y_rep[2]" "y_rep[3]" "y_rep[4]" ... library(posterior) -#> This is posterior version 1.6.0 +#> This is posterior version 1.6.1 #> #> Attaching package: ‘posterior’ #> The following objects are masked from ‘package:stats’: diff --git a/docs/reference/CmdStanLaplace.html b/docs/reference/CmdStanLaplace.html index 7115dbb92..613716534 100644 --- a/docs/reference/CmdStanLaplace.html +++ b/docs/reference/CmdStanLaplace.html @@ -19,7 +19,7 @@CmdStanMLE objects — CmdStanMLE • cmdstanr @@ -18,7 +23,7 @@CmdStanMLE objects
diff --git a/docs/reference/CmdStanModel-1.png b/docs/reference/CmdStanModel-1.png index aa185638c..35206a7af 100644 Binary files a/docs/reference/CmdStanModel-1.png and b/docs/reference/CmdStanModel-1.png differ diff --git a/docs/reference/CmdStanModel-2.png b/docs/reference/CmdStanModel-2.png index 4cf81fa80..b078570c6 100644 Binary files a/docs/reference/CmdStanModel-2.png and b/docs/reference/CmdStanModel-2.png differ diff --git a/docs/reference/CmdStanModel-3.png b/docs/reference/CmdStanModel-3.png index c67b37ed1..35367ed42 100644 Binary files a/docs/reference/CmdStanModel-3.png and b/docs/reference/CmdStanModel-3.png differ diff --git a/docs/reference/CmdStanModel.html b/docs/reference/CmdStanModel.html index ed53020c7..9b9494188 100644 --- a/docs/reference/CmdStanModel.html +++ b/docs/reference/CmdStanModel.html @@ -20,7 +20,7 @@A
+CmdStanMLEobject is the fitted model object returned by the -$optimize()method of aCmdStanModelobject.$optimize()method of aCmdStanModelobject. +This object will either contain a penalized maximum likelihood estimate +(MLE) or a maximum a posteriori estimate (MAP), depending on the value of +thejacobianargument when the model is fit (and whether the model has +constrained parameters). See$optimize()and the +CmdStan User's Guide for more details.Examples
library(cmdstanr) library(posterior) library(bayesplot) -#> This is bayesplot version 1.11.1 +#> This is bayesplot version 1.11.1.9000 #> - Online documentation and vignettes at mc-stan.org/bayesplot #> - bayesplot theme set to bayesplot::theme_default() #> * Does _not_ affect other ggplot2 plots @@ -168,7 +168,7 @@Examples
# Otherwise use the `path` argument to specify the location of your # CmdStan installation.) set_cmdstan_path(path = NULL) -#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.35.0 +#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.36.0 # Create a CmdStanModel object from a Stan program, # here using the example model that comes with CmdStan @@ -270,8 +270,8 @@Examples
#> # A tibble: 2 × 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__ -7.30 -7.00 0.811 0.344 -8.83 -6.75 1.00 702. 776. -#> 2 theta 0.254 0.238 0.125 0.124 0.0807 0.483 1.00 634. 580. +#> 1 lp__ -7.35 -7.01 0.882 0.353 -9.14 -6.75 1.00 724. 896. +#> 2 theta 0.254 0.239 0.129 0.126 0.0737 0.488 1.00 532. 657. # Check sampling diagnostics fit_mcmc$diagnostic_summary() @@ -282,7 +282,7 @@Examples
#> [1] 0 0 #> #> $ebfmi -#> [1] 1.1148699 0.8012192 +#> [1] 1.1148479 0.7568734 #> # Get posterior draws @@ -292,22 +292,22 @@Examples
#> , , variable = lp__ #> #> chain -#> iteration 1 2 -#> 1 -7.0 -6.8 -#> 2 -7.9 -6.9 -#> 3 -7.4 -6.8 -#> 4 -6.7 -6.8 -#> 5 -6.9 -10.2 +#> iteration 1 2 +#> 1 -7.0 -8.1 +#> 2 -7.9 -7.9 +#> 3 -7.4 -7.0 +#> 4 -6.7 -6.8 +#> 5 -6.9 -6.8 #> #> , , variable = theta #> #> chain -#> iteration 1 2 -#> 1 0.17 0.23 -#> 2 0.46 0.18 -#> 3 0.41 0.28 -#> 4 0.25 0.23 -#> 5 0.18 0.62 +#> iteration 1 2 +#> 1 0.17 0.088 +#> 2 0.46 0.097 +#> 3 0.41 0.167 +#> 4 0.25 0.292 +#> 5 0.18 0.238 #> #> # ... with 995 more iterations @@ -333,11 +333,6 @@Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.-# For models fit using MCMC, if you like working with RStan's stanfit objects -# then you can create one with rstan::read_stan_csv() -# stanfit <- rstan::read_stan_csv(fit_mcmc$output_files()) - - # Run 'optimize' method to get a point estimate (default is Stan's LBFGS algorithm) # and also demonstrate specifying data as a path to a file instead of a list my_data_file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.data.json") @@ -358,9 +353,9 @@
Examples
# 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 = -17.5579 +#> Initial log joint probability = -6.93289 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 5 -6.74802 0.00114604 2.88021e-05 1 1 8 +#> 4 -6.74802 0.00149466 1.90231e-05 1 1 7 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance #> Finished in 0.1 seconds. @@ -393,9 +388,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.96 0.761 0.290 -8.64 -6.75 -#> 2 lp_approx__ -0.505 -0.216 0.751 0.296 -1.96 -0.00191 -#> 3 theta 0.269 0.248 0.124 0.119 0.102 0.505 +#> 1 lp__ -7.24 -6.96 0.738 0.292 -8.68 -6.75 +#> 2 lp_approx__ -0.494 -0.213 0.716 0.294 -2.00 -0.00155 +#> 3 theta 0.268 0.245 0.124 0.116 0.104 0.509 # Run 'variational' method to use ADVI to approximate posterior fit_vb <- mod$variational(data = stan_data, seed = 123) @@ -404,8 +399,8 @@Examples
#> This procedure has not been thoroughly tested and may be unstable #> or buggy. The interface is subject to change. #> ------------------------------------------------------------ -#> Gradient evaluation took 1.6e-05 seconds -#> 1000 transitions using 10 leapfrog steps per transition would take 0.16 seconds. +#> Gradient evaluation took 1.1e-05 seconds +#> 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds. #> Adjust your expectations accordingly! #> Begin eta adaptation. #> Iteration: 1 / 250 [ 0%] (Adaptation) @@ -469,48 +464,47 @@Examples
fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40, history_size=50, max_lbfgs_iters=100) #> Warning: Number of PSIS draws is larger than the total number of draws returned by the single Pathfinders. This is likely unintentional and leads to re-sampling from the same draws. -#> Path [1] :Initial log joint density = -7.658980 +#> Path [1] :Initial log joint density = -7.264402 #> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.493e-04 7.219e-07 1.000e+00 1.000e+00 126 -6.255e+00 -6.255e+00 -#> Path [1] :Best Iter: [3] ELBO (-6.118635) evaluations: (126) -#> Path [2] :Initial log joint density = -15.590813 +#> 5 -6.748e+00 3.293e-04 4.141e-07 1.000e+00 1.000e+00 126 -6.296e+00 -6.296e+00 +#> Path [1] :Best Iter: [4] ELBO (-6.235406) evaluations: (126) +#> Path [2] :Initial log joint density = -11.117345 #> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.968e-03 5.939e-05 1.000e+00 1.000e+00 126 -6.158e+00 -6.158e+00 -#> Path [2] :Best Iter: [5] ELBO (-6.157859) evaluations: (126) -#> Path [3] :Initial log joint density = -6.799846 +#> 5 -6.748e+00 9.672e-04 1.459e-05 1.000e+00 1.000e+00 126 -6.259e+00 -6.259e+00 +#> Path [2] :Best Iter: [2] ELBO (-6.180823) evaluations: (126) +#> Path [3] :Initial log joint density = -7.495731 #> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 2.833e-04 1.189e-06 1.000e+00 1.000e+00 101 -6.196e+00 -6.196e+00 -#> Path [3] :Best Iter: [4] ELBO (-6.196377) evaluations: (101) -#> Path [4] :Initial log joint density = -7.264152 +#> 5 -6.748e+00 1.114e-04 4.492e-07 1.000e+00 1.000e+00 126 -6.259e+00 -6.259e+00 +#> Path [3] :Best Iter: [2] ELBO (-6.245533) evaluations: (126) +#> Path [4] :Initial log joint density = -7.770449 #> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 4.881e-03 1.363e-04 1.000e+00 1.000e+00 101 -6.246e+00 -6.246e+00 -#> Path [4] :Best Iter: [4] ELBO (-6.246482) evaluations: (101) -#> Path [5] :Initial log joint density = -6.872687 +#> 5 -6.748e+00 1.750e-04 9.341e-07 1.000e+00 1.000e+00 126 -6.225e+00 -6.225e+00 +#> Path [4] :Best Iter: [5] ELBO (-6.225361) evaluations: (126) +#> Path [5] :Initial log joint density = -14.218076 #> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 9.087e-04 8.299e-06 1.000e+00 1.000e+00 101 -6.154e+00 -6.154e+00 -#> Path [5] :Best Iter: [4] ELBO (-6.153998) evaluations: (101) -#> Path [6] :Initial log joint density = -6.752169 +#> 5 -6.748e+00 1.997e-03 5.573e-05 1.000e+00 1.000e+00 126 -6.216e+00 -6.216e+00 +#> Path [5] :Best Iter: [5] ELBO (-6.216169) evaluations: (126) +#> Path [6] :Initial log joint density = -7.472192 #> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 3 -6.748e+00 6.431e-04 9.017e-06 9.943e-01 9.943e-01 76 -6.254e+00 -6.254e+00 -#> Path [6] :Best Iter: [2] ELBO (-6.219041) evaluations: (76) -#> Path [7] :Initial log joint density = -6.964028 +#> 5 -6.748e+00 1.059e-04 4.145e-07 1.000e+00 1.000e+00 126 -6.137e+00 -6.137e+00 +#> Path [6] :Best Iter: [5] ELBO (-6.137426) evaluations: (126) +#> Path [7] :Initial log joint density = -8.723559 #> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 3.720e-04 7.938e-05 9.165e-01 9.165e-01 101 -6.157e+00 -6.157e+00 -#> Path [7] :Best Iter: [2] ELBO (-6.124107) evaluations: (101) -#> Path [8] :Initial log joint density = -7.712025 +#> 5 -6.748e+00 3.317e-04 2.693e-06 1.000e+00 1.000e+00 126 -6.210e+00 -6.210e+00 +#> Path [7] :Best Iter: [3] ELBO (-6.175877) evaluations: (126) +#> Path [8] :Initial log joint density = -9.460464 #> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.616e-04 8.207e-07 1.000e+00 1.000e+00 126 -6.193e+00 -6.193e+00 -#> Path [8] :Best Iter: [2] ELBO (-6.154633) evaluations: (126) -#> Path [9] :Initial log joint density = -8.980186 +#> 5 -6.748e+00 4.598e-04 4.575e-06 1.000e+00 1.000e+00 126 -6.241e+00 -6.241e+00 +#> Path [8] :Best Iter: [2] ELBO (-6.228285) evaluations: (126) +#> Path [9] :Initial log joint density = -18.781825 #> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 3.446e-04 2.899e-06 1.000e+00 1.000e+00 126 -6.172e+00 -6.172e+00 -#> Path [9] :Best Iter: [5] ELBO (-6.172384) evaluations: (126) -#> Path [10] :Initial log joint density = -6.762839 +#> 5 -6.748e+00 4.081e-04 6.355e-06 1.000e+00 1.000e+00 126 -6.256e+00 -6.256e+00 +#> Path [9] :Best Iter: [2] ELBO (-6.178423) evaluations: (126) +#> Path [10] :Initial log joint density = -7.492978 #> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 3 -6.748e+00 1.503e-03 8.368e-06 9.796e-01 9.796e-01 76 -6.234e+00 -6.234e+00 -#> Path [10] :Best Iter: [2] ELBO (-6.202358) evaluations: (76) -#> Total log probability function evaluations:1210 -#> Pareto k value (0.74) is greater than 0.7. Importance resampling was not able to improve the approximation, which may indicate that the approximation itself is poor. +#> 5 -6.748e+00 8.830e-04 2.382e-06 1.000e+00 1.000e+00 126 -6.191e+00 -6.191e+00 +#> Path [10] :Best Iter: [5] ELBO (-6.191391) evaluations: (126) +#> Total log probability function evaluations:1410 #> Finished in 0.1 seconds. # Specifying initial values as a function diff --git a/docs/reference/CmdStanPathfinder.html b/docs/reference/CmdStanPathfinder.html index 1b511142b..b25331a05 100644 --- a/docs/reference/CmdStanPathfinder.html +++ b/docs/reference/CmdStanPathfinder.html @@ -19,7 +19,7 @@Examples
#> #> chain #> iteration 1 2 3 4 -#> 1 -65 -67 -65 -66 -#> 2 -66 -65 -65 -67 -#> 3 -65 -65 -65 -65 -#> 4 -65 -66 -65 -65 -#> 5 -66 -69 -71 -66 +#> 1 -66 -65 -65 -64 +#> 2 -67 -67 -65 -68 +#> 3 -66 -65 -65 -66 +#> 4 -65 -66 -64 -66 +#> 5 -64 -67 -65 -66 #> #> , , variable = alpha #> #> chain #> iteration 1 2 3 4 -#> 1 0.448 0.19 0.36 0.34 -#> 2 0.343 0.57 0.28 0.53 -#> 3 0.441 0.54 0.56 0.45 -#> 4 0.095 0.75 0.19 0.57 -#> 5 0.089 0.81 0.57 0.20 +#> 1 0.792 0.30 0.38 0.38 +#> 2 0.061 0.54 0.49 0.14 +#> 3 0.538 0.23 0.47 0.29 +#> 4 0.446 0.10 0.37 0.41 +#> 5 0.253 0.68 0.46 0.56 #> #> , , variable = beta[1] #> #> chain #> iteration 1 2 3 4 -#> 1 -0.40 -0.13 -0.86 -0.87 -#> 2 -0.60 -0.75 -0.39 -0.66 -#> 3 -0.46 -1.00 -0.90 -0.61 -#> 4 -0.74 -0.72 -0.90 -0.87 -#> 5 -0.45 -0.80 -0.71 -0.99 +#> 1 -0.93 -0.46 -0.99 -0.75 +#> 2 -0.60 -0.87 -0.93 -0.84 +#> 3 -0.67 -0.51 -0.45 -0.41 +#> 4 -0.90 -0.78 -0.75 -0.19 +#> 5 -0.63 -0.57 -0.45 -0.62 #> #> , , variable = beta[2] #> #> chain -#> iteration 1 2 3 4 -#> 1 -0.29 -0.25 -0.041 -0.62 -#> 2 -0.70 -0.35 -0.376 0.26 -#> 3 -0.12 -0.21 -0.190 -0.23 -#> 4 -0.48 -0.34 -0.117 -0.20 -#> 5 -0.44 -0.10 0.289 -0.28 +#> iteration 1 2 3 4 +#> 1 -0.26 0.031 -0.15 -0.195 +#> 2 0.12 -0.226 -0.36 -0.386 +#> 3 -0.02 -0.199 -0.15 -0.548 +#> 4 -0.31 -0.013 -0.20 -0.084 +#> 5 -0.12 -0.615 -0.09 -0.610 #> #> # ... with 995 more iterations, and 101 more variables @@ -203,67 +203,68 @@Examples
#> [1] -66 ± 1.5 #> #> $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.25 -0.28 ± 0.23 0.69 ± 0.27 #> #> $log_lik: rvar<1000,4>[100] mean ± sd: -#> [1] -0.517 ± 0.101 -0.399 ± 0.145 -0.501 ± 0.225 -0.446 ± 0.153 -#> [5] -1.185 ± 0.288 -0.589 ± 0.186 -0.639 ± 0.122 -0.277 ± 0.138 -#> [9] -0.692 ± 0.164 -0.743 ± 0.239 -0.278 ± 0.126 -0.492 ± 0.239 -#> [13] -0.656 ± 0.204 -0.362 ± 0.176 -0.278 ± 0.108 -0.274 ± 0.089 -#> [17] -1.598 ± 0.297 -0.478 ± 0.109 -0.232 ± 0.077 -0.113 ± 0.080 -#> [21] -0.211 ± 0.089 -0.567 ± 0.147 -0.329 ± 0.142 -0.136 ± 0.067 -#> [25] -0.452 ± 0.119 -1.523 ± 0.345 -0.305 ± 0.123 -0.445 ± 0.085 -#> [29] -0.723 ± 0.230 -0.694 ± 0.192 -0.485 ± 0.161 -0.423 ± 0.108 -#> [33] -0.407 ± 0.124 -0.063 ± 0.050 -0.584 ± 0.183 -0.324 ± 0.134 -#> [37] -0.702 ± 0.231 -0.309 ± 0.148 -0.179 ± 0.111 -0.681 ± 0.127 -#> [41] -1.135 ± 0.256 -0.932 ± 0.194 -0.410 ± 0.262 -1.177 ± 0.192 -#> [45] -0.359 ± 0.120 -0.580 ± 0.127 -0.301 ± 0.127 -0.324 ± 0.084 -#> [49] -0.318 ± 0.082 -1.290 ± 0.332 -0.287 ± 0.095 -0.833 ± 0.145 -#> [53] -0.400 ± 0.130 -0.372 ± 0.143 -0.382 ± 0.133 -0.319 ± 0.194 -#> [57] -0.658 ± 0.119 -0.953 ± 0.354 -1.365 ± 0.337 -0.978 ± 0.163 -#> [61] -0.541 ± 0.099 -0.872 ± 0.313 -0.116 ± 0.075 -0.903 ± 0.248 -#> [65] -2.029 ± 0.603 -0.508 ± 0.136 -0.276 ± 0.083 -1.064 ± 0.237 -#> [69] -0.435 ± 0.086 -0.639 ± 0.237 -0.609 ± 0.205 -0.461 ± 0.167 -#> [73] -1.492 ± 0.362 -0.948 ± 0.200 -1.139 ± 0.388 -0.374 ± 0.142 -#> [77] -0.878 ± 0.139 -0.489 ± 0.172 -0.766 ± 0.193 -0.539 ± 0.194 -#> [81] -0.161 ± 0.098 -0.220 ± 0.134 -0.343 ± 0.083 -0.275 ± 0.093 -#> [85] -0.130 ± 0.076 -1.131 ± 0.318 -0.823 ± 0.128 -0.777 ± 0.238 -#> [89] -1.284 ± 0.315 -0.258 ± 0.133 -0.384 ± 0.127 -1.503 ± 0.353 -#> [93] -0.736 ± 0.221 -0.318 ± 0.090 -0.387 ± 0.113 -1.578 ± 0.293 -#> [97] -0.431 ± 0.102 -1.055 ± 0.371 -0.693 ± 0.139 -0.391 ± 0.098 +#> [1] -0.518 ± 0.101 -0.398 ± 0.148 -0.500 ± 0.222 -0.445 ± 0.153 +#> [5] -1.183 ± 0.289 -0.593 ± 0.195 -0.637 ± 0.127 -0.278 ± 0.133 +#> [9] -0.697 ± 0.172 -0.743 ± 0.237 -0.280 ± 0.126 -0.492 ± 0.240 +#> [13] -0.655 ± 0.213 -0.361 ± 0.174 -0.279 ± 0.109 -0.275 ± 0.087 +#> [17] -1.594 ± 0.288 -0.481 ± 0.109 -0.232 ± 0.075 -0.112 ± 0.078 +#> [21] -0.211 ± 0.087 -0.571 ± 0.151 -0.330 ± 0.138 -0.135 ± 0.065 +#> [25] -0.451 ± 0.123 -1.520 ± 0.340 -0.307 ± 0.123 -0.446 ± 0.086 +#> [29] -0.722 ± 0.230 -0.699 ± 0.193 -0.489 ± 0.165 -0.425 ± 0.111 +#> [33] -0.406 ± 0.128 -0.062 ± 0.048 -0.583 ± 0.188 -0.325 ± 0.130 +#> [37] -0.702 ± 0.230 -0.309 ± 0.149 -0.178 ± 0.110 -0.684 ± 0.132 +#> [41] -1.131 ± 0.261 -0.937 ± 0.201 -0.413 ± 0.266 -1.175 ± 0.188 +#> [45] -0.359 ± 0.118 -0.578 ± 0.131 -0.301 ± 0.128 -0.324 ± 0.083 +#> [49] -0.319 ± 0.081 -1.288 ± 0.331 -0.288 ± 0.094 -0.832 ± 0.146 +#> [53] -0.402 ± 0.132 -0.371 ± 0.142 -0.381 ± 0.136 -0.320 ± 0.188 +#> [57] -0.660 ± 0.121 -0.954 ± 0.356 -1.371 ± 0.345 -0.976 ± 0.161 +#> [61] -0.543 ± 0.100 -0.872 ± 0.317 -0.115 ± 0.071 -0.899 ± 0.250 +#> [65] -2.024 ± 0.609 -0.509 ± 0.139 -0.276 ± 0.081 -1.059 ± 0.239 +#> [69] -0.437 ± 0.086 -0.642 ± 0.235 -0.608 ± 0.213 -0.460 ± 0.173 +#> [73] -1.496 ± 0.368 -0.947 ± 0.199 -1.139 ± 0.392 -0.373 ± 0.140 +#> [77] -0.876 ± 0.143 -0.490 ± 0.174 -0.767 ± 0.193 -0.537 ± 0.197 +#> [81] -0.160 ± 0.100 -0.220 ± 0.138 -0.344 ± 0.082 -0.275 ± 0.092 +#> [85] -0.129 ± 0.074 -1.136 ± 0.323 -0.821 ± 0.130 -0.776 ± 0.248 +#> [89] -1.289 ± 0.322 -0.258 ± 0.136 -0.383 ± 0.131 -1.501 ± 0.351 +#> [93] -0.736 ± 0.220 -0.318 ± 0.088 -0.389 ± 0.113 -1.575 ± 0.284 +#> [97] -0.432 ± 0.101 -1.058 ± 0.374 -0.690 ± 0.144 -0.392 ± 0.098 #> posterior::as_draws_list(fit) #> # A draws_list: 1000 iterations, 4 chains, and 105 variables #> #> [chain = 1] #> $lp__ -#> [1] -65 -66 -65 -65 -66 -66 -65 -64 -65 -65 +#> [1] -66 -67 -66 -65 -64 -65 -65 -66 -64 -66 #> #> $alpha -#> [1] 0.448 0.343 0.441 0.095 0.089 0.680 0.373 0.327 0.441 0.215 +#> [1] 0.792 0.061 0.538 0.446 0.253 0.343 0.387 0.827 0.506 0.713 #> #> $`beta[1]` -#> [1] -0.40 -0.60 -0.46 -0.74 -0.45 -0.80 -0.65 -0.85 -0.39 -0.36 +#> [1] -0.93 -0.60 -0.67 -0.90 -0.63 -0.71 -0.64 -0.60 -0.73 -0.96 #> #> $`beta[2]` -#> [1] -0.29 -0.70 -0.12 -0.48 -0.44 -0.14 -0.50 -0.33 -0.25 -0.33 +#> [1] -0.26 0.12 -0.02 -0.31 -0.12 -0.46 -0.44 -0.39 -0.32 -0.22 #> #> #> [chain = 2] #> $lp__ -#> [1] -67 -65 -65 -66 -69 -68 -67 -67 -68 -69 +#> [1] -65 -67 -65 -66 -67 -67 -67 -67 -67 -72 #> #> $alpha -#> [1] 0.186 0.574 0.536 0.753 0.813 -0.010 0.027 0.027 0.628 0.271 +#> [1] 0.303 0.538 0.227 0.104 0.678 0.596 -0.041 0.769 0.340 0.948 #> #> $`beta[1]` -#> [1] -0.126 -0.754 -1.000 -0.716 -0.801 -0.503 -0.628 -0.628 -0.985 -0.052 +#> [1] -0.46 -0.87 -0.51 -0.78 -0.57 -0.50 -0.57 -0.67 -0.60 -0.47 #> #> $`beta[2]` -#> [1] -0.25 -0.35 -0.21 -0.34 -0.10 -0.34 -0.17 -0.17 -0.70 -0.21 +#> [1] 0.03060 -0.22607 -0.19885 -0.01303 -0.61503 -0.63211 0.00036 -0.41151 +#> [9] -0.46209 -0.88087 #> #> # ... with 990 more iterations, and 2 more chains, and 101 more variables # } diff --git a/docs/reference/as_mcmc.list.html b/docs/reference/as_mcmc.list.html index 6d0e719b5..222a49f3d 100644 --- a/docs/reference/as_mcmc.list.html +++ b/docs/reference/as_mcmc.list.html @@ -23,7 +23,7 @@Examples
# Otherwise use the `path` argument to specify the location of your # CmdStan installation.) set_cmdstan_path(path = NULL) -#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.35.0 +#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.36.0 # Create a CmdStanModel object from a Stan program, # here using the example model that comes with CmdStan @@ -287,8 +287,8 @@Examples
#> # A tibble: 2 × 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__ -7.30 -7.00 0.811 0.344 -8.83 -6.75 1.00 702. 776. -#> 2 theta 0.254 0.238 0.125 0.124 0.0807 0.483 1.00 634. 580. +#> 1 lp__ -7.35 -7.01 0.882 0.353 -9.14 -6.75 1.00 724. 896. +#> 2 theta 0.254 0.239 0.129 0.126 0.0737 0.488 1.00 532. 657. # Check sampling diagnostics fit_mcmc$diagnostic_summary() @@ -299,7 +299,7 @@Examples
#> [1] 0 0 #> #> $ebfmi -#> [1] 1.1148699 0.8012192 +#> [1] 1.1148479 0.7568734 #> # Get posterior draws @@ -309,22 +309,22 @@Examples
#> , , variable = lp__ #> #> chain -#> iteration 1 2 -#> 1 -7.0 -6.8 -#> 2 -7.9 -6.9 -#> 3 -7.4 -6.8 -#> 4 -6.7 -6.8 -#> 5 -6.9 -10.2 +#> iteration 1 2 +#> 1 -7.0 -8.1 +#> 2 -7.9 -7.9 +#> 3 -7.4 -7.0 +#> 4 -6.7 -6.8 +#> 5 -6.9 -6.8 #> #> , , variable = theta #> #> chain -#> iteration 1 2 -#> 1 0.17 0.23 -#> 2 0.46 0.18 -#> 3 0.41 0.28 -#> 4 0.25 0.23 -#> 5 0.18 0.62 +#> iteration 1 2 +#> 1 0.17 0.088 +#> 2 0.46 0.097 +#> 3 0.41 0.167 +#> 4 0.25 0.292 +#> 5 0.18 0.238 #> #> # ... with 995 more iterations @@ -350,11 +350,6 @@Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.-# For models fit using MCMC, if you like working with RStan's stanfit objects -# then you can create one with rstan::read_stan_csv() -# stanfit <- rstan::read_stan_csv(fit_mcmc$output_files()) - - # Run 'optimize' method to get a point estimate (default is Stan's LBFGS algorithm) # and also demonstrate specifying data as a path to a file instead of a list my_data_file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.data.json") @@ -364,7 +359,7 @@
Examples
#> 6 -5.00402 0.000246518 8.73164e-07 1 1 9 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance -#> Finished in 0.2 seconds. +#> Finished in 0.1 seconds. fit_optim$summary() #> # A tibble: 2 × 2 #> variable estimate @@ -375,12 +370,12 @@Examples
# 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 = -13.9671 +#> Initial log joint probability = -7.19041 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 5 -6.74802 0.00195337 5.29486e-05 1 1 8 +#> 5 -6.74802 0.000219546 2.02164e-07 1 1 8 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance -#> Finished in 0.2 seconds. +#> Finished in 0.1 seconds. fit_laplace <- mod$laplace(data = my_data_file, mode = fit_optim, draws = 2000) #> Calculating Hessian #> Calculating inverse of Cholesky factor @@ -405,14 +400,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.21 -6.97 0.646 0.293 -8.55 -6.75 -#> 2 lp_approx__ -0.466 -0.220 0.655 0.297 -1.78 -0.00205 -#> 3 theta 0.270 0.250 0.120 0.121 0.109 0.497 +#> 1 lp__ -7.23 -6.98 0.662 0.312 -8.57 -6.75 +#> 2 lp_approx__ -0.490 -0.230 0.676 0.315 -1.92 -0.00147 +#> 3 theta 0.269 0.251 0.121 0.123 0.101 0.490 # Run 'variational' method to use ADVI to approximate posterior fit_vb <- mod$variational(data = stan_data, seed = 123) @@ -421,8 +416,8 @@Examples
#> This procedure has not been thoroughly tested and may be unstable #> or buggy. The interface is subject to change. #> ------------------------------------------------------------ -#> Gradient evaluation took 2.3e-05 seconds -#> 1000 transitions using 10 leapfrog steps per transition would take 0.23 seconds. +#> Gradient evaluation took 9e-06 seconds +#> 1000 transitions using 10 leapfrog steps per transition would take 0.09 seconds. #> Adjust your expectations accordingly! #> Begin eta adaptation. #> Iteration: 1 / 250 [ 0%] (Adaptation) @@ -438,7 +433,7 @@Examples
#> 300 -6.186 0.339 0.010 MEDIAN ELBO CONVERGED #> Drawing a sample of size 1000 from the approximate posterior... #> COMPLETED. -#> Finished in 0.2 seconds. +#> Finished in 0.1 seconds. fit_vb$summary() #> # A tibble: 3 × 7 #> variable mean median sd mad q5 q95 @@ -469,7 +464,7 @@Examples
#> 5 -6.748e+00 2.145e-04 1.301e-06 1.000e+00 1.000e+00 126 -6.197e+00 -6.197e+00 #> Path [4] :Best Iter: [5] ELBO (-6.197118) evaluations: (126) #> Total log probability function evaluations:4379 -#> Finished in 0.2 seconds. +#> Finished in 0.1 seconds. fit_pf$summary() #> # A tibble: 3 × 7 #> variable mean median sd mad q5 q95 @@ -486,48 +481,48 @@Examples
fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40, history_size=50, max_lbfgs_iters=100) #> Warning: Number of PSIS draws is larger than the total number of draws returned by the single Pathfinders. This is likely unintentional and leads to re-sampling from the same draws. -#> Path [1] :Initial log joint density = -7.405417 +#> Path [1] :Initial log joint density = -19.520956 #> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 9.081e-05 3.233e-07 1.000e+00 1.000e+00 126 -6.231e+00 -6.231e+00 -#> Path [1] :Best Iter: [3] ELBO (-6.194155) evaluations: (126) -#> Path [2] :Initial log joint density = -7.706381 +#> 4 -6.748e+00 1.226e-02 1.762e-04 1.000e+00 1.000e+00 101 -6.253e+00 -6.253e+00 +#> Path [1] :Best Iter: [2] ELBO (-6.195755) evaluations: (101) +#> Path [2] :Initial log joint density = -7.254863 #> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.603e-04 8.100e-07 1.000e+00 1.000e+00 126 -6.209e+00 -6.209e+00 -#> Path [2] :Best Iter: [5] ELBO (-6.209214) evaluations: (126) -#> Path [3] :Initial log joint density = -8.140103 +#> 5 -6.748e+00 3.135e-04 3.796e-07 1.000e+00 1.000e+00 126 -6.215e+00 -6.215e+00 +#> Path [2] :Best Iter: [4] ELBO (-6.093719) evaluations: (126) +#> Path [3] :Initial log joint density = -9.357651 #> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 2.528e-04 1.703e-06 1.000e+00 1.000e+00 126 -6.231e+00 -6.231e+00 -#> Path [3] :Best Iter: [3] ELBO (-6.213740) evaluations: (126) -#> Path [4] :Initial log joint density = -6.779208 +#> 5 -6.748e+00 4.272e-04 4.080e-06 1.000e+00 1.000e+00 126 -6.228e+00 -6.228e+00 +#> Path [3] :Best Iter: [3] ELBO (-6.197602) evaluations: (126) +#> Path [4] :Initial log joint density = -15.654513 #> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 1.406e-04 3.696e-07 1.000e+00 1.000e+00 101 -6.183e+00 -6.183e+00 -#> Path [4] :Best Iter: [4] ELBO (-6.183257) evaluations: (101) -#> Path [5] :Initial log joint density = -6.762413 +#> 5 -6.748e+00 1.955e-03 5.901e-05 1.000e+00 1.000e+00 126 -6.224e+00 -6.224e+00 +#> Path [4] :Best Iter: [5] ELBO (-6.224416) evaluations: (126) +#> Path [5] :Initial log joint density = -6.893187 #> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 3 -6.748e+00 2.209e-03 1.061e-04 1.000e+00 1.000e+00 76 -6.247e+00 -6.247e+00 -#> Path [5] :Best Iter: [2] ELBO (-6.191386) evaluations: (76) -#> Path [6] :Initial log joint density = -7.106649 +#> 4 -6.748e+00 1.780e-04 2.911e-05 9.344e-01 9.344e-01 101 -6.239e+00 -6.239e+00 +#> Path [5] :Best Iter: [3] ELBO (-6.215896) evaluations: (101) +#> Path [6] :Initial log joint density = -10.329090 #> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 3.282e-03 7.049e-05 1.000e+00 1.000e+00 101 -6.179e+00 -6.179e+00 -#> Path [6] :Best Iter: [3] ELBO (-6.136787) evaluations: (101) -#> Path [7] :Initial log joint density = -7.037942 +#> 5 -6.748e+00 7.385e-04 9.583e-06 1.000e+00 1.000e+00 126 -6.222e+00 -6.222e+00 +#> Path [6] :Best Iter: [3] ELBO (-6.212303) evaluations: (126) +#> Path [7] :Initial log joint density = -15.872224 #> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 2.570e-03 4.694e-05 1.000e+00 1.000e+00 101 -6.238e+00 -6.238e+00 -#> Path [7] :Best Iter: [3] ELBO (-6.227629) evaluations: (101) -#> Path [8] :Initial log joint density = -6.772444 +#> 5 -6.748e+00 1.903e-03 5.733e-05 1.000e+00 1.000e+00 126 -6.254e+00 -6.254e+00 +#> Path [7] :Best Iter: [4] ELBO (-6.195869) evaluations: (126) +#> Path [8] :Initial log joint density = -10.958418 #> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 9.980e-05 2.088e-07 1.000e+00 1.000e+00 101 -6.208e+00 -6.208e+00 -#> Path [8] :Best Iter: [2] ELBO (-6.208417) evaluations: (101) -#> Path [9] :Initial log joint density = -17.488355 +#> 5 -6.748e+00 9.246e-04 1.360e-05 1.000e+00 1.000e+00 126 -6.214e+00 -6.214e+00 +#> Path [8] :Best Iter: [2] ELBO (-6.186854) evaluations: (126) +#> Path [9] :Initial log joint density = -12.861849 #> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.187e-03 3.028e-05 1.000e+00 1.000e+00 126 -6.283e+00 -6.283e+00 -#> Path [9] :Best Iter: [2] ELBO (-6.205015) evaluations: (126) -#> Path [10] :Initial log joint density = -7.447696 +#> 5 -6.748e+00 1.621e-03 3.641e-05 1.000e+00 1.000e+00 126 -6.213e+00 -6.213e+00 +#> Path [9] :Best Iter: [5] ELBO (-6.213458) evaluations: (126) +#> Path [10] :Initial log joint density = -16.360860 #> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.004e-04 3.798e-07 1.000e+00 1.000e+00 126 -6.264e+00 -6.264e+00 -#> Path [10] :Best Iter: [3] ELBO (-6.226969) evaluations: (126) -#> Total log probability function evaluations:1260 -#> Finished in 0.2 seconds. +#> 5 -6.748e+00 1.745e-03 5.153e-05 1.000e+00 1.000e+00 126 -6.169e+00 -6.169e+00 +#> Path [10] :Best Iter: [5] ELBO (-6.169190) 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( @@ -609,7 +604,7 @@Examples
#> 6 -5.00402 0.000237915 9.55309e-07 1 1 9 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance -#> Finished in 0.2 seconds. +#> Finished in 0.1 seconds. fit_optim_w_init_list$init() #> [[1]] #> [[1]]$theta diff --git a/docs/reference/cmdstanr-package-1.png b/docs/reference/cmdstanr-package-1.png index aa185638c..35206a7af 100644 Binary files a/docs/reference/cmdstanr-package-1.png and b/docs/reference/cmdstanr-package-1.png differ diff --git a/docs/reference/cmdstanr-package-2.png b/docs/reference/cmdstanr-package-2.png index 4cf81fa80..b078570c6 100644 Binary files a/docs/reference/cmdstanr-package-2.png and b/docs/reference/cmdstanr-package-2.png differ diff --git a/docs/reference/cmdstanr-package-3.png b/docs/reference/cmdstanr-package-3.png index c67b37ed1..35367ed42 100644 Binary files a/docs/reference/cmdstanr-package-3.png and b/docs/reference/cmdstanr-package-3.png differ diff --git a/docs/reference/cmdstanr-package.html b/docs/reference/cmdstanr-package.html index 497703b7b..a3d781a32 100644 --- a/docs/reference/cmdstanr-package.html +++ b/docs/reference/cmdstanr-package.html @@ -19,7 +19,7 @@Examples
# Otherwise use the `path` argument to specify the location of your # CmdStan installation.) set_cmdstan_path(path = NULL) -#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.35.0 +#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.36.0 # Create a CmdStanModel object from a Stan program, # here using the example model that comes with CmdStan @@ -313,8 +313,8 @@Examples
#> # A tibble: 2 × 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__ -7.30 -7.00 0.811 0.344 -8.83 -6.75 1.00 702. 776. -#> 2 theta 0.254 0.238 0.125 0.124 0.0807 0.483 1.00 634. 580. +#> 1 lp__ -7.35 -7.01 0.882 0.353 -9.14 -6.75 1.00 724. 896. +#> 2 theta 0.254 0.239 0.129 0.126 0.0737 0.488 1.00 532. 657. # Check sampling diagnostics fit_mcmc$diagnostic_summary() @@ -325,7 +325,7 @@Examples
#> [1] 0 0 #> #> $ebfmi -#> [1] 1.1148699 0.8012192 +#> [1] 1.1148479 0.7568734 #> # Get posterior draws @@ -335,22 +335,22 @@Examples
#> , , variable = lp__ #> #> chain -#> iteration 1 2 -#> 1 -7.0 -6.8 -#> 2 -7.9 -6.9 -#> 3 -7.4 -6.8 -#> 4 -6.7 -6.8 -#> 5 -6.9 -10.2 +#> iteration 1 2 +#> 1 -7.0 -8.1 +#> 2 -7.9 -7.9 +#> 3 -7.4 -7.0 +#> 4 -6.7 -6.8 +#> 5 -6.9 -6.8 #> #> , , variable = theta #> #> chain -#> iteration 1 2 -#> 1 0.17 0.23 -#> 2 0.46 0.18 -#> 3 0.41 0.28 -#> 4 0.25 0.23 -#> 5 0.18 0.62 +#> iteration 1 2 +#> 1 0.17 0.088 +#> 2 0.46 0.097 +#> 3 0.41 0.167 +#> 4 0.25 0.292 +#> 5 0.18 0.238 #> #> # ... with 995 more iterations @@ -376,11 +376,6 @@Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.-# For models fit using MCMC, if you like working with RStan's stanfit objects -# then you can create one with rstan::read_stan_csv() -# stanfit <- rstan::read_stan_csv(fit_mcmc$output_files()) - - # Run 'optimize' method to get a point estimate (default is Stan's LBFGS algorithm) # and also demonstrate specifying data as a path to a file instead of a list my_data_file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.data.json") @@ -390,7 +385,7 @@
Examples
#> 6 -5.00402 0.000246518 8.73164e-07 1 1 9 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance -#> Finished in 0.2 seconds. +#> Finished in 0.1 seconds. fit_optim$summary() #> # A tibble: 2 × 2 #> variable estimate @@ -401,12 +396,12 @@Examples
# 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.37731 +#> Initial log joint probability = -6.80195 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 5 -6.74802 8.45677e-05 2.88228e-07 1 1 8 +#> 4 -6.74802 0.00029907 1.30133e-06 1 1 7 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance -#> Finished in 0.2 seconds. +#> Finished in 0.1 seconds. fit_laplace <- mod$laplace(data = my_data_file, mode = fit_optim, draws = 2000) #> Calculating Hessian #> Calculating inverse of Cholesky factor @@ -431,14 +426,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.25 -6.98 0.745 0.324 -8.71 -6.75 -#> 2 lp_approx__ -0.518 -0.231 0.764 0.321 -1.95 -0.00198 -#> 3 theta 0.266 0.247 0.124 0.121 0.0979 0.501 +#> variable mean median sd mad q5 q95 +#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> +#> 1 lp__ -7.22 -6.96 0.660 0.293 -8.56 -6.75 +#> 2 lp_approx__ -0.479 -0.220 0.648 0.296 -1.85 -0.00230 +#> 3 theta 0.271 0.251 0.122 0.119 0.101 0.501 # Run 'variational' method to use ADVI to approximate posterior fit_vb <- mod$variational(data = stan_data, seed = 123) @@ -447,8 +442,8 @@Examples
#> This procedure has not been thoroughly tested and may be unstable #> or buggy. The interface is subject to change. #> ------------------------------------------------------------ -#> Gradient evaluation took 1.5e-05 seconds -#> 1000 transitions using 10 leapfrog steps per transition would take 0.15 seconds. +#> Gradient evaluation took 1e-05 seconds +#> 1000 transitions using 10 leapfrog steps per transition would take 0.1 seconds. #> Adjust your expectations accordingly! #> Begin eta adaptation. #> Iteration: 1 / 250 [ 0%] (Adaptation) @@ -464,7 +459,7 @@Examples
#> 300 -6.186 0.339 0.010 MEDIAN ELBO CONVERGED #> Drawing a sample of size 1000 from the approximate posterior... #> COMPLETED. -#> Finished in 0.2 seconds. +#> Finished in 0.1 seconds. fit_vb$summary() #> # A tibble: 3 × 7 #> variable mean median sd mad q5 q95 @@ -495,7 +490,7 @@Examples
#> 5 -6.748e+00 2.145e-04 1.301e-06 1.000e+00 1.000e+00 126 -6.197e+00 -6.197e+00 #> Path [4] :Best Iter: [5] ELBO (-6.197118) evaluations: (126) #> Total log probability function evaluations:4379 -#> Finished in 0.2 seconds. +#> Finished in 0.1 seconds. fit_pf$summary() #> # A tibble: 3 × 7 #> variable mean median sd mad q5 q95 @@ -512,49 +507,48 @@Examples
fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40, history_size=50, max_lbfgs_iters=100) #> Warning: Number of PSIS draws is larger than the total number of draws returned by the single Pathfinders. This is likely unintentional and leads to re-sampling from the same draws. -#> Path [1] :Initial log joint density = -15.640416 +#> Path [1] :Initial log joint density = -8.288264 #> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.958e-03 5.910e-05 1.000e+00 1.000e+00 126 -6.252e+00 -6.252e+00 -#> Path [1] :Best Iter: [4] ELBO (-6.217832) evaluations: (126) -#> Path [2] :Initial log joint density = -7.289736 +#> 5 -6.748e+00 2.788e-04 2.003e-06 1.000e+00 1.000e+00 126 -6.242e+00 -6.242e+00 +#> Path [1] :Best Iter: [2] ELBO (-6.189407) evaluations: (126) +#> Path [2] :Initial log joint density = -7.122559 #> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 3.739e-04 5.183e-07 1.000e+00 1.000e+00 126 -6.223e+00 -6.223e+00 -#> Path [2] :Best Iter: [4] ELBO (-6.180764) evaluations: (126) -#> Path [3] :Initial log joint density = -6.814578 +#> 4 -6.748e+00 3.446e-03 7.646e-05 1.000e+00 1.000e+00 101 -6.267e+00 -6.267e+00 +#> Path [2] :Best Iter: [2] ELBO (-6.217814) evaluations: (101) +#> Path [3] :Initial log joint density = -6.904847 #> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 3 -6.748e+00 4.711e-03 8.907e-05 9.425e-01 9.425e-01 76 -6.167e+00 -6.167e+00 -#> Path [3] :Best Iter: [3] ELBO (-6.166803) evaluations: (76) -#> Path [4] :Initial log joint density = -6.750524 +#> 4 -6.748e+00 1.217e-03 1.351e-05 1.000e+00 1.000e+00 101 -6.256e+00 -6.256e+00 +#> Path [3] :Best Iter: [3] ELBO (-6.226443) evaluations: (101) +#> Path [4] :Initial log joint density = -15.810600 #> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 3 -6.748e+00 4.513e-04 7.212e-06 9.979e-01 9.979e-01 76 -6.172e+00 -6.172e+00 -#> Path [4] :Best Iter: [3] ELBO (-6.171786) evaluations: (76) -#> Path [5] :Initial log joint density = -7.332655 +#> 5 -6.748e+00 1.919e-03 5.787e-05 1.000e+00 1.000e+00 126 -6.202e+00 -6.202e+00 +#> Path [4] :Best Iter: [4] ELBO (-6.144907) evaluations: (126) +#> Path [5] :Initial log joint density = -7.535814 #> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 4.580e-04 7.427e-07 1.000e+00 1.000e+00 126 -6.250e+00 -6.250e+00 -#> Path [5] :Best Iter: [3] ELBO (-6.236262) evaluations: (126) -#> Path [6] :Initial log joint density = -12.928546 +#> 5 -6.748e+00 1.206e-04 5.112e-07 1.000e+00 1.000e+00 126 -6.233e+00 -6.233e+00 +#> Path [5] :Best Iter: [4] ELBO (-6.165244) evaluations: (126) +#> Path [6] :Initial log joint density = -12.317092 #> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.646e-03 3.751e-05 1.000e+00 1.000e+00 126 -6.201e+00 -6.201e+00 -#> Path [6] :Best Iter: [5] ELBO (-6.201184) evaluations: (126) -#> Path [7] :Initial log joint density = -10.302489 +#> 5 -6.748e+00 1.394e-03 2.744e-05 1.000e+00 1.000e+00 126 -6.247e+00 -6.247e+00 +#> Path [6] :Best Iter: [3] ELBO (-6.207884) evaluations: (126) +#> Path [7] :Initial log joint density = -6.970206 #> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 7.301e-04 9.415e-06 1.000e+00 1.000e+00 126 -6.220e+00 -6.220e+00 -#> Path [7] :Best Iter: [3] ELBO (-6.177461) evaluations: (126) -#> Path [8] :Initial log joint density = -9.256093 +#> 4 -6.748e+00 3.919e-04 8.523e-05 9.151e-01 9.151e-01 101 -6.187e+00 -6.187e+00 +#> Path [7] :Best Iter: [4] ELBO (-6.187348) evaluations: (101) +#> Path [8] :Initial log joint density = -6.960470 #> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 3.955e-04 3.617e-06 1.000e+00 1.000e+00 126 -6.238e+00 -6.238e+00 -#> Path [8] :Best Iter: [3] ELBO (-6.220144) evaluations: (126) -#> Path [9] :Initial log joint density = -18.100368 +#> 4 -6.748e+00 1.773e-03 2.529e-05 1.000e+00 1.000e+00 101 -6.148e+00 -6.148e+00 +#> Path [8] :Best Iter: [4] ELBO (-6.147740) evaluations: (101) +#> Path [9] :Initial log joint density = -6.771981 #> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 8.150e-04 1.759e-05 1.000e+00 1.000e+00 126 -6.245e+00 -6.245e+00 -#> Path [9] :Best Iter: [2] ELBO (-6.200207) evaluations: (126) -#> Path [10] :Initial log joint density = -6.749568 +#> 3 -6.748e+00 2.126e-03 4.338e-07 9.709e-01 9.709e-01 76 -6.239e+00 -6.239e+00 +#> Path [9] :Best Iter: [2] ELBO (-6.211440) evaluations: (76) +#> Path [10] :Initial log joint density = -7.099410 #> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 3 -6.748e+00 2.564e-04 4.111e-06 1.000e+00 1.000e+00 76 -6.255e+00 -6.255e+00 -#> Path [10] :Best Iter: [2] ELBO (-6.165609) evaluations: (76) +#> 5 -6.748e+00 1.211e-04 7.078e-08 1.000e+00 1.000e+00 126 -6.227e+00 -6.227e+00 +#> Path [10] :Best Iter: [2] ELBO (-6.196731) evaluations: (126) #> Total log probability function evaluations:1260 -#> Pareto k value (0.89) 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.2 seconds. +#> Finished in 0.1 seconds. # Specifying initial values as a function fit_mcmc_w_init_fun <- mod$sample( @@ -636,7 +630,7 @@Examples
#> 6 -5.00402 0.000237915 9.55309e-07 1 1 9 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance -#> Finished in 0.2 seconds. +#> Finished in 0.1 seconds. fit_optim_w_init_list$init() #> [[1]] #> [[1]]$theta diff --git a/docs/reference/cmdstanr_example.html b/docs/reference/cmdstanr_example.html index e844dcaaf..b4484a920 100644 --- a/docs/reference/cmdstanr_example.html +++ b/docs/reference/cmdstanr_example.html @@ -17,7 +17,7 @@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__ -65.9 -65.6 1.43 1.23 -68.7 -64.3 1.00 890. -#> 2 alpha 0.377 0.375 0.220 0.220 0.0153 0.743 1.00 2007. -#> 3 beta[1] -0.670 -0.663 0.247 0.244 -1.10 -0.273 1.00 1880. -#> 4 beta[2] -0.268 -0.269 0.223 0.218 -0.637 0.106 1.00 1834. -#> 5 beta[3] 0.684 0.681 0.271 0.271 0.243 1.14 1.00 2163. -#> 6 log_lik[1] -0.516 -0.511 0.101 0.0973 -0.694 -0.363 1.00 2030. -#> 7 log_lik[2] -0.398 -0.38 0.143 0.141 -0.661 -0.204 1.00 2280. -#> 8 log_lik[3] -0.493 -0.463 0.216 0.196 -0.883 -0.197 1.00 1914. -#> 9 log_lik[4] -0.450 -0.430 0.153 0.148 -0.730 -0.229 1.00 2150. -#> 10 log_lik[5] -1.19 -1.16 0.288 0.283 -1.70 -0.769 1.00 2194. +#> 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.22 -68.8 -64.3 1.00 963. +#> 2 alpha 0.376 0.373 0.220 0.221 0.0226 0.745 1.00 2237. +#> 3 beta[1] -0.671 -0.663 0.250 0.252 -1.10 -0.258 1.00 1930. +#> 4 beta[2] -0.262 -0.261 0.222 0.229 -0.629 0.0934 1.00 1801. +#> 5 beta[3] 0.674 0.681 0.264 0.263 0.242 1.10 1.00 1979. +#> 6 log_lik[1] -0.515 -0.509 0.0991 0.0964 -0.681 -0.363 1.00 2100. +#> 7 log_lik[2] -0.401 -0.381 0.147 0.138 -0.671 -0.197 1.00 2010. +#> 8 log_lik[3] -0.489 -0.456 0.215 0.202 -0.891 -0.207 1.00 1914. +#> 9 log_lik[4] -0.455 -0.435 0.154 0.152 -0.726 -0.242 1.00 1918. +#> 10 log_lik[5] -1.18 -1.16 0.283 0.282 -1.69 -0.749 1.00 2470. #> # ℹ 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.2 -65.8 1.56 1.32 -69.2 -64.3 -#> 2 lp_approx__ -1.94 -1.61 1.34 1.15 -4.56 -0.362 -#> 3 alpha 0.448 0.454 0.184 0.186 0.144 0.745 -#> 4 beta[1] -0.710 -0.711 0.297 0.296 -1.20 -0.230 -#> 5 beta[2] -0.211 -0.214 0.213 0.218 -0.546 0.131 -#> 6 beta[3] 0.719 0.717 0.272 0.278 0.285 1.18 -#> 7 log_lik[1] -0.478 -0.474 0.0839 0.0865 -0.622 -0.351 -#> 8 log_lik[2] -0.391 -0.364 0.154 0.141 -0.698 -0.180 -#> 9 log_lik[3] -0.408 -0.382 0.181 0.171 -0.755 -0.162 -#> 10 log_lik[4] -0.483 -0.471 0.145 0.142 -0.745 -0.272 +#> variable mean median sd mad q5 q95 +#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> +#> 1 lp__ -66.4 -65.9 1.84 1.52 -69.9 -64.3 +#> 2 lp_approx__ -1.98 -1.65 1.42 1.25 -4.64 -0.331 +#> 3 alpha 0.377 0.370 0.296 0.307 -0.116 0.869 +#> 4 beta[1] -0.646 -0.648 0.241 0.234 -1.04 -0.241 +#> 5 beta[2] -0.252 -0.257 0.201 0.191 -0.579 0.0845 +#> 6 beta[3] 0.702 0.695 0.280 0.269 0.236 1.16 +#> 7 log_lik[1] -0.523 -0.518 0.128 0.130 -0.747 -0.331 +#> 8 log_lik[2] -0.398 -0.369 0.168 0.155 -0.716 -0.174 +#> 9 log_lik[3] -0.480 -0.450 0.204 0.193 -0.859 -0.211 +#> 10 log_lik[4] -0.455 -0.431 0.159 0.160 -0.739 -0.235 #> # ℹ 96 more rows print_example_program("schools") @@ -254,25 +254,25 @@Examples
#> target += normal_lpdf(y | theta, sigma); #> } fit_schools_mcmc <- cmdstanr_example("schools") -#> Warning: 679 of 4000 (17.0%) transitions ended with a divergence. +#> Warning: 260 of 4000 (6.0%) transitions ended with a divergence. #> See https://mc-stan.org/misc/warnings for details. -#> Warning: 2 of 4 chains had an E-BFMI less than 0.3. +#> Warning: 1 of 4 chains had an E-BFMI less than 0.3. #> 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__ -55.2 -56.2 7.20 8.44 -65.7 -44.5 1.35 9.26 502. -#> 2 mu 5.92 4.83 3.74 2.79 0.0739 12.5 1.14 269. 979. -#> 3 tau 4.29 3.34 3.72 3.44 0.650 11.7 1.35 9.24 5.53 -#> 4 theta[1] 8.28 6.13 6.22 3.70 0.148 20.3 1.19 199. 1448. -#> 5 theta[2] 6.41 5.49 5.11 3.45 -1.72 15.4 1.10 460. 1260. -#> 6 theta[3] 5.14 4.33 5.96 3.94 -5.01 15.0 1.23 782. 1447. -#> 7 theta[4] 5.87 4.59 5.16 3.49 -2.48 15.2 1.31 730. 948. -#> 8 theta[5] 4.56 4.37 5.04 4.04 -4.72 12.5 1.28 643. 1270. -#> 9 theta[6] 5.08 4.56 5.20 3.35 -3.77 13.6 1.12 659. 1302. -#> 10 theta[7] 8.06 6.46 5.45 3.53 0.928 18.2 1.05 73.8 1255. -#> 11 theta[8] 6.38 5.50 6.15 3.54 -2.77 17.5 1.11 260. 1699. +#> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail +#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> +#> 1 lp__ -58.0 -58.4 5.27 5.30 -66.3 -48.5 1.07 43.0 27.8 +#> 2 mu 6.38 6.13 4.15 3.80 -0.237 13.5 1.01 627. 964. +#> 3 tau 5.31 4.49 3.57 3.28 1.10 12.2 1.07 37.6 21.2 +#> 4 theta[1] 9.14 8.16 7.00 6.00 -0.685 21.7 1.01 966. 1427. +#> 5 theta[2] 6.73 6.51 5.64 4.88 -2.30 16.4 1.02 1127. 1732. +#> 6 theta[3] 5.08 5.36 6.58 5.64 -6.24 15.5 1.02 792. 1549. +#> 7 theta[4] 6.57 6.30 5.92 5.19 -2.79 16.1 1.01 1328. 1869. +#> 8 theta[5] 4.56 4.87 5.47 5.08 -5.00 13.1 1.02 707. 1473. +#> 9 theta[6] 5.31 5.53 6.01 5.11 -5.18 14.7 1.01 834. 1685. +#> 10 theta[7] 9.04 8.41 5.90 5.30 0.408 19.3 1.01 701. 1390. +#> 11 theta[8] 6.88 6.54 6.69 5.37 -4.06 18.2 1.02 1238. 2106. print_example_program("schools_ncp") #> data { @@ -297,36 +297,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.41 2.29 -51.3 -43.5 1.00 1454. -#> 2 mu 6.51 6.48 4.11 4.18 -0.0368 13.3 1.00 3392. -#> 3 tau 4.77 3.96 3.63 3.48 0.449 11.8 1.00 2260. -#> 4 theta_raw[1] 0.377 0.379 0.975 0.954 -1.26 1.95 1.00 4065. -#> 5 theta_raw[2] 0.0526 0.0555 0.895 0.884 -1.43 1.53 1.00 3436. -#> 6 theta_raw[3] -0.143 -0.156 0.970 0.957 -1.73 1.48 1.00 3686. -#> 7 theta_raw[4] 0.0219 0.0261 0.906 0.930 -1.48 1.50 1.00 3671. -#> 8 theta_raw[5] -0.263 -0.285 0.920 0.904 -1.76 1.29 1.00 4086. -#> 9 theta_raw[6] -0.130 -0.144 0.930 0.917 -1.64 1.42 1.00 4353. -#> 10 theta_raw[7] 0.369 0.376 0.918 0.911 -1.15 1.87 1.00 3860. -#> 11 theta_raw[8] 0.0659 0.0592 0.971 0.988 -1.51 1.69 1.00 3781. -#> 12 theta[1] 9.01 8.30 6.74 5.76 -0.246 21.2 1.00 3647. -#> 13 theta[2] 6.88 6.83 5.35 4.89 -1.89 15.7 1.00 4377. -#> 14 theta[3] 5.45 5.79 6.51 5.55 -5.90 15.5 1.00 3662. -#> 15 theta[4] 6.73 6.60 5.73 5.22 -2.58 16.1 1.00 3999. -#> 16 theta[5] 4.91 5.16 5.52 4.90 -4.78 13.6 1.00 4517. -#> 17 theta[6] 5.64 5.91 6.01 5.33 -4.77 15.0 1.00 4197. -#> 18 theta[7] 8.87 8.36 5.95 5.37 0.312 19.6 1.00 3846. -#> 19 theta[8] 7.06 6.77 6.80 5.70 -3.70 18.3 1.00 3866. -#> # ℹ 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.40 2.30 -51.2 -43.5 1.00 1569. 2358. +#> 2 mu 6.51 6.55e+0 4.22 4.14 -0.355 13.3 1.00 3009. 2465. +#> 3 tau 4.86 4.06e+0 3.67 3.43 0.444 12.0 1.00 1792. 1620. +#> 4 theta_r… 0.348 3.50e-1 0.956 0.960 -1.26 1.93 1.00 3527. 2677. +#> 5 theta_r… 0.0410 5.49e-2 0.889 0.880 -1.47 1.46 1.00 4110. 2991. +#> 6 theta_r… -0.142 -1.47e-1 0.953 0.945 -1.69 1.43 1.00 4686. 2441. +#> 7 theta_r… -0.0107 -9.40e-3 0.937 0.935 -1.53 1.53 1.00 4262. 2854. +#> 8 theta_r… -0.296 -2.93e-1 0.931 0.915 -1.83 1.24 1.00 3286. 2516. +#> 9 theta_r… -0.172 -1.84e-1 0.911 0.881 -1.69 1.36 1.00 3801. 2532. +#> 10 theta_r… 0.360 3.84e-1 0.933 0.904 -1.21 1.83 1.00 3900. 2825. +#> 11 theta_r… 0.0773 7.71e-2 0.982 1.00 -1.54 1.67 1.00 4239. 2766. +#> 12 theta[1] 9.01 8.06e+0 6.94 5.65 -0.546 22.1 1.00 3731. 3102. +#> 13 theta[2] 6.85 6.80e+0 5.61 5.13 -2.12 16.3 1.00 4538. 3046. +#> 14 theta[3] 5.47 5.82e+0 6.48 5.46 -6.06 15.3 1.00 4254. 3124. +#> 15 theta[4] 6.52 6.47e+0 5.74 5.18 -2.72 15.9 1.00 4625. 3465. +#> 16 theta[5] 4.79 5.10e+0 5.61 5.15 -4.87 13.3 1.00 4852. 3150. +#> 17 theta[6] 5.54 5.73e+0 5.60 5.11 -3.94 14.1 1.00 4021. 3062. +#> 18 theta[7] 8.95 8.27e+0 6.02 5.41 0.317 19.7 1.00 4087. 3495. +#> 19 theta[8] 7.00 7.00e+0 6.58 5.65 -3.39 17.8 1.00 3992. 3246. # optimization fails for hierarchical model cmdstanr_example("schools", "optimize", quiet = FALSE) -#> Initial log joint probability = -53.966 +#> Initial log joint probability = -57.1999 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 99 123.351 0.058381 2.09576e+09 0.5049 0.5049 181 +#> 99 137.364 0.389882 2.12196e+10 0.1758 0.3216 199 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 184 248.826 0.4674 3.92933e+16 1e-12 0.001 384 LS failed, Hessian reset +#> 175 252.319 0.0285374 7.72538e+16 1e-12 0.001 386 LS failed, Hessian reset #> Chain 1 Optimization terminated with error: #> Chain 1 Line search failed to achieve a sufficient decrease, no more progress can be made #> Warning: Fitting finished unexpectedly! Use the $output() method for more information. diff --git a/docs/reference/cmdstanr_global_options.html b/docs/reference/cmdstanr_global_options.html index 879820a9f..97ca7fb7f 100644 --- a/docs/reference/cmdstanr_global_options.html +++ b/docs/reference/cmdstanr_global_options.html @@ -17,7 +17,7 @@Details
compile for more details. The default isFALSE.+
cmdstanr_max_rows: The maximum number of rows of output to print when using the$print()method. The default is 10.
cmdstanr_print_line_numbers: Should line numbers be included when +printing a Stan program? The default isFALSE.
cmdstanr_no_ver_check: Should the check for a more recent version of CmdStan be disabled? The default isFALSE.
cmdstanr_output_dir: The directory where CmdStan should write its output diff --git a/docs/reference/draws_to_csv.html b/docs/reference/draws_to_csv.html index 2ce97f972..a87098b92 100644 --- a/docs/reference/draws_to_csv.html +++ b/docs/reference/draws_to_csv.html @@ -18,7 +18,7 @@Examples
draws_csv_files <- draws_to_csv(draws) print(draws_csv_files) -#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpiACQ3q/fittedParams-202407021533-1-2ac97c.csv" -#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpiACQ3q/fittedParams-202407021533-2-2ac97c.csv" -#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpiACQ3q/fittedParams-202407021533-3-2ac97c.csv" -#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpiACQ3q/fittedParams-202407021533-4-2ac97c.csv" +#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpWzIPg0/fittedParams-202503310842-1-4146ef.csv" +#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpWzIPg0/fittedParams-202503310842-2-4146ef.csv" +#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpWzIPg0/fittedParams-202503310842-3-4146ef.csv" +#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T//RtmpWzIPg0/fittedParams-202503310842-4-4146ef.csv" # draws_csv_files <- draws_to_csv(draws, # sampler_diagnostic = sampler_diagnostics, diff --git a/docs/reference/eng_cmdstan.html b/docs/reference/eng_cmdstan.html index 6deca41f0..a00dec670 100644 --- a/docs/reference/eng_cmdstan.html +++ b/docs/reference/eng_cmdstan.html @@ -22,7 +22,7 @@Examples
diff --git a/docs/reference/fit-method-code.html b/docs/reference/fit-method-code.html index cdf0e851d..c8190b196 100644 --- a/docs/reference/fit-method-code.html +++ b/docs/reference/fit-method-code.html @@ -17,7 +17,7 @@# \dontrun{ fit <- cmdstanr_example("logistic") fit$cmdstan_diagnose() -#> Processing csv files: /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021533-1-42dde2.csv, /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021533-2-42dde2.csv, /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021533-3-42dde2.csv, /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021533-4-42dde2.csv -#> #> Checking sampler transitions treedepth. #> Treedepth satisfactory for all transitions. #> @@ -160,137 +158,136 @@Examples
#> Checking E-BFMI - sampler transitions HMC potential energy. #> E-BFMI satisfactory. #> -#> Effective sample size satisfactory. +#> Rank-normalized split effective sample size satisfactory for all parameters. #> -#> Split R-hat values satisfactory all parameters. +#> Rank-normalized split R-hat values satisfactory for all parameters. #> #> Processing complete, no problems detected. fit$cmdstan_summary() #> 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. +#> 4 chains: each with iter=1000; warmup=1000; thin=1; 1000 iterations saved. #> -#> Warmup took (0.043, 0.046, 0.042, 0.041) seconds, 0.17 seconds total -#> Sampling took (0.15, 0.15, 0.16, 0.15) seconds, 0.61 seconds total +#> Warmup took (0.023, 0.023, 0.022, 0.021) seconds, 0.089 seconds total +#> Sampling took (0.078, 0.073, 0.074, 0.072) seconds, 0.30 seconds total #> -#> Mean MCSE StdDev 5% 50% 95% N_Eff N_Eff/s R_hat +#> Mean MCSE StdDev MAD 5% 50% 95% ESS_bulk ESS_tail R_hat #> -#> lp__ -6.6e+01 3.3e-02 1.4 -69 -6.6e+01 -6.4e+01 1837 3007 1.0 -#> accept_stat__ 0.90 0.011 0.12 0.65 0.94 1.0 123 202 1.0e+00 -#> stepsize__ 0.77 0.038 0.054 0.73 0.77 0.86 2.0 3.3 1.9e+13 -#> treedepth__ 2.3 0.10 0.51 2.0 2.0 3.0 26 42 1.1e+00 -#> n_leapfrog__ 4.9 0.35 2.0 3.0 3.0 7.0 34 55 1.0e+00 -#> divergent__ 0.00 nan 0.00 0.00 0.00 0.00 nan nan nan -#> energy__ 68 0.049 2.0 65 68 72 1652 2704 1.0e+00 +#> lp__ -6.6e+01 3.1e-02 1.4 1.2 -69 -6.6e+01 -6.4e+01 2077 2863 1.0 +#> accept_stat__ 0.91 1.4e-03 0.10 0.072 0.71 0.95 1.0 5781 4282 1.0 +#> stepsize__ 0.72 nan 0.040 0.039 0.66 0.73 0.77 nan nan nan +#> treedepth__ 2.4 1.5e-02 0.53 0.00 2.0 2.0 3.0 1630 1360 1.0 +#> n_leapfrog__ 5.3 9.5e-02 2.0 0.00 3.0 7.0 7.0 3307 884 1.0 +#> divergent__ 0.00 nan 0.00 0.00 0.00 0.00 0.00 nan nan nan +#> energy__ 68 4.7e-02 2.0 1.8 65 68 72 1774 2711 1.0 #> -#> alpha 3.8e-01 3.5e-03 0.22 0.023 3.8e-01 7.4e-01 3919 6414 1.0 -#> beta[1] -6.7e-01 3.8e-03 0.25 -1.1 -6.7e-01 -2.6e-01 4387 7180 1.0 -#> beta[2] -2.7e-01 3.5e-03 0.23 -0.64 -2.7e-01 1.1e-01 4209 6889 1.00 -#> beta[3] 6.8e-01 4.3e-03 0.26 0.25 6.7e-01 1.1e+00 3682 6026 1.00 -#> log_lik[1] -5.1e-01 1.5e-03 0.099 -0.69 -5.1e-01 -3.6e-01 4109 6725 1.0 -#> log_lik[2] -4.0e-01 2.2e-03 0.15 -0.67 -3.8e-01 -2.0e-01 4736 7751 1.0 -#> log_lik[3] -5.0e-01 3.4e-03 0.22 -0.90 -4.6e-01 -2.0e-01 4043 6617 1.0 -#> log_lik[4] -4.5e-01 2.4e-03 0.15 -0.73 -4.3e-01 -2.4e-01 3941 6450 1.0 -#> log_lik[5] -1.2e+00 4.5e-03 0.28 -1.7 -1.2e+00 -7.7e-01 3844 6291 1.00 -#> log_lik[6] -5.9e-01 2.9e-03 0.19 -0.93 -5.7e-01 -3.2e-01 4123 6748 1.00 -#> log_lik[7] -6.4e-01 1.9e-03 0.13 -0.87 -6.3e-01 -4.5e-01 4625 7569 1.0 -#> log_lik[8] -2.8e-01 2.1e-03 0.13 -0.53 -2.5e-01 -1.1e-01 3984 6520 1.00 -#> log_lik[9] -6.9e-01 2.6e-03 0.17 -0.99 -6.8e-01 -4.4e-01 4294 7028 1.0 -#> log_lik[10] -7.4e-01 3.7e-03 0.23 -1.2 -7.1e-01 -4.0e-01 3964 6488 1.0 -#> log_lik[11] -2.8e-01 2.1e-03 0.12 -0.51 -2.6e-01 -1.2e-01 3501 5729 1.00 -#> log_lik[12] -5.0e-01 3.5e-03 0.23 -0.93 -4.6e-01 -1.9e-01 4348 7116 1.0 -#> log_lik[13] -6.6e-01 3.2e-03 0.21 -1.0 -6.3e-01 -3.5e-01 4224 6914 1.00 -#> log_lik[14] -3.6e-01 2.7e-03 0.17 -0.68 -3.3e-01 -1.3e-01 4013 6568 1.0 -#> log_lik[15] -2.8e-01 1.8e-03 0.11 -0.47 -2.6e-01 -1.3e-01 3538 5790 1.00 -#> log_lik[16] -2.8e-01 1.4e-03 0.086 -0.43 -2.7e-01 -1.5e-01 3558 5822 1.00 -#> log_lik[17] -1.6e+00 4.8e-03 0.29 -2.1 -1.6e+00 -1.2e+00 3654 5981 1.0 -#> log_lik[18] -4.8e-01 1.6e-03 0.11 -0.67 -4.7e-01 -3.1e-01 4457 7294 1.00 -#> log_lik[19] -2.3e-01 1.2e-03 0.075 -0.37 -2.3e-01 -1.2e-01 3731 6107 1.00 -#> log_lik[20] -1.1e-01 1.4e-03 0.080 -0.26 -9.3e-02 -2.7e-02 3471 5681 1.0 -#> log_lik[21] -2.1e-01 1.5e-03 0.086 -0.37 -2.0e-01 -9.3e-02 3393 5554 1.00 -#> log_lik[22] -5.7e-01 2.3e-03 0.15 -0.83 -5.6e-01 -3.5e-01 4157 6803 1.00 -#> log_lik[23] -3.3e-01 2.1e-03 0.14 -0.60 -3.1e-01 -1.4e-01 4351 7120 1.00 -#> log_lik[24] -1.4e-01 1.1e-03 0.066 -0.26 -1.2e-01 -5.2e-02 3635 5949 1.00 -#> log_lik[25] -4.6e-01 1.8e-03 0.12 -0.68 -4.5e-01 -2.8e-01 4638 7591 1.0 -#> log_lik[26] -1.5e+00 5.1e-03 0.34 -2.1 -1.5e+00 -1.0e+00 4383 7173 1.00 -#> log_lik[27] -3.1e-01 2.0e-03 0.12 -0.52 -2.9e-01 -1.4e-01 3553 5815 1.00 -#> log_lik[28] -4.4e-01 1.3e-03 0.083 -0.59 -4.4e-01 -3.2e-01 4086 6688 1.0 -#> log_lik[29] -7.3e-01 3.4e-03 0.23 -1.1 -7.0e-01 -3.9e-01 4476 7326 1.00 -#> log_lik[30] -6.9e-01 2.9e-03 0.19 -1.0 -6.8e-01 -4.1e-01 4511 7383 1.0 -#> log_lik[31] -4.9e-01 2.6e-03 0.16 -0.78 -4.7e-01 -2.6e-01 3899 6381 1.00 -#> log_lik[32] -4.2e-01 1.8e-03 0.11 -0.61 -4.1e-01 -2.7e-01 3671 6009 1.00 -#> log_lik[33] -4.1e-01 1.9e-03 0.13 -0.65 -4.0e-01 -2.3e-01 4622 7564 1.0 -#> log_lik[34] -6.4e-02 8.5e-04 0.050 -0.16 -5.0e-02 -1.3e-02 3474 5686 1.00 -#> log_lik[35] -5.9e-01 2.6e-03 0.18 -0.92 -5.7e-01 -3.2e-01 4937 8080 1.00 -#> log_lik[36] -3.2e-01 1.9e-03 0.13 -0.57 -3.1e-01 -1.5e-01 4737 7753 1.00 -#> log_lik[37] -7.0e-01 3.5e-03 0.23 -1.1 -6.7e-01 -3.7e-01 4158 6805 1.0 -#> log_lik[38] -3.1e-01 2.4e-03 0.15 -0.60 -2.9e-01 -1.2e-01 4035 6604 1.00 -#> log_lik[39] -1.8e-01 1.8e-03 0.11 -0.39 -1.5e-01 -5.2e-02 3644 5964 1.0 -#> log_lik[40] -6.8e-01 1.9e-03 0.13 -0.91 -6.7e-01 -4.8e-01 4470 7316 1.0 -#> log_lik[41] -1.1e+00 4.1e-03 0.25 -1.6 -1.1e+00 -7.6e-01 3765 6162 1.00 -#> log_lik[42] -9.3e-01 3.0e-03 0.20 -1.3 -9.1e-01 -6.3e-01 4354 7127 1.0 -#> log_lik[43] -4.1e-01 3.7e-03 0.26 -0.91 -3.5e-01 -1.0e-01 4788 7836 1.00 -#> log_lik[44] -1.2e+00 3.1e-03 0.19 -1.5 -1.2e+00 -8.9e-01 3623 5929 1.0 -#> log_lik[45] -3.6e-01 1.8e-03 0.12 -0.57 -3.4e-01 -1.9e-01 4021 6581 1.0 -#> log_lik[46] -5.8e-01 1.9e-03 0.13 -0.81 -5.7e-01 -3.9e-01 4786 7833 1.0 -#> log_lik[47] -3.1e-01 2.0e-03 0.13 -0.55 -2.9e-01 -1.4e-01 4246 6949 1.0 -#> log_lik[48] -3.2e-01 1.3e-03 0.082 -0.47 -3.2e-01 -2.0e-01 4166 6819 1.00 -#> log_lik[49] -3.2e-01 1.3e-03 0.079 -0.46 -3.1e-01 -2.0e-01 3546 5804 1.00 -#> log_lik[50] -1.3e+00 4.9e-03 0.33 -1.9 -1.3e+00 -8.0e-01 4492 7352 1.00 -#> log_lik[51] -2.9e-01 1.4e-03 0.093 -0.46 -2.8e-01 -1.6e-01 4451 7284 1.00 -#> log_lik[52] -8.4e-01 2.2e-03 0.14 -1.1 -8.3e-01 -6.2e-01 4245 6948 1.0 -#> log_lik[53] -4.0e-01 2.1e-03 0.13 -0.63 -3.9e-01 -2.2e-01 3748 6134 1.00 -#> log_lik[54] -3.7e-01 2.2e-03 0.14 -0.63 -3.5e-01 -1.7e-01 4130 6759 1.0 -#> log_lik[55] -3.9e-01 2.0e-03 0.14 -0.64 -3.7e-01 -2.0e-01 4649 7608 1.0 -#> log_lik[56] -3.2e-01 2.8e-03 0.19 -0.69 -2.8e-01 -9.5e-02 4610 7546 1.00 -#> log_lik[57] -6.6e-01 1.8e-03 0.12 -0.86 -6.5e-01 -4.7e-01 4203 6879 1.0 -#> log_lik[58] -9.5e-01 5.3e-03 0.36 -1.6 -9.0e-01 -4.4e-01 4498 7362 1.00 -#> log_lik[59] -1.4e+00 5.4e-03 0.34 -2.0 -1.3e+00 -8.4e-01 4097 6706 1.0 -#> log_lik[60] -9.8e-01 2.5e-03 0.16 -1.3 -9.7e-01 -7.3e-01 4050 6628 1.0 -#> log_lik[61] -5.4e-01 1.5e-03 0.098 -0.71 -5.3e-01 -3.9e-01 4382 7171 1.0 -#> log_lik[62] -8.8e-01 4.7e-03 0.31 -1.4 -8.4e-01 -4.4e-01 4166 6818 1.00 -#> log_lik[63] -1.2e-01 1.2e-03 0.072 -0.25 -1.0e-01 -3.2e-02 3346 5477 1.00 -#> log_lik[64] -9.0e-01 3.7e-03 0.25 -1.4 -8.8e-01 -5.3e-01 4389 7183 1.00 -#> log_lik[65] -2.0e+00 9.9e-03 0.58 -3.0 -2.0e+00 -1.1e+00 3440 5629 1.00 -#> log_lik[66] -5.1e-01 2.2e-03 0.14 -0.75 -5.0e-01 -3.1e-01 3804 6226 1.00 -#> log_lik[67] -2.8e-01 1.3e-03 0.081 -0.42 -2.7e-01 -1.6e-01 4007 6558 1.00 -#> log_lik[68] -1.1e+00 3.7e-03 0.24 -1.5 -1.0e+00 -7.0e-01 4155 6800 1.00 -#> log_lik[69] -4.3e-01 1.4e-03 0.084 -0.58 -4.3e-01 -3.1e-01 3753 6142 1.00 -#> log_lik[70] -6.4e-01 3.5e-03 0.24 -1.1 -6.1e-01 -3.1e-01 4500 7365 1.00 -#> log_lik[71] -6.1e-01 3.0e-03 0.21 -0.99 -5.8e-01 -3.1e-01 4571 7481 1.00 -#> log_lik[72] -4.6e-01 2.6e-03 0.17 -0.78 -4.4e-01 -2.2e-01 4261 6974 1.00 -#> log_lik[73] -1.5e+00 5.8e-03 0.37 -2.1 -1.5e+00 -9.2e-01 4023 6585 1.0 -#> log_lik[74] -9.5e-01 3.1e-03 0.20 -1.3 -9.4e-01 -6.5e-01 4106 6721 1.00 -#> log_lik[75] -1.1e+00 5.9e-03 0.38 -1.9 -1.1e+00 -5.9e-01 4198 6870 1.00 -#> log_lik[76] -3.7e-01 2.2e-03 0.14 -0.63 -3.5e-01 -1.8e-01 3982 6517 1.0 -#> log_lik[77] -8.8e-01 2.2e-03 0.14 -1.1 -8.7e-01 -6.6e-01 4043 6618 1.0 -#> log_lik[78] -4.8e-01 2.5e-03 0.17 -0.79 -4.6e-01 -2.5e-01 4533 7418 1.00 -#> log_lik[79] -7.6e-01 3.0e-03 0.19 -1.1 -7.5e-01 -4.8e-01 4054 6635 1.0 -#> log_lik[80] -5.4e-01 2.8e-03 0.19 -0.89 -5.2e-01 -2.7e-01 4782 7827 1.0 -#> log_lik[81] -1.6e-01 1.6e-03 0.10 -0.37 -1.4e-01 -4.9e-02 4161 6810 1.0 -#> log_lik[82] -2.2e-01 2.1e-03 0.14 -0.49 -1.9e-01 -6.5e-02 4340 7103 1.0 -#> log_lik[83] -3.4e-01 1.3e-03 0.081 -0.48 -3.4e-01 -2.2e-01 3663 5996 1.0 -#> log_lik[84] -2.7e-01 1.5e-03 0.092 -0.44 -2.6e-01 -1.5e-01 3524 5767 1.00 -#> log_lik[85] -1.3e-01 1.3e-03 0.076 -0.28 -1.1e-01 -4.1e-02 3532 5780 1.0 -#> log_lik[86] -1.1e+00 4.8e-03 0.32 -1.7 -1.1e+00 -6.6e-01 4283 7011 1.0 -#> log_lik[87] -8.2e-01 1.9e-03 0.13 -1.0 -8.2e-01 -6.3e-01 4347 7115 1.0 -#> log_lik[88] -7.8e-01 3.7e-03 0.24 -1.2 -7.5e-01 -4.3e-01 4170 6825 1.00 -#> log_lik[89] -1.3e+00 5.0e-03 0.32 -1.8 -1.2e+00 -7.9e-01 4012 6566 1.0 -#> log_lik[90] -2.6e-01 2.1e-03 0.14 -0.53 -2.4e-01 -9.3e-02 4313 7058 1.00 -#> log_lik[91] -3.9e-01 1.9e-03 0.13 -0.63 -3.7e-01 -2.1e-01 4620 7562 1.0 -#> log_lik[92] -1.5e+00 5.7e-03 0.34 -2.1 -1.5e+00 -9.8e-01 3518 5758 1.00 -#> log_lik[93] -7.4e-01 3.5e-03 0.22 -1.1 -7.2e-01 -4.2e-01 3871 6336 1.00 -#> log_lik[94] -3.2e-01 1.4e-03 0.088 -0.48 -3.1e-01 -1.9e-01 3732 6107 1.0 -#> log_lik[95] -3.9e-01 1.8e-03 0.11 -0.58 -3.8e-01 -2.3e-01 3830 6269 1.00 -#> log_lik[96] -1.6e+00 4.8e-03 0.28 -2.1 -1.6e+00 -1.1e+00 3457 5657 1.0 -#> log_lik[97] -4.3e-01 1.5e-03 0.10 -0.61 -4.2e-01 -2.8e-01 4740 7758 1.00 -#> log_lik[98] -1.0e+00 5.5e-03 0.37 -1.7 -1.0e+00 -5.1e-01 4582 7499 1.00 -#> log_lik[99] -6.9e-01 2.1e-03 0.14 -0.95 -6.8e-01 -4.8e-01 4565 7472 1.0 -#> log_lik[100] -3.9e-01 1.5e-03 0.096 -0.56 -3.8e-01 -2.5e-01 4243 6945 1.0 +#> alpha 3.7e-01 3.4e-03 0.22 0.22 0.028 3.7e-01 7.3e-01 4093 2683 1.0 +#> beta[1] -6.6e-01 3.9e-03 0.25 0.25 -1.1 -6.6e-01 -2.6e-01 4257 3329 1.0 +#> beta[2] -2.7e-01 3.6e-03 0.22 0.23 -0.64 -2.6e-01 9.8e-02 3945 3224 1.0 +#> beta[3] 6.7e-01 4.3e-03 0.27 0.27 0.25 6.6e-01 1.1e+00 3898 2767 1.00 +#> log_lik[1] -5.2e-01 1.5e-03 0.098 0.098 -0.69 -5.1e-01 -3.7e-01 4210 2902 1.0 +#> log_lik[2] -4.0e-01 2.2e-03 0.14 0.14 -0.67 -3.9e-01 -2.0e-01 4291 2935 1.0 +#> log_lik[3] -5.0e-01 3.3e-03 0.21 0.20 -0.90 -4.6e-01 -2.1e-01 4240 2834 1.0 +#> log_lik[4] -4.5e-01 2.5e-03 0.16 0.15 -0.73 -4.3e-01 -2.4e-01 3795 3034 1.0 +#> log_lik[5] -1.2e+00 4.4e-03 0.28 0.28 -1.7 -1.2e+00 -7.5e-01 4168 2944 1.0 +#> log_lik[6] -5.9e-01 3.0e-03 0.19 0.19 -0.93 -5.8e-01 -3.3e-01 3850 2768 1.00 +#> log_lik[7] -6.4e-01 1.9e-03 0.13 0.12 -0.87 -6.3e-01 -4.5e-01 4232 3044 1.0 +#> log_lik[8] -2.8e-01 2.2e-03 0.13 0.12 -0.53 -2.6e-01 -1.1e-01 3612 3023 1.0 +#> log_lik[9] -6.9e-01 2.6e-03 0.16 0.16 -0.98 -6.8e-01 -4.5e-01 4078 3164 1.0 +#> log_lik[10] -7.4e-01 3.7e-03 0.23 0.23 -1.2 -7.1e-01 -4.0e-01 4026 2967 1.0 +#> log_lik[11] -2.8e-01 2.1e-03 0.13 0.12 -0.52 -2.6e-01 -1.2e-01 3419 2597 1.0 +#> log_lik[12] -5.0e-01 3.6e-03 0.24 0.22 -0.94 -4.7e-01 -1.9e-01 4359 3260 1.0 +#> log_lik[13] -6.5e-01 3.3e-03 0.21 0.21 -1.0 -6.3e-01 -3.6e-01 4071 2663 1.0 +#> log_lik[14] -3.6e-01 2.7e-03 0.17 0.16 -0.68 -3.3e-01 -1.4e-01 4196 2966 1.0 +#> log_lik[15] -2.8e-01 1.7e-03 0.11 0.10 -0.47 -2.6e-01 -1.4e-01 4062 2457 1.0 +#> log_lik[16] -2.8e-01 1.5e-03 0.087 0.085 -0.44 -2.7e-01 -1.5e-01 3304 2815 1.0 +#> log_lik[17] -1.6e+00 4.8e-03 0.29 0.29 -2.1 -1.6e+00 -1.1e+00 3624 2964 1.0 +#> log_lik[18] -4.8e-01 1.7e-03 0.10 0.10 -0.66 -4.8e-01 -3.2e-01 3932 2824 1.0 +#> log_lik[19] -2.4e-01 1.3e-03 0.075 0.074 -0.37 -2.3e-01 -1.3e-01 3554 3085 1.0 +#> log_lik[20] -1.1e-01 1.3e-03 0.079 0.061 -0.27 -9.5e-02 -3.0e-02 4170 3008 1.0 +#> log_lik[21] -2.2e-01 1.5e-03 0.089 0.084 -0.38 -2.0e-01 -9.7e-02 3302 2740 1.0 +#> log_lik[22] -5.7e-01 2.4e-03 0.14 0.14 -0.83 -5.6e-01 -3.6e-01 3779 3160 1.0 +#> log_lik[23] -3.3e-01 2.2e-03 0.14 0.13 -0.58 -3.1e-01 -1.5e-01 3934 3316 1.0 +#> log_lik[24] -1.4e-01 1.1e-03 0.067 0.061 -0.27 -1.3e-01 -5.4e-02 3656 3128 1.0 +#> log_lik[25] -4.6e-01 1.9e-03 0.12 0.12 -0.68 -4.4e-01 -2.8e-01 4029 2992 1.0 +#> log_lik[26] -1.5e+00 5.2e-03 0.34 0.33 -2.1 -1.5e+00 -9.9e-01 4325 3387 1.0 +#> log_lik[27] -3.1e-01 2.1e-03 0.12 0.12 -0.54 -2.9e-01 -1.5e-01 3375 2563 1.0 +#> log_lik[28] -4.5e-01 1.3e-03 0.082 0.082 -0.59 -4.4e-01 -3.2e-01 3776 2975 1.0 +#> log_lik[29] -7.3e-01 3.3e-03 0.23 0.23 -1.1 -7.0e-01 -3.9e-01 4688 3192 1.0 +#> log_lik[30] -7.0e-01 2.9e-03 0.18 0.18 -1.0 -6.8e-01 -4.2e-01 4197 3162 1.0 +#> log_lik[31] -4.9e-01 2.7e-03 0.16 0.16 -0.79 -4.7e-01 -2.6e-01 3604 2908 1.0 +#> log_lik[32] -4.3e-01 1.7e-03 0.11 0.11 -0.62 -4.2e-01 -2.7e-01 3793 2685 1.0 +#> log_lik[33] -4.1e-01 2.0e-03 0.13 0.12 -0.65 -3.9e-01 -2.3e-01 4149 2968 1.0 +#> log_lik[34] -6.6e-02 8.7e-04 0.052 0.038 -0.16 -5.2e-02 -1.3e-02 3571 2878 1.0 +#> log_lik[35] -5.9e-01 2.8e-03 0.19 0.19 -0.92 -5.6e-01 -3.2e-01 4485 3033 1.0 +#> log_lik[36] -3.3e-01 2.0e-03 0.13 0.12 -0.56 -3.1e-01 -1.5e-01 4361 3167 1.00 +#> log_lik[37] -7.0e-01 3.4e-03 0.23 0.22 -1.1 -6.7e-01 -3.7e-01 4430 3268 1.0 +#> log_lik[38] -3.2e-01 2.5e-03 0.15 0.14 -0.61 -2.9e-01 -1.2e-01 3889 3062 1.0 +#> log_lik[39] -1.8e-01 1.7e-03 0.11 0.089 -0.38 -1.6e-01 -5.5e-02 4256 2773 1.0 +#> log_lik[40] -6.8e-01 2.0e-03 0.12 0.12 -0.90 -6.7e-01 -4.9e-01 4119 3108 1.0 +#> log_lik[41] -1.1e+00 4.3e-03 0.25 0.25 -1.6 -1.1e+00 -7.5e-01 3475 2646 1.0 +#> log_lik[42] -9.3e-01 3.0e-03 0.19 0.19 -1.3 -9.2e-01 -6.3e-01 4203 3085 1.0 +#> log_lik[43] -4.1e-01 3.9e-03 0.26 0.22 -0.91 -3.5e-01 -1.1e-01 4971 3223 1.00 +#> log_lik[44] -1.2e+00 2.9e-03 0.18 0.18 -1.5 -1.2e+00 -8.9e-01 3992 2815 1.0 +#> log_lik[45] -3.6e-01 1.8e-03 0.12 0.11 -0.57 -3.4e-01 -1.9e-01 4297 3077 1.00 +#> log_lik[46] -5.8e-01 1.9e-03 0.13 0.12 -0.81 -5.7e-01 -3.9e-01 4228 3113 1.0 +#> log_lik[47] -3.1e-01 2.1e-03 0.13 0.12 -0.55 -2.9e-01 -1.4e-01 3831 2919 1.0 +#> log_lik[48] -3.3e-01 1.3e-03 0.082 0.081 -0.47 -3.2e-01 -2.1e-01 3891 3283 1.0 +#> log_lik[49] -3.2e-01 1.3e-03 0.079 0.078 -0.46 -3.2e-01 -2.0e-01 3475 2682 1.0 +#> log_lik[50] -1.3e+00 4.9e-03 0.32 0.32 -1.8 -1.3e+00 -7.9e-01 4610 3388 1.0 +#> log_lik[51] -2.9e-01 1.4e-03 0.093 0.090 -0.46 -2.8e-01 -1.6e-01 4207 3215 1.0 +#> log_lik[52] -8.3e-01 2.2e-03 0.14 0.14 -1.1 -8.3e-01 -6.1e-01 4205 3039 1.0 +#> log_lik[53] -4.1e-01 2.2e-03 0.13 0.12 -0.64 -3.9e-01 -2.2e-01 3463 2821 1.0 +#> log_lik[54] -3.7e-01 2.2e-03 0.14 0.13 -0.63 -3.5e-01 -1.8e-01 4357 3109 1.00 +#> log_lik[55] -3.9e-01 2.1e-03 0.13 0.13 -0.63 -3.7e-01 -2.0e-01 4184 2870 1.0 +#> log_lik[56] -3.2e-01 2.8e-03 0.19 0.17 -0.67 -2.8e-01 -9.4e-02 4725 2892 1.0 +#> log_lik[57] -6.6e-01 1.8e-03 0.12 0.12 -0.86 -6.5e-01 -4.8e-01 4204 3006 1.0 +#> log_lik[58] -9.5e-01 5.4e-03 0.36 0.35 -1.6 -9.0e-01 -4.5e-01 4724 2916 1.0 +#> log_lik[59] -1.4e+00 5.4e-03 0.34 0.33 -2.0 -1.3e+00 -8.4e-01 4126 2944 1.0 +#> log_lik[60] -9.8e-01 2.4e-03 0.16 0.16 -1.3 -9.7e-01 -7.3e-01 4237 3028 1.0 +#> log_lik[61] -5.4e-01 1.5e-03 0.097 0.096 -0.71 -5.4e-01 -3.9e-01 4260 3064 1.0 +#> log_lik[62] -8.8e-01 4.8e-03 0.31 0.31 -1.4 -8.5e-01 -4.4e-01 4420 3420 1.0 +#> log_lik[63] -1.2e-01 1.3e-03 0.075 0.063 -0.26 -1.0e-01 -3.4e-02 3288 2867 1.0 +#> log_lik[64] -9.0e-01 3.6e-03 0.24 0.23 -1.3 -8.7e-01 -5.5e-01 4286 3272 1.0 +#> log_lik[65] -2.0e+00 1.0e-02 0.59 0.61 -3.0 -2.0e+00 -1.1e+00 3390 2645 1.0 +#> log_lik[66] -5.1e-01 2.1e-03 0.14 0.13 -0.75 -5.0e-01 -3.1e-01 4289 2934 1.0 +#> log_lik[67] -2.8e-01 1.3e-03 0.081 0.080 -0.42 -2.7e-01 -1.6e-01 3650 3029 1.0 +#> log_lik[68] -1.1e+00 3.7e-03 0.23 0.22 -1.5 -1.0e+00 -7.1e-01 3844 3244 1.0 +#> log_lik[69] -4.4e-01 1.4e-03 0.083 0.084 -0.58 -4.3e-01 -3.1e-01 3763 2707 1.0 +#> log_lik[70] -6.4e-01 3.4e-03 0.23 0.21 -1.1 -6.1e-01 -3.2e-01 4692 3113 1.0 +#> log_lik[71] -6.1e-01 3.3e-03 0.21 0.21 -0.99 -5.8e-01 -3.1e-01 4276 3089 1.0 +#> log_lik[72] -4.6e-01 2.6e-03 0.17 0.16 -0.78 -4.4e-01 -2.3e-01 4326 3218 1.0 +#> log_lik[73] -1.5e+00 6.0e-03 0.37 0.37 -2.1 -1.4e+00 -9.1e-01 3893 3087 1.0 +#> log_lik[74] -9.5e-01 2.9e-03 0.19 0.20 -1.3 -9.3e-01 -6.5e-01 4399 2879 1.0 +#> log_lik[75] -1.1e+00 5.8e-03 0.38 0.38 -1.8 -1.1e+00 -5.8e-01 4471 3388 1.0 +#> log_lik[76] -3.7e-01 2.1e-03 0.14 0.13 -0.62 -3.5e-01 -1.8e-01 4223 2860 1.00 +#> log_lik[77] -8.8e-01 2.2e-03 0.14 0.14 -1.1 -8.7e-01 -6.7e-01 3901 2655 1.0 +#> log_lik[78] -4.9e-01 2.6e-03 0.17 0.16 -0.80 -4.6e-01 -2.5e-01 4623 3544 1.00 +#> log_lik[79] -7.6e-01 3.0e-03 0.19 0.19 -1.1 -7.5e-01 -4.8e-01 4156 3125 1.0 +#> log_lik[80] -5.4e-01 2.8e-03 0.19 0.18 -0.88 -5.2e-01 -2.7e-01 4708 3185 1.0 +#> log_lik[81] -1.7e-01 1.7e-03 0.10 0.084 -0.37 -1.4e-01 -4.9e-02 4002 3125 1.0 +#> log_lik[82] -2.2e-01 2.1e-03 0.14 0.11 -0.48 -1.9e-01 -6.6e-02 4234 2703 1.0 +#> log_lik[83] -3.5e-01 1.3e-03 0.080 0.079 -0.49 -3.4e-01 -2.2e-01 3872 2864 1.00 +#> log_lik[84] -2.8e-01 1.5e-03 0.091 0.087 -0.44 -2.7e-01 -1.5e-01 4033 2778 1.0 +#> log_lik[85] -1.3e-01 1.2e-03 0.075 0.063 -0.28 -1.2e-01 -4.3e-02 4008 3071 1.0 +#> log_lik[86] -1.1e+00 4.8e-03 0.31 0.30 -1.7 -1.1e+00 -6.7e-01 4424 2829 1.0 +#> log_lik[87] -8.2e-01 1.9e-03 0.13 0.12 -1.0 -8.1e-01 -6.3e-01 4199 3091 1.0 +#> log_lik[88] -7.7e-01 3.9e-03 0.24 0.24 -1.2 -7.4e-01 -4.3e-01 3979 2725 1.00 +#> log_lik[89] -1.3e+00 5.0e-03 0.32 0.31 -1.8 -1.2e+00 -8.0e-01 4105 2643 1.0 +#> log_lik[90] -2.7e-01 2.2e-03 0.14 0.12 -0.54 -2.4e-01 -9.4e-02 4059 3128 1.0 +#> log_lik[91] -3.9e-01 2.0e-03 0.13 0.12 -0.63 -3.7e-01 -2.0e-01 4231 3276 1.0 +#> log_lik[92] -1.5e+00 5.5e-03 0.34 0.34 -2.1 -1.5e+00 -9.7e-01 3905 2575 1.0 +#> log_lik[93] -7.4e-01 3.5e-03 0.22 0.22 -1.1 -7.2e-01 -4.2e-01 3995 2990 1.0 +#> log_lik[94] -3.2e-01 1.4e-03 0.087 0.084 -0.48 -3.1e-01 -1.9e-01 4054 2800 1.00 +#> log_lik[95] -3.9e-01 1.9e-03 0.11 0.11 -0.59 -3.8e-01 -2.3e-01 3454 2901 1.0 +#> log_lik[96] -1.6e+00 4.6e-03 0.28 0.28 -2.1 -1.5e+00 -1.1e+00 3721 3096 1.0 +#> log_lik[97] -4.3e-01 1.5e-03 0.098 0.095 -0.60 -4.2e-01 -2.8e-01 4401 3224 1.0 +#> log_lik[98] -1.0e+00 5.7e-03 0.38 0.37 -1.7 -1.0e+00 -5.2e-01 4630 2912 1.0 +#> log_lik[99] -6.9e-01 2.1e-03 0.14 0.13 -0.94 -6.8e-01 -4.8e-01 4146 3139 1.0 +#> log_lik[100] -3.9e-01 1.5e-03 0.096 0.096 -0.56 -3.8e-01 -2.5e-01 4330 2963 1.0 #> #> Samples were drawn using hmc with nuts. -#> For each parameter, N_Eff is a crude measure of effective sample size, -#> and R_hat is the potential scale reduction factor on split chains (at -#> convergence, R_hat=1). +#> For each parameter, ESS_bulk and ESS_tail measure the effective sample size for the entire sample (bulk) and for the .05 and .95 tails (tail), +#> and R_hat measures the potential scale reduction on split chains. At convergence R_hat will be very close to 1.00. # }See also
Examples
@@ -203,7 +203,7 @@# \dontrun{ fit <- cmdstanr_example("schools") -#> Warning: 235 of 4000 (6.0%) transitions ended with a divergence. +#> Warning: 191 of 4000 (5.0%) transitions ended with a divergence. #> See https://mc-stan.org/misc/warnings for details. #> Warning: 2 of 4 chains had an E-BFMI less than 0.3. #> See https://mc-stan.org/misc/warnings for details. fit$diagnostic_summary() -#> Warning: 235 of 4000 (6.0%) transitions ended with a divergence. +#> Warning: 191 of 4000 (5.0%) transitions ended with a divergence. #> See https://mc-stan.org/misc/warnings for details. #> Warning: 2 of 4 chains had an E-BFMI less than 0.3. #> See https://mc-stan.org/misc/warnings for details. #> $num_divergent -#> [1] 104 30 98 3 +#> [1] 23 107 22 39 #> #> $num_max_treedepth #> [1] 0 0 0 0 #> #> $ebfmi -#> [1] 0.4564907 0.4041931 0.2577905 0.2642813 +#> [1] 0.4160269 0.2285873 0.3803260 0.2845859 #> fit$diagnostic_summary(quiet = TRUE) #> $num_divergent -#> [1] 104 30 98 3 +#> [1] 23 107 22 39 #> #> $num_max_treedepth #> [1] 0 0 0 0 #> #> $ebfmi -#> [1] 0.4564907 0.4041931 0.2577905 0.2642813 +#> [1] 0.4160269 0.2285873 0.3803260 0.2845859 #> # } diff --git a/docs/reference/fit-method-draws-1.png b/docs/reference/fit-method-draws-1.png index b241904b2..79a6eb1cf 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 b9abe3988..3248606ab 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 c7816907b..c11a2ea61 100644 --- a/docs/reference/fit-method-draws.html +++ b/docs/reference/fit-method-draws.html @@ -22,7 +22,7 @@Examples
dim(draws) #> [1] 1000 4 105 str(draws) -#> 'draws_array' num [1:1000, 1:4, 1:105] -65 -66.8 -64.9 -66.9 -66.5 ... +#> 'draws_array' num [1:1000, 1:4, 1:105] -64.4 -64.5 -65.8 -66.7 -66 ... #> - attr(*, "dimnames")=List of 3 #> ..$ iteration: chr [1:1000] "1" "2" "3" "4" ... #> ..$ chain : chr [1:4] "1" "2" "3" "4" @@ -214,13 +214,13 @@Examples
head(posterior::as_draws_matrix(draws)) #> # 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 -65 0.363 -0.70 -0.26 1.04 -0.53 -0.24 -0.40 -#> 2 -67 0.522 -0.55 -0.61 1.18 -0.54 -0.30 -0.65 -#> 3 -65 0.607 -0.57 -0.41 0.82 -0.46 -0.44 -0.49 -#> 4 -67 -0.012 -0.52 -0.11 0.25 -0.65 -0.44 -0.59 -#> 5 -67 0.715 -0.77 -0.34 1.14 -0.41 -0.29 -0.32 -#> 6 -65 0.473 -0.42 -0.41 0.76 -0.52 -0.45 -0.60 +#> draw lp__ alpha beta[1] beta[2] beta[3] log_lik[1] log_lik[2] log_lik[3] +#> 1 -64 0.37 -0.73 -0.28 0.46 -0.49 -0.47 -0.49 +#> 2 -65 0.37 -0.54 -0.24 0.89 -0.54 -0.31 -0.44 +#> 3 -66 0.44 -1.06 -0.43 0.84 -0.46 -0.30 -0.44 +#> 4 -67 0.49 -0.81 0.15 0.92 -0.42 -0.24 -0.16 +#> 5 -66 0.34 -0.51 -0.53 0.30 -0.55 -0.67 -0.87 +#> 6 -66 0.38 -0.42 -0.44 0.34 -0.54 -0.66 -0.76 #> # ... with 97 more variables # or can specify 'format' argument to avoid manual conversion @@ -229,13 +229,13 @@Examples
head(draws) #> # 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 -65 0.363 -0.70 -0.26 1.04 -0.53 -0.24 -0.40 -#> 2 -67 0.522 -0.55 -0.61 1.18 -0.54 -0.30 -0.65 -#> 3 -65 0.607 -0.57 -0.41 0.82 -0.46 -0.44 -0.49 -#> 4 -67 -0.012 -0.52 -0.11 0.25 -0.65 -0.44 -0.59 -#> 5 -67 0.715 -0.77 -0.34 1.14 -0.41 -0.29 -0.32 -#> 6 -65 0.473 -0.42 -0.41 0.76 -0.52 -0.45 -0.60 +#> draw lp__ alpha beta[1] beta[2] beta[3] log_lik[1] log_lik[2] log_lik[3] +#> 1 -64 0.37 -0.73 -0.28 0.46 -0.49 -0.47 -0.49 +#> 2 -65 0.37 -0.54 -0.24 0.89 -0.54 -0.31 -0.44 +#> 3 -66 0.44 -1.06 -0.43 0.84 -0.46 -0.30 -0.44 +#> 4 -67 0.49 -0.81 0.15 0.92 -0.42 -0.24 -0.16 +#> 5 -66 0.34 -0.51 -0.53 0.30 -0.55 -0.67 -0.87 +#> 6 -66 0.38 -0.42 -0.44 0.34 -0.54 -0.66 -0.76 #> # ... with 97 more variables # can select specific parameters @@ -244,12 +244,12 @@Examples
#> , , variable = alpha #> #> chain -#> iteration 1 2 3 4 -#> 1 0.363 0.52 0.50 -0.0071 -#> 2 0.522 0.50 0.46 0.3258 -#> 3 0.607 0.19 0.25 0.2788 -#> 4 -0.012 0.13 0.41 0.2299 -#> 5 0.715 0.48 0.40 0.6308 +#> iteration 1 2 3 4 +#> 1 0.37 0.152 0.089 0.26 +#> 2 0.37 0.301 0.658 0.22 +#> 3 0.44 0.685 0.554 0.52 +#> 4 0.49 0.049 0.734 0.51 +#> 5 0.34 0.171 0.797 0.22 #> #> # ... with 995 more iterations fit$draws("beta") # selects entire vector beta @@ -258,31 +258,31 @@Examples
#> #> chain #> iteration 1 2 3 4 -#> 1 -0.70 -0.74 -0.87 -0.37 -#> 2 -0.55 -0.71 -0.58 -0.84 -#> 3 -0.57 -0.85 -0.59 -0.37 -#> 4 -0.52 -0.66 -0.60 -0.53 -#> 5 -0.77 -0.40 -0.55 -0.68 +#> 1 -0.73 -0.57 -0.63 -0.95 +#> 2 -0.54 -0.63 -0.67 -0.64 +#> 3 -1.06 -0.85 -1.14 -0.59 +#> 4 -0.81 -0.58 -0.70 -0.67 +#> 5 -0.51 -0.60 -0.68 -1.30 #> #> , , variable = beta[2] #> #> chain -#> iteration 1 2 3 4 -#> 1 -0.26 -0.12 -0.28 -0.474 -#> 2 -0.61 -0.12 -0.51 -0.487 -#> 3 -0.41 -0.10 -0.22 -0.069 -#> 4 -0.11 -0.14 -0.13 -0.094 -#> 5 -0.34 -0.08 -0.58 -0.328 +#> iteration 1 2 3 4 +#> 1 -0.28 -0.615 -0.432 -0.21 +#> 2 -0.24 -0.304 -0.049 -0.14 +#> 3 -0.43 -0.431 -0.395 0.06 +#> 4 0.15 -0.192 -0.265 -0.13 +#> 5 -0.53 -0.018 -0.289 -0.19 #> #> , , variable = beta[3] #> #> chain #> iteration 1 2 3 4 -#> 1 1.04 0.96 0.78 0.75 -#> 2 1.18 0.90 0.40 0.81 -#> 3 0.82 0.29 1.27 0.64 -#> 4 0.25 0.45 0.97 0.64 -#> 5 1.14 0.18 0.54 0.66 +#> 1 0.46 0.87 0.53 0.50 +#> 2 0.89 0.84 0.89 0.22 +#> 3 0.84 0.83 0.47 0.35 +#> 4 0.92 0.71 1.36 0.67 +#> 5 0.30 0.42 1.40 0.59 #> #> # ... 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.363 0.52 0.50 -0.0071 -#> 2 0.522 0.50 0.46 0.3258 -#> 3 0.607 0.19 0.25 0.2788 -#> 4 -0.012 0.13 0.41 0.2299 -#> 5 0.715 0.48 0.40 0.6308 +#> iteration 1 2 3 4 +#> 1 0.37 0.152 0.089 0.26 +#> 2 0.37 0.301 0.658 0.22 +#> 3 0.44 0.685 0.554 0.52 +#> 4 0.49 0.049 0.734 0.51 +#> 5 0.34 0.171 0.797 0.22 #> #> , , variable = beta[2] #> #> chain -#> iteration 1 2 3 4 -#> 1 -0.26 -0.12 -0.28 -0.474 -#> 2 -0.61 -0.12 -0.51 -0.487 -#> 3 -0.41 -0.10 -0.22 -0.069 -#> 4 -0.11 -0.14 -0.13 -0.094 -#> 5 -0.34 -0.08 -0.58 -0.328 +#> iteration 1 2 3 4 +#> 1 -0.28 -0.615 -0.432 -0.21 +#> 2 -0.24 -0.304 -0.049 -0.14 +#> 3 -0.43 -0.431 -0.395 0.06 +#> 4 0.15 -0.192 -0.265 -0.13 +#> 5 -0.53 -0.018 -0.289 -0.19 #> #> # ... 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.80 -0.25 0.98 -#> 2 -0.56 -0.31 0.57 -#> 3 -0.98 -0.35 0.66 -#> 4 -0.67 -0.78 0.49 -#> 5 -0.98 -0.38 0.75 -#> 6 -0.52 -0.52 0.37 +#> 1 -0.70 -0.15 0.690 +#> 2 -0.69 -0.54 0.897 +#> 3 -0.41 -0.67 0.323 +#> 4 -0.93 -0.51 0.460 +#> 5 -0.77 -0.39 0.031 +#> 6 -0.64 -0.16 0.711 head(fit$draws("beta", format = "df")) #> # A draws_df: 6 iterations, 1 chains, and 3 variables #> beta[1] beta[2] beta[3] -#> 1 -0.80 -0.25 0.98 -#> 2 -0.56 -0.31 0.57 -#> 3 -0.98 -0.35 0.66 -#> 4 -0.67 -0.78 0.49 -#> 5 -0.98 -0.38 0.75 -#> 6 -0.52 -0.52 0.37 +#> 1 -0.70 -0.15 0.690 +#> 2 -0.69 -0.54 0.897 +#> 3 -0.41 -0.67 0.323 +#> 4 -0.93 -0.51 0.460 +#> 5 -0.77 -0.39 0.031 +#> 6 -0.64 -0.16 0.711 #> # ... 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 93ab582f4..d301b29fd 100644 --- a/docs/reference/fit-method-grad_log_prob.html +++ b/docs/reference/fit-method-grad_log_prob.html @@ -18,7 +18,7 @@Examples
# retrieve the gradients test$gradients() #> param_idx value model finite_diff error -#> 1 0 -1.816810 37.64170 37.64170 -8.16570e-10 -#> 2 1 0.376746 -18.33100 -18.33100 -3.03892e-08 -#> 3 2 0.477942 -15.36460 -15.36460 -2.99484e-08 -#> 4 3 1.852310 -7.94121 -7.94121 -3.99522e-08 +#> 1 0 -1.956090 42.51440 42.51440 -1.09401e-08 +#> 2 1 -0.130427 -13.33070 -13.33070 -1.40895e-08 +#> 3 2 1.228760 -24.25270 -24.25270 -4.45662e-08 +#> 4 3 0.625050 3.12825 3.12825 -3.33963e-09 # }Examples
str(fit$init()) #> List of 2 #> $ :List of 2 -#> ..$ alpha: num -1.12 -#> ..$ beta : num [1:3] 0.398 0.421 -0.425 +#> ..$ alpha: num -1.19 +#> ..$ beta : num [1:3] -0.0532 0.2552 1.706 #> $ :List of 2 -#> ..$ alpha: num -0.877 -#> ..$ beta : num [1:3] 1.3 -1.34 1.43 +#> ..$ alpha: num 1 +#> ..$ beta : num [1:3] -0.496 0.356 -1.135 # partial inits (only specifying for a subset of parameters) init_list <- list( diff --git a/docs/reference/fit-method-init_model_methods.html b/docs/reference/fit-method-init_model_methods.html index 83a00fb4e..a34a009bd 100644 --- a/docs/reference/fit-method-init_model_methods.html +++ b/docs/reference/fit-method-init_model_methods.html @@ -24,7 +24,7 @@Examples
fit <- cmdstanr_example("logistic") fit$inv_metric() #> $`1` -#> [,1] [,2] [,3] [,4] -#> [1,] 0.041261 0.0000000 0.0000000 0.0000000 -#> [2,] 0.000000 0.0524298 0.0000000 0.0000000 -#> [3,] 0.000000 0.0000000 0.0481435 0.0000000 -#> [4,] 0.000000 0.0000000 0.0000000 0.0732764 +#> [,1] [,2] [,3] [,4] +#> [1,] 0.0399675 0.0000000 0.000000 0.0000000 +#> [2,] 0.0000000 0.0581864 0.000000 0.0000000 +#> [3,] 0.0000000 0.0000000 0.045564 0.0000000 +#> [4,] 0.0000000 0.0000000 0.000000 0.0657117 #> #> $`2` -#> [,1] [,2] [,3] [,4] -#> [1,] 0.0476774 0.0000000 0.000000 0.0000000 -#> [2,] 0.0000000 0.0504326 0.000000 0.0000000 -#> [3,] 0.0000000 0.0000000 0.052821 0.0000000 -#> [4,] 0.0000000 0.0000000 0.000000 0.0711489 +#> [,1] [,2] [,3] [,4] +#> [1,] 0.042812 0.0000000 0.0000000 0.0000000 +#> [2,] 0.000000 0.0677379 0.0000000 0.0000000 +#> [3,] 0.000000 0.0000000 0.0505126 0.0000000 +#> [4,] 0.000000 0.0000000 0.0000000 0.0732512 #> #> $`3` #> [,1] [,2] [,3] [,4] -#> [1,] 0.0465449 0.000000 0.0000000 0.0000000 -#> [2,] 0.0000000 0.058276 0.0000000 0.0000000 -#> [3,] 0.0000000 0.000000 0.0462442 0.0000000 -#> [4,] 0.0000000 0.000000 0.0000000 0.0746648 +#> [1,] 0.0421817 0.000000 0.0000000 0.0000000 +#> [2,] 0.0000000 0.062998 0.0000000 0.0000000 +#> [3,] 0.0000000 0.000000 0.0483093 0.0000000 +#> [4,] 0.0000000 0.000000 0.0000000 0.0806989 #> #> $`4` -#> [,1] [,2] [,3] [,4] -#> [1,] 0.043908 0.0000000 0.000000 0.0000000 -#> [2,] 0.000000 0.0657091 0.000000 0.0000000 -#> [3,] 0.000000 0.0000000 0.048942 0.0000000 -#> [4,] 0.000000 0.0000000 0.000000 0.0632482 +#> [,1] [,2] [,3] [,4] +#> [1,] 0.0458222 0.0000000 0.0000000 0.0000000 +#> [2,] 0.0000000 0.0724218 0.0000000 0.0000000 +#> [3,] 0.0000000 0.0000000 0.0524932 0.0000000 +#> [4,] 0.0000000 0.0000000 0.0000000 0.0726335 #> fit$inv_metric(matrix=FALSE) #> $`1` -#> [1] 0.0412610 0.0524298 0.0481435 0.0732764 +#> [1] 0.0399675 0.0581864 0.0455640 0.0657117 #> #> $`2` -#> [1] 0.0476774 0.0504326 0.0528210 0.0711489 +#> [1] 0.0428120 0.0677379 0.0505126 0.0732512 #> #> $`3` -#> [1] 0.0465449 0.0582760 0.0462442 0.0746648 +#> [1] 0.0421817 0.0629980 0.0483093 0.0806989 #> #> $`4` -#> [1] 0.0439080 0.0657091 0.0489420 0.0632482 +#> [1] 0.0458222 0.0724218 0.0524932 0.0726335 #> fit <- cmdstanr_example("logistic", metric = "dense_e") fit$inv_metric() #> $`1` -#> [,1] [,2] [,3] [,4] -#> [1,] 0.05192450 -0.00808928 0.00233609 0.00537011 -#> [2,] -0.00808928 0.05617200 -0.00192090 -0.00711062 -#> [3,] 0.00233609 -0.00192090 0.04964080 -0.01391690 -#> [4,] 0.00537011 -0.00711062 -0.01391690 0.07126540 +#> [,1] [,2] [,3] [,4] +#> [1,] 0.048423300 0.001823680 0.00659113 -0.000666867 +#> [2,] 0.001823680 0.055877400 -0.00378891 0.000328776 +#> [3,] 0.006591130 -0.003788910 0.04607360 -0.010493400 +#> [4,] -0.000666867 0.000328776 -0.01049340 0.061314400 #> #> $`2` -#> [,1] [,2] [,3] [,4] -#> [1,] 0.044604400 0.000608339 0.00107581 0.00451756 -#> [2,] 0.000608339 0.058117400 -0.01088670 -0.00141863 -#> [3,] 0.001075810 -0.010886700 0.04437890 -0.00650639 -#> [4,] 0.004517560 -0.001418630 -0.00650639 0.06984850 +#> [,1] [,2] [,3] [,4] +#> [1,] 0.055615500 -0.004688890 0.000366103 0.00657168 +#> [2,] -0.004688890 0.070634600 0.000161933 -0.00900785 +#> [3,] 0.000366103 0.000161933 0.043863800 -0.01242910 +#> [4,] 0.006571680 -0.009007850 -0.012429100 0.06169190 #> #> $`3` -#> [,1] [,2] [,3] [,4] -#> [1,] 0.04180740 -0.001275980 0.005750270 0.00305686 -#> [2,] -0.00127598 0.054490900 -0.000483551 -0.00770396 -#> [3,] 0.00575027 -0.000483551 0.044247700 -0.01478120 -#> [4,] 0.00305686 -0.007703960 -0.014781200 0.06501070 +#> [,1] [,2] [,3] [,4] +#> [1,] 0.046092000 0.000277152 -0.000196182 0.00653545 +#> [2,] 0.000277152 0.052935700 -0.001316380 -0.00135849 +#> [3,] -0.000196182 -0.001316380 0.052723400 -0.00738233 +#> [4,] 0.006535450 -0.001358490 -0.007382330 0.06829300 #> #> $`4` -#> [,1] [,2] [,3] [,4] -#> [1,] 4.17467e-02 -0.000269914 4.51726e-05 0.00472656 -#> [2,] -2.69914e-04 0.061160800 -1.36053e-02 -0.00637189 -#> [3,] 4.51726e-05 -0.013605300 4.96363e-02 -0.00759941 -#> [4,] 4.72656e-03 -0.006371890 -7.59941e-03 0.06762740 +#> [,1] [,2] [,3] [,4] +#> [1,] 0.05362400 -0.00182030 0.00998512 -0.00383164 +#> [2,] -0.00182030 0.06051710 0.00414984 -0.01575160 +#> [3,] 0.00998512 0.00414984 0.04282750 -0.01094520 +#> [4,] -0.00383164 -0.01575160 -0.01094520 0.07697140 #> # } diff --git a/docs/reference/fit-method-log_prob.html b/docs/reference/fit-method-log_prob.html index 74b7e2f25..de3159dd8 100644 --- a/docs/reference/fit-method-log_prob.html +++ b/docs/reference/fit-method-log_prob.html @@ -18,7 +18,7 @@Leave-one-out cross-validation (LOO-CV)
@@ -104,19 +108,23 @@Arguments
- variables
-- +
(character vector) The name(s) of the variable(s) in the -Stan program containing the pointwise log-likelihood. The default is to -look for
"log_lik". This argument is passed to the -$draws()method.(string) The name of the variable in the Stan program +containing the pointwise log-likelihood. The default is to look for +
"log_lik". This argument is passed to the$draws()+method.- r_eff
@@ -184,7 +184,7 @@Examples
#> Estimate SE #> elpd_loo -63.7 4.1 #> p_loo 3.9 0.5 -#> looic 127.4 8.2 +#> looic 127.4 8.3 #> ------ #> MCSE of elpd_loo is 0.0. #> MCSE and ESS estimates assume MCMC draws (r_eff in [0.9, 1.4]). diff --git a/docs/reference/fit-method-lp-1.png b/docs/reference/fit-method-lp-1.png index 7016ed34e..54cfc9139 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 180e4c9a9..4ee587d71 100644 --- a/docs/reference/fit-method-lp.html +++ b/docs/reference/fit-method-lp.html @@ -5,8 +5,8 @@ the posterior is available via the $lp_approx() method. For Laplace approximation the unnormalized density of the approximation to the posterior is available via the $lp_approx() method. -See the Log Probability Increment vs. Sampling Statement -section of the Stan Reference Manual for details on when normalizing +See the Increment log density and Distribution Statements +sections of the Stan Reference Manual for details on when normalizing constants are dropped from log probability calculations.">Extract (penalized) maximum likelihood estimate after optimization — fit-method-mle • cmdstanr Extract point estimate after optimization — fit-method-mle • cmdstanr @@ -23,7 +27,7 @@@@ -167,22 +167,22 @@diff --git a/docs/reference/fit-method-output.html b/docs/reference/fit-method-output.html index 9d6e90765..641421f36 100644 --- a/docs/reference/fit-method-output.html +++ b/docs/reference/fit-method-output.html @@ -22,7 +22,7 @@-Extract (penalized) maximum likelihood estimate after optimization
+Extract point estimate after optimization
Source:R/fit.Rfit-method-mle.Rd-The
+$mle()method is only available forCmdStanMLEobjects. -It returns the penalized maximum likelihood estimate (posterior mode) as a -numeric vector with one element per variable. The returned vector does not -includelp__, the total log probability (target) accumulated in the -model block of the Stan program, which is available via the -$lp()method and also included in the -$draws()method.The
+$mle()method is only available forCmdStanMLE+objects. It returns the point estimate as a numeric vector with one element +per variable. The returned vector does not includelp__, the total log +probability (target) accumulated in the model block of the Stan program, +which is available via the$lp()method and also +included in the$draws()method.For models with constrained parameters that are fit with
jacobian=TRUE, +the$mle()method actually returns the maximum a posteriori (MAP) +estimate (posterior mode) rather than the MLE. See +$optimize()and the CmdStan User's Guide for +more details.@@ -148,13 +156,13 @@diff --git a/docs/reference/fit-method-num_chains.html b/docs/reference/fit-method-num_chains.html index 0cce33e50..020f9be41 100644 --- a/docs/reference/fit-method-num_chains.html +++ b/docs/reference/fit-method-num_chains.html @@ -17,7 +17,7 @@Examples
fit <- cmdstanr_example("logistic", method = "optimize") fit$mle("alpha") #> alpha -#> 0.364419 +#> 0.364453 fit$mle("beta") #> beta[1] beta[2] beta[3] -#> -0.631543 -0.258962 0.648511 +#> -0.631550 -0.258968 0.648499 fit$mle("beta[2]") #> beta[2] -#> -0.258962 +#> -0.258968 # }Examples
#> num_chains = 1 (Default) #> id = 1 (Default) #> data -#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpBGNQRs/temp_libpath45223306cea5/cmdstanr/logistic.data.json +#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp0Jp8Zk/temp_libpathb838752e97c0/cmdstanr/logistic.data.json #> init = 2 (Default) #> random -#> seed = 1162623978 +#> seed = 279613479 #> output -#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021538-1-35ac7c.csv +#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-202503310845-1-28c1ee.csv #> diagnostic_file = (Default) #> refresh = 100 (Default) #> sig_figs = -1 (Default) -#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-profile-202407021538-1-88cb05.csv +#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-profile-202503310845-1-0139e1.csv #> save_cmdstan_config = false (Default) #> num_threads = 1 (Default) #> #> -#> Gradient evaluation took 5.1e-05 seconds -#> 1000 transitions using 10 leapfrog steps per transition would take 0.51 seconds. +#> Gradient evaluation took 2.7e-05 seconds +#> 1000 transitions using 10 leapfrog steps per transition would take 0.27 seconds. #> Adjust your expectations accordingly! #> #> @@ -209,9 +209,9 @@Examples
#> Iteration: 1900 / 2000 [ 95%] (Sampling) #> Iteration: 2000 / 2000 [100%] (Sampling) #> -#> Elapsed Time: 0.028 seconds (Warm-up) -#> 0.097 seconds (Sampling) -#> 0.125 seconds (Total) +#> Elapsed Time: 0.022 seconds (Warm-up) +#> 0.074 seconds (Sampling) +#> 0.096 seconds (Total) out <- fit_mcmc$output() str(out) #> List of 4 @@ -239,22 +239,22 @@Examples
#> save_iterations = false (Default) #> id = 1 (Default) #> data -#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpBGNQRs/temp_libpath45223306cea5/cmdstanr/logistic.data.json +#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp0Jp8Zk/temp_libpathb838752e97c0/cmdstanr/logistic.data.json #> init = 2 (Default) #> random -#> seed = 212160042 +#> seed = 384468259 #> output -#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021538-1-18b979.csv +#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-202503310845-1-819b35.csv #> diagnostic_file = (Default) #> refresh = 100 (Default) #> sig_figs = -1 (Default) -#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-profile-202407021538-1-3c00bf.csv +#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-profile-202503310845-1-053c3a.csv #> save_cmdstan_config = false (Default) #> num_threads = 1 (Default) #> -#> Initial log joint probability = -125.672 +#> Initial log joint probability = -105.906 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 7 -63.9218 0.000372447 0.00126853 1 1 10 +#> 8 -63.9218 6.03661e-05 0.000635963 0.6801 0.6801 10 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance @@ -277,16 +277,16 @@Examples
#> output_samples = 1000 (Default) #> id = 1 (Default) #> data -#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpBGNQRs/temp_libpath45223306cea5/cmdstanr/logistic.data.json +#> file = /private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp0Jp8Zk/temp_libpathb838752e97c0/cmdstanr/logistic.data.json #> init = 2 (Default) #> random -#> seed = 490142728 +#> seed = 428491960 #> output -#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021538-1-81868f.csv +#> file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-202503310845-1-1320f3.csv #> diagnostic_file = (Default) #> refresh = 100 (Default) #> sig_figs = -1 (Default) -#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-profile-202407021538-1-385cb7.csv +#> profile_file = /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-profile-202503310845-1-101778.csv #> save_cmdstan_config = false (Default) #> num_threads = 1 (Default) #> @@ -298,8 +298,8 @@Examples
#> #> #> -#> Gradient evaluation took 2.5e-05 seconds -#> 1000 transitions using 10 leapfrog steps per transition would take 0.25 seconds. +#> Gradient evaluation took 2.7e-05 seconds +#> 1000 transitions using 10 leapfrog steps per transition would take 0.27 seconds. #> Adjust your expectations accordingly! #> #> @@ -313,9 +313,9 @@Examples
#> #> Begin stochastic gradient ascent. #> iter ELBO delta_ELBO_mean delta_ELBO_med notes -#> 100 -66.510 1.000 1.000 -#> 200 -66.168 0.503 1.000 -#> 300 -66.153 0.335 0.005 MEDIAN ELBO CONVERGED +#> 100 -67.030 1.000 1.000 +#> 200 -66.410 0.505 1.000 +#> 300 -65.913 0.339 0.009 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 3cde575ed..325bafed8 100644 --- a/docs/reference/fit-method-profiles.html +++ b/docs/reference/fit-method-profiles.html @@ -21,7 +21,7 @@Examples
fit$profiles() #> [[1]] #> name thread_id total_time forward_time reverse_time chain_stack -#> 1 gq 0x7ff858f85100 0.000442373 0.000442373 0.000000000 0 -#> 2 likelihood 0x7ff858f85100 0.001250430 0.000907142 0.000343284 6721 +#> 1 likelihood 0x7ff85af4eb00 0.001158940 0.000848855 0.00031008 6721 +#> 2 gq 0x7ff85af4eb00 0.000444795 0.000444795 0.00000000 0 #> no_chain_stack autodiff_calls no_autodiff_calls -#> 1 0 0 1000 -#> 2 6721 6721 1 +#> 1 6721 6721 1 +#> 2 0 0 1000 #> #> [[2]] #> name thread_id total_time forward_time reverse_time chain_stack -#> 1 gq 0x7ff858f85100 0.000468161 0.000468161 0.000000000 0 -#> 2 likelihood 0x7ff858f85100 0.001255240 0.000911108 0.000344131 6792 +#> 1 likelihood 0x7ff85af4eb00 0.001207200 0.000885927 0.000321272 6792 +#> 2 gq 0x7ff85af4eb00 0.000453808 0.000453808 0.000000000 0 #> no_chain_stack autodiff_calls no_autodiff_calls -#> 1 0 0 1000 -#> 2 6792 6792 1 +#> 1 6792 6792 1 +#> 2 0 0 1000 #> #> [[3]] #> name thread_id total_time forward_time reverse_time chain_stack -#> 1 gq 0x7ff858f85100 0.000458935 0.000458935 0.000000000 0 -#> 2 likelihood 0x7ff858f85100 0.001356490 0.000992885 0.000363606 7163 +#> 1 likelihood 0x7ff85af4eb00 0.001181750 0.000860407 0.000321346 6835 +#> 2 gq 0x7ff85af4eb00 0.000418544 0.000418544 0.000000000 0 #> no_chain_stack autodiff_calls no_autodiff_calls -#> 1 0 0 1000 -#> 2 7163 7163 1 +#> 1 6835 6835 1 +#> 2 0 0 1000 #> #> [[4]] #> name thread_id total_time forward_time reverse_time chain_stack -#> 1 gq 0x7ff858f85100 0.000489173 0.000489173 0.000000000 0 -#> 2 likelihood 0x7ff858f85100 0.001301980 0.000949488 0.000352494 6979 +#> 1 likelihood 0x7ff85af4eb00 0.001272150 0.000927098 0.000345053 6955 +#> 2 gq 0x7ff85af4eb00 0.000416536 0.000416536 0.000000000 0 #> no_chain_stack autodiff_calls no_autodiff_calls -#> 1 0 0 1000 -#> 2 6979 6979 1 +#> 1 6955 6955 1 +#> 2 0 0 1000 #> # } diff --git a/docs/reference/fit-method-return_codes.html b/docs/reference/fit-method-return_codes.html index ad9659f78..8c06616cf 100644 --- a/docs/reference/fit-method-return_codes.html +++ b/docs/reference/fit-method-return_codes.html @@ -18,7 +18,7 @@Examples
@@ -152,7 +152,7 @@# \dontrun{ # example with return codes all zero fit_mcmc <- cmdstanr_example("schools", method = "sample") -#> Warning: 127 of 4000 (3.0%) transitions ended with a divergence. -#> See https://mc-stan.org/misc/warnings for details. -#> Warning: 2 of 4 chains had an E-BFMI less than 0.3. +#> Warning: 81 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 b870781b3..104338f30 100644 --- a/docs/reference/fit-method-sampler_diagnostics.html +++ b/docs/reference/fit-method-sampler_diagnostics.html @@ -20,7 +20,7 @@Examples
fit <- cmdstanr_example("logistic") sampler_diagnostics <- fit$sampler_diagnostics() str(sampler_diagnostics) -#> 'draws_array' num [1:1000, 1:4, 1:6] 3 3 2 3 2 3 2 2 3 2 ... +#> 'draws_array' num [1:1000, 1:4, 1:6] 2 2 2 2 2 2 2 2 3 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 3 0 68 0.91 0.83 7 -#> 2 3 0 66 1.00 0.83 7 -#> 3 2 0 66 0.89 0.83 3 -#> 4 3 0 66 1.00 0.83 7 -#> 5 2 0 67 0.95 0.83 3 -#> 6 3 0 69 0.85 0.83 7 -#> 7 2 0 66 1.00 0.83 3 -#> 8 2 0 66 0.83 0.83 3 -#> 9 3 0 65 0.94 0.83 7 -#> 10 2 0 66 0.93 0.83 7 +#> 1 2 0 69 0.87 0.79 3 +#> 2 2 0 67 0.96 0.79 7 +#> 3 2 0 68 0.80 0.79 3 +#> 4 2 0 69 0.72 0.79 3 +#> 5 2 0 68 0.83 0.79 3 +#> 6 2 0 69 0.94 0.79 3 +#> 7 2 0 66 0.99 0.79 3 +#> 8 2 0 68 0.62 0.79 3 +#> 9 3 0 67 1.00 0.79 7 +#> 10 2 0 67 0.99 0.79 7 #> # ... 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 3 0 68 0.91 0.83 7 -#> 2 3 0 66 1.00 0.83 7 -#> 3 2 0 66 0.89 0.83 3 -#> 4 3 0 66 1.00 0.83 7 -#> 5 2 0 67 0.95 0.83 3 -#> 6 3 0 69 0.85 0.83 7 -#> 7 2 0 66 1.00 0.83 3 -#> 8 2 0 66 0.83 0.83 3 -#> 9 3 0 65 0.94 0.83 7 -#> 10 2 0 66 0.93 0.83 7 +#> 1 2 0 69 0.87 0.79 3 +#> 2 2 0 67 0.96 0.79 7 +#> 3 2 0 68 0.80 0.79 3 +#> 4 2 0 69 0.72 0.79 3 +#> 5 2 0 68 0.83 0.79 3 +#> 6 2 0 69 0.94 0.79 3 +#> 7 2 0 66 0.99 0.79 3 +#> 8 2 0 68 0.62 0.79 3 +#> 9 3 0 67 1.00 0.79 7 +#> 10 2 0 67 0.99 0.79 7 #> # ... 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 baf767c76..ac2d20ae2 100644 --- a/docs/reference/fit-method-save_object.html +++ b/docs/reference/fit-method-save_object.html @@ -1,9 +1,12 @@ -Save fitted model object to a file — fit-method-save_object • cmdstanr Save fitted model object to a file — fit-method-save_object • cmdstanr @@ -21,7 +24,7 @@Save fitted model object to a file
model object. Because the contents of the CmdStan output CSV files are only read into R lazily (i.e., as needed), the$save_object()method is the safest way to guarantee that everything has been read in before saving. +See the "Saving fitted model objects" section of the +Getting started with CmdStanR +vignette for some suggestions on faster model saving for large models.
@@ -146,18 +152,18 @@@@ -224,33 +224,33 @@Examples
fit <- readRDS(temp_rds_file) fit$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.0 -65.7 1.42 1.27 -68.7 -64.3 1.00 2381. -#> 2 alpha 0.379 0.377 0.223 0.224 0.0200 0.754 1.00 4356. -#> 3 beta[1] -0.663 -0.664 0.252 0.252 -1.08 -0.250 1.00 4356. -#> 4 beta[2] -0.270 -0.263 0.223 0.215 -0.645 0.0924 1.00 4293. -#> 5 beta[3] 0.686 0.676 0.269 0.263 0.261 1.15 1.00 4246. -#> 6 log_lik[1] -0.516 -0.511 0.101 0.101 -0.692 -0.364 1.00 4361. -#> 7 log_lik[2] -0.401 -0.381 0.149 0.144 -0.676 -0.193 1.00 4797. -#> 8 log_lik[3] -0.494 -0.460 0.214 0.203 -0.897 -0.207 1.00 4344. -#> 9 log_lik[4] -0.450 -0.431 0.154 0.150 -0.725 -0.233 1.00 4169. -#> 10 log_lik[5] -1.19 -1.17 0.280 0.279 -1.67 -0.767 1.00 4463. +#> 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.42 1.21 -68.6 -64.3 1.00 2184. +#> 2 alpha 0.376 0.374 0.216 0.221 0.0219 0.730 1.00 4114. +#> 3 beta[1] -0.661 -0.659 0.244 0.246 -1.08 -0.269 1.00 4410. +#> 4 beta[2] -0.274 -0.272 0.227 0.228 -0.639 0.0940 1.00 3599. +#> 5 beta[3] 0.675 0.668 0.265 0.261 0.256 1.11 1.00 3811. +#> 6 log_lik[1] -0.517 -0.507 0.0995 0.0970 -0.692 -0.369 1.00 4022. +#> 7 log_lik[2] -0.404 -0.387 0.144 0.134 -0.663 -0.199 1.00 4613. +#> 8 log_lik[3] -0.501 -0.465 0.219 0.208 -0.909 -0.215 1.00 3919. +#> 9 log_lik[4] -0.450 -0.432 0.152 0.148 -0.723 -0.233 1.00 3378. +#> 10 log_lik[5] -1.18 -1.15 0.277 0.272 -1.68 -0.758 1.00 4267. #> # ℹ 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 6b521c25b..06261804b 100644 --- a/docs/reference/fit-method-save_output_files.html +++ b/docs/reference/fit-method-save_output_files.html @@ -24,7 +24,7 @@Examples
diff --git a/docs/reference/fit-method-summary.html b/docs/reference/fit-method-summary.html index a1ceadd7f..e394ca9ff 100644 --- a/docs/reference/fit-method-summary.html +++ b/docs/reference/fit-method-summary.html @@ -27,7 +27,7 @@# \dontrun{ fit <- cmdstanr_example() fit$output_files() -#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021539-1-615e63.csv" -#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021539-2-615e63.csv" -#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021539-3-615e63.csv" -#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021539-4-615e63.csv" +#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-202503310845-1-466e74.csv" +#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-202503310845-2-466e74.csv" +#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-202503310845-3-466e74.csv" +#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-202503310845-4-466e74.csv" fit$data_file() -#> [1] "/private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpBGNQRs/temp_libpath45223306cea5/cmdstanr/logistic.data.json" +#> [1] "/private/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/Rtmp0Jp8Zk/temp_libpathb838752e97c0/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/RtmpiACQ3q/banana-202407021539-1-897d5b.csv -#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/banana-202407021539-2-897d5b.csv -#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/banana-202407021539-3-897d5b.csv -#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/banana-202407021539-4-897d5b.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/banana-202503310845-1-6af888.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/banana-202503310845-2-6af888.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/banana-202503310845-3-6af888.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/banana-202503310845-4-6af888.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/RtmpiACQ3q/tomato-1-4291b8.csv -#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/tomato-2-4291b8.csv -#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/tomato-3-4291b8.csv -#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/tomato-4-4291b8.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/tomato-1-7df674.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/tomato-2-7df674.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/tomato-3-7df674.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/tomato-4-7df674.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/RtmpiACQ3q/lettuce-1.csv -#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/lettuce-2.csv -#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/lettuce-3.csv -#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/lettuce-4.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/lettuce-1.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/lettuce-2.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/lettuce-3.csv +#> - /var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/lettuce-4.csv # }Examples
fit <- cmdstanr_example("logistic") fit$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.0 -65.6 1.45 1.26 -68.7 -64.3 1.00 1922. -#> 2 alpha 0.378 0.373 0.221 0.218 0.0220 0.750 1.00 4329. -#> 3 beta[1] -0.669 -0.660 0.252 0.257 -1.09 -0.264 1.00 3807. -#> 4 beta[2] -0.279 -0.273 0.223 0.223 -0.649 0.0786 1.00 3937. -#> 5 beta[3] 0.677 0.669 0.267 0.257 0.248 1.13 1.00 3914. -#> 6 log_lik[1] -0.516 -0.510 0.0985 0.0955 -0.690 -0.361 1.00 4145. -#> 7 log_lik[2] -0.404 -0.386 0.148 0.137 -0.677 -0.198 1.00 4343. -#> 8 log_lik[3] -0.502 -0.466 0.215 0.206 -0.908 -0.213 1.00 4197. -#> 9 log_lik[4] -0.447 -0.432 0.150 0.147 -0.720 -0.233 1.00 3438. -#> 10 log_lik[5] -1.18 -1.16 0.280 0.281 -1.68 -0.753 1.00 4471. +#> 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.21 -68.7 -64.3 1.00 2233. +#> 2 alpha 0.382 0.380 0.214 0.217 0.0308 0.730 1.00 4473. +#> 3 beta[1] -0.667 -0.665 0.248 0.254 -1.08 -0.261 1.00 4454. +#> 4 beta[2] -0.274 -0.271 0.233 0.232 -0.649 0.103 1.00 4166. +#> 5 beta[3] 0.680 0.672 0.264 0.258 0.254 1.12 1.00 3555. +#> 6 log_lik[1] -0.514 -0.506 0.0973 0.0977 -0.684 -0.368 1.00 4272. +#> 7 log_lik[2] -0.403 -0.383 0.147 0.137 -0.677 -0.199 1.00 4474. +#> 8 log_lik[3] -0.497 -0.465 0.217 0.204 -0.897 -0.202 1.00 4228. +#> 9 log_lik[4] -0.450 -0.434 0.152 0.148 -0.717 -0.238 1.00 3834. +#> 10 log_lik[5] -1.18 -1.16 0.278 0.275 -1.67 -0.760 1.00 4261. #> # ℹ 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.96 -65.63 1.45 1.26 -68.70 -64.28 1.00 1922 2690 -#> alpha 0.38 0.37 0.22 0.22 0.02 0.75 1.00 4329 2617 -#> beta[1] -0.67 -0.66 0.25 0.26 -1.09 -0.26 1.00 3806 3246 -#> beta[2] -0.28 -0.27 0.22 0.22 -0.65 0.08 1.00 3937 2974 -#> beta[3] 0.68 0.67 0.27 0.26 0.25 1.13 1.00 3913 3133 -#> log_lik[1] -0.52 -0.51 0.10 0.10 -0.69 -0.36 1.00 4145 3089 -#> log_lik[2] -0.40 -0.39 0.15 0.14 -0.68 -0.20 1.00 4342 3107 -#> log_lik[3] -0.50 -0.47 0.22 0.21 -0.91 -0.21 1.00 4196 3253 -#> log_lik[4] -0.45 -0.43 0.15 0.15 -0.72 -0.23 1.00 3437 2969 -#> log_lik[5] -1.18 -1.16 0.28 0.28 -1.68 -0.75 1.00 4471 3204 +#> lp__ -65.96 -65.62 1.45 1.21 -68.75 -64.29 1.00 2232 2919 +#> alpha 0.38 0.38 0.21 0.22 0.03 0.73 1.00 4473 3190 +#> beta[1] -0.67 -0.66 0.25 0.25 -1.08 -0.26 1.00 4454 3056 +#> beta[2] -0.27 -0.27 0.23 0.23 -0.65 0.10 1.00 4166 2823 +#> beta[3] 0.68 0.67 0.26 0.26 0.25 1.12 1.00 3555 3140 +#> log_lik[1] -0.51 -0.51 0.10 0.10 -0.68 -0.37 1.00 4272 3239 +#> log_lik[2] -0.40 -0.38 0.15 0.14 -0.68 -0.20 1.00 4474 3106 +#> log_lik[3] -0.50 -0.46 0.22 0.20 -0.90 -0.20 1.00 4228 3323 +#> log_lik[4] -0.45 -0.43 0.15 0.15 -0.72 -0.24 1.00 3833 2800 +#> log_lik[5] -1.18 -1.16 0.28 0.28 -1.67 -0.76 1.00 4260 3060 #> #> # 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.96 -65.63 1.45 1.26 -68.70 -64.28 1.00 1922 2690 -#> alpha 0.38 0.37 0.22 0.22 0.02 0.75 1.00 4329 2617 +#> lp__ -65.96 -65.62 1.45 1.21 -68.75 -64.29 1.00 2232 2919 +#> alpha 0.38 0.38 0.21 0.22 0.03 0.73 1.00 4473 3190 #> #> # showing 2 of 105 rows (change via 'max_rows' argument or 'cmdstanr_max_rows' option) # include only certain variables fit$summary("beta") #> # 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.669 -0.660 0.252 0.257 -1.09 -0.264 1.00 3807. 3246. -#> 2 beta[2] -0.279 -0.273 0.223 0.223 -0.649 0.0786 1.00 3937. 2974. -#> 3 beta[3] 0.677 0.669 0.267 0.257 0.248 1.13 1.00 3914. 3133. +#> 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.667 -0.665 0.248 0.254 -1.08 -0.261 1.00 4454. 3056. +#> 2 beta[2] -0.274 -0.271 0.233 0.232 -0.649 0.103 1.00 4166. 2824. +#> 3 beta[3] 0.680 0.672 0.264 0.258 0.254 1.12 1.00 3555. 3140. fit$print(c("alpha", "beta[2]")) #> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail -#> alpha 0.38 0.37 0.22 0.22 0.02 0.75 1.00 4329 2617 -#> beta[2] -0.28 -0.27 0.22 0.22 -0.65 0.08 1.00 3937 2974 +#> alpha 0.38 0.38 0.21 0.22 0.03 0.73 1.00 4473 3190 +#> beta[2] -0.27 -0.27 0.23 0.23 -0.65 0.10 1.00 4166 2823 # include all variables but only certain summaries fit$summary(NULL, c("mean", "sd")) @@ -217,15 +217,15 @@Examples
#> variable mean sd #> <chr> <dbl> <dbl> #> 1 lp__ -66.0 1.45 -#> 2 alpha 0.378 0.221 -#> 3 beta[1] -0.669 0.252 -#> 4 beta[2] -0.279 0.223 -#> 5 beta[3] 0.677 0.267 -#> 6 log_lik[1] -0.516 0.0985 -#> 7 log_lik[2] -0.404 0.148 -#> 8 log_lik[3] -0.502 0.215 -#> 9 log_lik[4] -0.447 0.150 -#> 10 log_lik[5] -1.18 0.280 +#> 2 alpha 0.382 0.214 +#> 3 beta[1] -0.667 0.248 +#> 4 beta[2] -0.274 0.233 +#> 5 beta[3] 0.680 0.264 +#> 6 log_lik[1] -0.514 0.0973 +#> 7 log_lik[2] -0.403 0.147 +#> 8 log_lik[3] -0.497 0.217 +#> 9 log_lik[4] -0.450 0.152 +#> 10 log_lik[5] -1.18 0.278 #> # ℹ 95 more rows # can use functions created from formulas @@ -235,8 +235,8 @@Examples
#> variable prob_gt_0 #> <chr> <dbl> #> 1 beta[1] 0.0015 -#> 2 beta[2] 0.102 -#> 3 beta[3] 0.993 +#> 2 beta[2] 0.118 +#> 3 beta[3] 0.994 # 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.378 0.373 0.221 0.218 -0.0434 0.812 1.00 4329. 2618. -#> 2 beta[1] -0.669 -0.660 0.252 0.257 -1.17 -0.191 1.00 3807. 3246. -#> 3 beta[2] -0.279 -0.273 0.223 0.223 -0.728 0.143 1.00 3937. 2974. -#> 4 beta[3] 0.677 0.669 0.267 0.257 0.164 1.22 1.00 3914. 3133. +#> 1 alpha 0.382 0.380 0.214 0.217 -0.0460 0.804 1.00 4473. 3191. +#> 2 beta[1] -0.667 -0.665 0.248 0.254 -1.16 -0.189 1.00 4454. 3056. +#> 3 beta[2] -0.274 -0.271 0.233 0.232 -0.727 0.182 1.00 4166. 2824. +#> 4 beta[3] 0.680 0.672 0.264 0.258 0.172 1.21 1.00 3555. 3140. # 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 a966e10d1..4ec8378a2 100644 --- a/docs/reference/fit-method-time.html +++ b/docs/reference/fit-method-time.html @@ -21,7 +21,7 @@Examples
fit_mcmc <- cmdstanr_example("logistic", method = "sample") fit_mcmc$time() #> $total -#> [1] 1.020517 +#> [1] 0.938334 #> #> $chains #> chain_id warmup sampling total -#> 1 1 0.030 0.101 0.131 -#> 2 2 0.027 0.095 0.122 -#> 3 3 0.031 0.099 0.130 -#> 4 4 0.026 0.112 0.138 +#> 1 1 0.022 0.074 0.096 +#> 2 2 0.022 0.076 0.098 +#> 3 3 0.022 0.076 0.098 +#> 4 4 0.022 0.074 0.096 #> fit_vb <- cmdstanr_example("logistic", method = "variational") fit_vb$time() #> $total -#> [1] 0.1371388 +#> [1] 0.1466939 #> fit_mle <- cmdstanr_example("logistic", method = "optimize", jacobian = TRUE) fit_mle$time() #> $total -#> [1] 0.1316919 +#> [1] 0.146842 #> # 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.131767 +#> [1] 0.1427319 #> fit_laplace$time()$total + fit_mle$time()$total # total time -#> [1] 0.263459 +#> [1] 0.2895739 # }Fitted model objects and methods
- + Extract (penalized) maximum likelihood estimate after optimization
Extract point estimate after optimization
diff --git a/docs/reference/install_cmdstan.html b/docs/reference/install_cmdstan.html index 8f4dbe2a3..0cdf27c32 100644 --- a/docs/reference/install_cmdstan.html +++ b/docs/reference/install_cmdstan.html @@ -16,7 +16,15 @@ should typically be followed by calling rebuild_cmdstan(). The check_cmdstan_toolchain() function attempts to check for the required C++ toolchain. It is called internally by install_cmdstan() but can also -be called directly by the user."> @@ -34,7 +42,7 @@ @@ -138,7 +146,15 @@ Install CmdStan or clean and rebuild an existing installation
should typically be followed by callingrebuild_cmdstan().The
+be called directly by the user. On Windows only, calling the function with +thecheck_cmdstan_toolchain()function attempts to check for the required C++ toolchain. It is called internally byinstall_cmdstan()but can also -be called directly by the user.fix = TRUEargument will attempt to install the necessary toolchain +components if they are not found. For Windows users with RTools and CmdStan +versions >= 2.35 no additional toolchain configuration is required. +NOTE: When installing CmdStan on Windows with RTools and CmdStan versions +prior to 2.35.0, the above additional toolchain configuration +is still required. To enable this configuration, set the environment variable +
CMDSTANR_USE_MSYS_TOOLCHAINto 'true' and call +check_cmdstan_toolchain(fix = TRUE).diff --git a/docs/reference/model-method-check_syntax.html b/docs/reference/model-method-check_syntax.html index 36f1d1d85..39684030b 100644 --- a/docs/reference/model-method-check_syntax.html +++ b/docs/reference/model-method-check_syntax.html @@ -19,7 +19,7 @@@@ -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/RtmpiACQ3q/model_febb1e69c7387a0e64cf13583e078104.stan', line 11, column 14: A +#> Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/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 26d474489..6e749d1cd 100644 --- a/docs/reference/model-method-compile.html +++ b/docs/reference/model-method-compile.html @@ -31,7 +31,7 @@ @@ -171,7 +171,7 @@Arguments
pedantic @@ -286,12 +286,12 @@ (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 section 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.Examples
mod <- cmdstan_model(file, compile = FALSE) mod$compile() mod$exe_file() -#> [1] "/Users/jgabry/.cmdstan/cmdstan-2.35.0/examples/bernoulli/bernoulli" +#> [1] "/Users/jgabry/.cmdstan/cmdstan-2.36.0/examples/bernoulli/bernoulli" # turn on threading support (for using functions that support within-chain parallelization) mod$compile(force_recompile = TRUE, cpp_options = list(stan_threads = TRUE)) mod$exe_file() -#> [1] "/Users/jgabry/.cmdstan/cmdstan-2.35.0/examples/bernoulli/bernoulli" +#> [1] "/Users/jgabry/.cmdstan/cmdstan-2.36.0/examples/bernoulli/bernoulli" # turn on pedantic mode (new in Stan v2.24) file_pedantic <- write_stan_file(" @@ -303,7 +303,7 @@Examples
} ") mod <- cmdstan_model(file_pedantic, pedantic = TRUE) -#> Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/model-59c030d64420.stan', line 6, column 2: Parameter +#> Warning in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/model-b9aa1e29138e.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 1ad592eff..41e361f40 100644 --- a/docs/reference/model-method-diagnose.html +++ b/docs/reference/model-method-diagnose.html @@ -21,7 +21,7 @@ @@ -270,11 +270,11 @@Examples
# retrieve the gradients test$gradients() -#> param_idx value model finite_diff error -#> 1 0 0.591940 0.00146498 0.00146493 4.91040e-08 -#> 2 1 1.390710 -30.34660000 -30.34660000 -4.69705e-09 -#> 3 2 -0.987687 11.19930000 11.19930000 1.90498e-08 -#> 4 3 -1.426340 28.46830000 28.46830000 1.54688e-08 +#> param_idx value model finite_diff error +#> 1 0 -1.760420 33.15260 33.15260 2.88651e-08 +#> 2 1 -1.814920 5.15400 5.15400 6.47713e-09 +#> 3 2 0.718975 -16.58770 -16.58770 2.24132e-08 +#> 4 3 1.697010 -5.70682 -5.70682 5.89145e-10 # } diff --git a/docs/reference/model-method-expose_functions.html b/docs/reference/model-method-expose_functions.html index 6032f96f0..f401d289c 100644 --- a/docs/reference/model-method-expose_functions.html +++ b/docs/reference/model-method-expose_functions.html @@ -25,7 +25,7 @@ diff --git a/docs/reference/model-method-format.html b/docs/reference/model-method-format.html index 92f6c52d9..a3546c03a 100644 --- a/docs/reference/model-method-format.html +++ b/docs/reference/model-method-format.html @@ -19,7 +19,7 @@ @@ -187,72 +187,6 @@See also
Examples
diff --git a/docs/reference/model-method-generate-quantities.html b/docs/reference/model-method-generate-quantities.html index a7c397f90..d7278dd5e 100644 --- a/docs/reference/model-method-generate-quantities.html +++ b/docs/reference/model-method-generate-quantities.html @@ -19,7 +19,7 @@ diff --git a/docs/reference/model-method-laplace-1.png b/docs/reference/model-method-laplace-1.png index ddc254975..823e448ec 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 c510e97af..39a307131 100644 --- a/docs/reference/model-method-laplace.html +++ b/docs/reference/model-method-laplace.html @@ -28,7 +28,7 @@ @@ -384,12 +384,12 @@# \dontrun{ -# Example of fixing old syntax -# real x[2] --> array[2] real x; -file <- write_stan_file(" -parameters { - real x[2]; -} -model { - x ~ std_normal(); -} -") - -# set compile=FALSE then call format to fix old syntax -mod <- cmdstan_model(file, compile = FALSE) -mod$format(canonicalize = list("deprecations")) -#> Syntax error in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/model_1fc88c86300d78667dd3e476a636c279.stan', line 3, column 9 to column 10, parsing error: -#> ------------------------------------------------- -#> 1: -#> 2: parameters { -#> 3: real x[2]; -#> ^ -#> 4: } -#> 5: model { -#> ------------------------------------------------- -#> -#> ";" expected after variable declaration. -#> It looks like you are trying to use the old array syntax. -#> Please use the new syntax: -#> array[2] real x; -#> Error: Syntax error found! See the message above for more information. - -# overwrite the original file instead of just printing it -mod$format(canonicalize = list("deprecations"), overwrite_file = TRUE) -#> Syntax error in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/model_1fc88c86300d78667dd3e476a636c279.stan', line 3, column 9 to column 10, parsing error: -#> ------------------------------------------------- -#> 1: -#> 2: parameters { -#> 3: real x[2]; -#> ^ -#> 4: } -#> 5: model { -#> ------------------------------------------------- -#> -#> ";" expected after variable declaration. -#> It looks like you are trying to use the old array syntax. -#> Please use the new syntax: -#> array[2] real x; -#> Error: Syntax error found! See the message above for more information. -mod$compile() -#> Syntax error in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/model-59c028cea1fd.stan', line 3, column 9 to column 10, parsing error: -#> ------------------------------------------------- -#> 1: -#> 2: parameters { -#> 3: real x[2]; -#> ^ -#> 4: } -#> 5: model { -#> ------------------------------------------------- -#> -#> ";" expected after variable declaration. -#> It looks like you are trying to use the old array syntax. -#> Please use the new syntax: -#> array[2] real x; -#> make: *** [/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/model-59c028cea1fd.hpp] Error 1 -#> Error: An error occured during compilation! See the message above for more information. - - # Example of removing unnecessary whitespace file <- write_stan_file(" data { @@ -267,8 +201,10 @@Examples
poisson_lpmf(y | lambda); } ") + +# set compile=FALSE then call format to fix old syntax mod <- cmdstan_model(file, compile = FALSE) -mod$format(canonicalize = TRUE) +mod$format(canonicalize = list("deprecations")) #> data { #> int N; #> array[N] int y; @@ -281,6 +217,11 @@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/RtmpWzIPg0/model_39022cccc3fe5384fab5a52b791fead6.stan.bak-20250331084850. +mod$compile() # }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 = -7.3571 +#> Initial log joint probability = -7.39766 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 5 -6.74802 0.000511122 9.02231e-07 1 1 8 +#> 5 -6.74802 8.90809e-05 3.13416e-07 1 1 8 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance -#> Finished in 0.3 seconds. +#> Finished in 0.2 seconds. fit_laplace <- mod$laplace(data = stan_data, mode = fit_mode) #> Calculating Hessian #> Calculating inverse of Cholesky factor @@ -407,17 +407,17 @@Examples
#> Finished in 0.2 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.734 0.309 -8.50 -6.75 -#> 2 lp_approx__ -0.491 -0.223 0.698 0.309 -1.80 -0.00200 -#> 3 theta 0.271 0.250 0.123 0.123 0.103 0.487 +#> variable mean median sd mad q5 q95 +#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> +#> 1 lp__ -7.26 -6.98 0.724 0.319 -8.80 -6.75 +#> 2 lp_approx__ -0.533 -0.245 0.740 0.330 -2.10 -0.00300 +#> 3 theta 0.262 0.240 0.125 0.120 0.0941 0.503 # if mode isn't specified optimize is run internally first fit_laplace <- mod$laplace(data = stan_data) -#> Initial log joint probability = -11.0359 +#> Initial log joint probability = -7.50846 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 5 -6.74802 0.000945646 1.40836e-05 1 1 8 +#> 5 -6.74802 0.000114292 4.68497e-07 1 1 8 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance #> Finished in 0.1 seconds. @@ -434,14 +434,14 @@Examples
#> iteration: 700 #> iteration: 800 #> iteration: 900 -#> Finished in 0.1 seconds. +#> Finished in 0.2 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.26 -6.97 0.744 0.306 -8.73 -6.75 -#> 2 lp_approx__ -0.516 -0.226 0.742 0.306 -1.93 -0.00178 -#> 3 theta 0.270 0.250 0.126 0.121 0.103 0.513 +#> 1 lp__ -7.23 -6.96 0.773 0.291 -8.49 -6.75 +#> 2 lp_approx__ -0.485 -0.219 0.744 0.303 -1.81 -0.00163 +#> 3 theta 0.265 0.250 0.121 0.121 0.101 0.493 # plot approximate posterior bayesplot::mcmc_hist(fit_laplace$draws("theta")) diff --git a/docs/reference/model-method-optimize-1.png b/docs/reference/model-method-optimize-1.png index aa185638c..35206a7af 100644 Binary files a/docs/reference/model-method-optimize-1.png and b/docs/reference/model-method-optimize-1.png differ diff --git a/docs/reference/model-method-optimize-2.png b/docs/reference/model-method-optimize-2.png index 4cf81fa80..b078570c6 100644 Binary files a/docs/reference/model-method-optimize-2.png and b/docs/reference/model-method-optimize-2.png differ diff --git a/docs/reference/model-method-optimize-3.png b/docs/reference/model-method-optimize-3.png index c67b37ed1..35367ed42 100644 Binary files a/docs/reference/model-method-optimize-3.png and b/docs/reference/model-method-optimize-3.png differ diff --git a/docs/reference/model-method-optimize.html b/docs/reference/model-method-optimize.html index ff5a7c21a..ff5bdc696 100644 --- a/docs/reference/model-method-optimize.html +++ b/docs/reference/model-method-optimize.html @@ -1,7 +1,13 @@Run Stan's optimization algorithms — model-method-optimize • cmdstanr cmdstanr - 0.8.1 + 0.9.0 @@ -114,8 +120,14 @@Run Stan's optimization algorithms
@@ -451,7 +451,7 @@The
$optimize()method of aCmdStanModelobject runs -Stan's optimizer to obtain a (penalized) maximum likelihood estimate or a -maximum a posteriori estimate (ifjacobian=TRUE). See the +Stan's optimizer to obtain a (penalized) maximum likelihood estimate (MLE) +or a maximum a posteriori estimate (MAP), depending on the value of the +jacobianargument. For models with constrained parameters, when the +Jacobian adjustment is not applied, the point estimate corresponds to a +penalized MLE, and when the Jacobian adjustment is applied the point +estimate corresponds to the MAP (posterior mode) of the model we would fit +if we were instead doing MCMC sampling. The Jacobian adjustment has no +affect if the model has only unconstrained parameters. See the CmdStan User's Guide for more details.Any argument left as
NULLwill default to the default value used by the @@ -410,7 +422,7 @@Examples
# Otherwise use the `path` argument to specify the location of your # CmdStan installation.) set_cmdstan_path(path = NULL) -#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.35.0 +#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.36.0 # Create a CmdStanModel object from a Stan program, # here using the example model that comes with CmdStan @@ -512,8 +524,8 @@Examples
#> # A tibble: 2 × 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__ -7.30 -7.00 0.811 0.344 -8.83 -6.75 1.00 702. 776. -#> 2 theta 0.254 0.238 0.125 0.124 0.0807 0.483 1.00 634. 580. +#> 1 lp__ -7.35 -7.01 0.882 0.353 -9.14 -6.75 1.00 724. 896. +#> 2 theta 0.254 0.239 0.129 0.126 0.0737 0.488 1.00 532. 657. # Check sampling diagnostics fit_mcmc$diagnostic_summary() @@ -524,7 +536,7 @@Examples
#> [1] 0 0 #> #> $ebfmi -#> [1] 1.1148699 0.8012192 +#> [1] 1.1148479 0.7568734 #> # Get posterior draws @@ -534,22 +546,22 @@Examples
#> , , variable = lp__ #> #> chain -#> iteration 1 2 -#> 1 -7.0 -6.8 -#> 2 -7.9 -6.9 -#> 3 -7.4 -6.8 -#> 4 -6.7 -6.8 -#> 5 -6.9 -10.2 +#> iteration 1 2 +#> 1 -7.0 -8.1 +#> 2 -7.9 -7.9 +#> 3 -7.4 -7.0 +#> 4 -6.7 -6.8 +#> 5 -6.9 -6.8 #> #> , , variable = theta #> #> chain -#> iteration 1 2 -#> 1 0.17 0.23 -#> 2 0.46 0.18 -#> 3 0.41 0.28 -#> 4 0.25 0.23 -#> 5 0.18 0.62 +#> iteration 1 2 +#> 1 0.17 0.088 +#> 2 0.46 0.097 +#> 3 0.41 0.167 +#> 4 0.25 0.292 +#> 5 0.18 0.238 #> #> # ... with 995 more iterations @@ -575,11 +587,6 @@Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.-# For models fit using MCMC, if you like working with RStan's stanfit objects -# then you can create one with rstan::read_stan_csv() -# stanfit <- rstan::read_stan_csv(fit_mcmc$output_files()) - - # Run 'optimize' method to get a point estimate (default is Stan's LBFGS algorithm) # and also demonstrate specifying data as a path to a file instead of a list my_data_file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.data.json") @@ -600,9 +607,9 @@
Examples
# 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.9711 +#> Initial log joint probability = -12.6782 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 5 -6.74802 0.00123686 2.20415e-05 1 1 8 +#> 5 -6.74802 0.00154762 3.33598e-05 1 1 8 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance #> Finished in 0.2 seconds. @@ -630,14 +637,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.697 0.297 -8.63 -6.75 -#> 2 lp_approx__ -0.491 -0.213 0.686 0.296 -1.89 -0.00171 -#> 3 theta 0.268 0.249 0.123 0.118 0.102 0.507 +#> variable mean median sd mad q5 q95 +#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> +#> 1 lp__ -7.23 -6.96 0.673 0.289 -8.53 -6.75 +#> 2 lp_approx__ -0.484 -0.215 0.665 0.294 -1.83 -0.00153 +#> 3 theta 0.270 0.253 0.121 0.119 0.0987 0.501 # Run 'variational' method to use ADVI to approximate posterior fit_vb <- mod$variational(data = stan_data, seed = 123) @@ -646,8 +653,8 @@Examples
#> This procedure has not been thoroughly tested and may be unstable #> or buggy. The interface is subject to change. #> ------------------------------------------------------------ -#> Gradient evaluation took 1.2e-05 seconds -#> 1000 transitions using 10 leapfrog steps per transition would take 0.12 seconds. +#> Gradient evaluation took 1.1e-05 seconds +#> 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds. #> Adjust your expectations accordingly! #> Begin eta adaptation. #> Iteration: 1 / 250 [ 0%] (Adaptation) @@ -663,7 +670,7 @@Examples
#> 300 -6.186 0.339 0.010 MEDIAN ELBO CONVERGED #> Drawing a sample of size 1000 from the approximate posterior... #> COMPLETED. -#> Finished in 0.1 seconds. +#> Finished in 0.2 seconds. fit_vb$summary() #> # A tibble: 3 × 7 #> variable mean median sd mad q5 q95 @@ -694,7 +701,7 @@Examples
#> 5 -6.748e+00 2.145e-04 1.301e-06 1.000e+00 1.000e+00 126 -6.197e+00 -6.197e+00 #> Path [4] :Best Iter: [5] ELBO (-6.197118) evaluations: (126) #> Total log probability function evaluations:4379 -#> Finished in 0.1 seconds. +#> Finished in 0.2 seconds. fit_pf$summary() #> # A tibble: 3 × 7 #> variable mean median sd mad q5 q95 @@ -711,49 +718,48 @@Examples
fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40, history_size=50, max_lbfgs_iters=100) #> Warning: Number of PSIS draws is larger than the total number of draws returned by the single Pathfinders. This is likely unintentional and leads to re-sampling from the same draws. -#> Path [1] :Initial log joint density = -14.241761 +#> Path [1] :Initial log joint density = -6.755726 #> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 2.000e-03 5.597e-05 1.000e+00 1.000e+00 126 -6.236e+00 -6.236e+00 -#> Path [1] :Best Iter: [5] ELBO (-6.235525) evaluations: (126) -#> Path [2] :Initial log joint density = -13.402374 +#> 3 -6.748e+00 9.605e-04 1.028e-05 9.884e-01 9.884e-01 76 -6.240e+00 -6.240e+00 +#> Path [1] :Best Iter: [2] ELBO (-6.221702) evaluations: (76) +#> Path [2] :Initial log joint density = -9.051867 #> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.810e-03 4.511e-05 1.000e+00 1.000e+00 126 -6.208e+00 -6.208e+00 -#> Path [2] :Best Iter: [2] ELBO (-6.203915) evaluations: (126) -#> Path [3] :Initial log joint density = -12.050800 +#> 5 -6.748e+00 3.457e-04 2.924e-06 1.000e+00 1.000e+00 126 -6.190e+00 -6.190e+00 +#> Path [2] :Best Iter: [5] ELBO (-6.189740) evaluations: (126) +#> Path [3] :Initial log joint density = -6.775220 #> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.274e-03 2.325e-05 1.000e+00 1.000e+00 126 -6.196e+00 -6.196e+00 -#> Path [3] :Best Iter: [3] ELBO (-6.168581) evaluations: (126) -#> Path [4] :Initial log joint density = -11.907691 +#> 3 -6.748e+00 2.337e-03 3.532e-06 9.682e-01 9.682e-01 76 -6.298e+00 -6.298e+00 +#> Path [3] :Best Iter: [3] ELBO (-6.298399) evaluations: (76) +#> Path [4] :Initial log joint density = -18.179237 #> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.208e-03 2.110e-05 1.000e+00 1.000e+00 126 -6.195e+00 -6.195e+00 -#> Path [4] :Best Iter: [3] ELBO (-6.184266) evaluations: (126) -#> Path [5] :Initial log joint density = -17.062583 +#> 5 -6.748e+00 7.662e-04 1.607e-05 1.000e+00 1.000e+00 126 -6.271e+00 -6.271e+00 +#> Path [4] :Best Iter: [4] ELBO (-6.175731) evaluations: (126) +#> Path [5] :Initial log joint density = -17.845239 #> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.424e-03 3.915e-05 1.000e+00 1.000e+00 126 -6.229e+00 -6.229e+00 -#> Path [5] :Best Iter: [4] ELBO (-6.180989) evaluations: (126) -#> Path [6] :Initial log joint density = -7.950926 +#> 5 -6.748e+00 9.725e-04 2.274e-05 1.000e+00 1.000e+00 126 -6.275e+00 -6.275e+00 +#> Path [5] :Best Iter: [4] ELBO (-6.207498) evaluations: (126) +#> Path [6] :Initial log joint density = -11.863276 #> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 2.149e-04 1.305e-06 1.000e+00 1.000e+00 126 -6.210e+00 -6.210e+00 -#> Path [6] :Best Iter: [4] ELBO (-6.193547) evaluations: (126) -#> Path [7] :Initial log joint density = -13.337353 +#> 5 -6.748e+00 1.187e-03 2.045e-05 1.000e+00 1.000e+00 126 -6.264e+00 -6.264e+00 +#> Path [6] :Best Iter: [2] ELBO (-6.141104) evaluations: (126) +#> Path [7] :Initial log joint density = -6.807183 #> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.789e-03 4.411e-05 1.000e+00 1.000e+00 126 -6.275e+00 -6.275e+00 -#> Path [7] :Best Iter: [4] ELBO (-6.264759) evaluations: (126) -#> Path [8] :Initial log joint density = -6.856154 +#> 4 -6.748e+00 3.391e-04 1.605e-06 1.000e+00 1.000e+00 101 -6.264e+00 -6.264e+00 +#> Path [7] :Best Iter: [2] ELBO (-6.199985) evaluations: (101) +#> Path [8] :Initial log joint density = -6.874334 #> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 7.559e-04 6.106e-06 1.000e+00 1.000e+00 101 -6.237e+00 -6.237e+00 -#> Path [8] :Best Iter: [2] ELBO (-6.233924) evaluations: (101) -#> Path [9] :Initial log joint density = -19.158821 +#> 4 -6.748e+00 1.370e-04 2.042e-05 9.398e-01 9.398e-01 101 -6.203e+00 -6.203e+00 +#> Path [8] :Best Iter: [4] ELBO (-6.203174) evaluations: (101) +#> Path [9] :Initial log joint density = -16.813276 #> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 2.167e-04 2.482e-06 1.000e+00 1.000e+00 126 -6.251e+00 -6.251e+00 -#> Path [9] :Best Iter: [3] ELBO (-6.196829) evaluations: (126) -#> Path [10] :Initial log joint density = -6.894545 +#> 5 -6.748e+00 1.549e-03 4.398e-05 1.000e+00 1.000e+00 126 -6.174e+00 -6.174e+00 +#> Path [9] :Best Iter: [5] ELBO (-6.174126) evaluations: (126) +#> Path [10] :Initial log joint density = -11.429555 #> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 1.811e-04 2.981e-05 9.341e-01 9.341e-01 101 -6.227e+00 -6.227e+00 -#> Path [10] :Best Iter: [2] ELBO (-6.144040) evaluations: (101) -#> Total log probability function evaluations:1360 -#> Pareto k value (0.73) 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. +#> 5 -6.748e+00 1.045e-03 1.644e-05 1.000e+00 1.000e+00 126 -6.293e+00 -6.293e+00 +#> Path [10] :Best Iter: [3] ELBO (-6.173918) evaluations: (126) +#> Total log probability function evaluations:1260 +#> Finished in 0.2 seconds. # Specifying initial values as a function fit_mcmc_w_init_fun <- mod$sample( @@ -789,7 +795,7 @@Examples
#> #> Both chains finished successfully. #> Mean chain execution time: 0.0 seconds. -#> Total execution time: 0.3 seconds. +#> Total execution time: 0.4 seconds. #> fit_mcmc_w_init_fun_2$init() #> [[1]] diff --git a/docs/reference/model-method-pathfinder-1.png b/docs/reference/model-method-pathfinder-1.png index aa185638c..35206a7af 100644 Binary files a/docs/reference/model-method-pathfinder-1.png and b/docs/reference/model-method-pathfinder-1.png differ diff --git a/docs/reference/model-method-pathfinder-2.png b/docs/reference/model-method-pathfinder-2.png index 4cf81fa80..b078570c6 100644 Binary files a/docs/reference/model-method-pathfinder-2.png and b/docs/reference/model-method-pathfinder-2.png differ diff --git a/docs/reference/model-method-pathfinder-3.png b/docs/reference/model-method-pathfinder-3.png index c67b37ed1..35367ed42 100644 Binary files a/docs/reference/model-method-pathfinder-3.png and b/docs/reference/model-method-pathfinder-3.png differ diff --git a/docs/reference/model-method-pathfinder.html b/docs/reference/model-method-pathfinder.html index fabd8cf2f..c338a2b62 100644 --- a/docs/reference/model-method-pathfinder.html +++ b/docs/reference/model-method-pathfinder.html @@ -32,7 +32,7 @@Examples
# Otherwise use the `path` argument to specify the location of your # CmdStan installation.) set_cmdstan_path(path = NULL) -#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.35.0 +#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.36.0 # Create a CmdStanModel object from a Stan program, # here using the example model that comes with CmdStan @@ -553,8 +553,8 @@Examples
#> # A tibble: 2 × 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__ -7.30 -7.00 0.811 0.344 -8.83 -6.75 1.00 702. 776. -#> 2 theta 0.254 0.238 0.125 0.124 0.0807 0.483 1.00 634. 580. +#> 1 lp__ -7.35 -7.01 0.882 0.353 -9.14 -6.75 1.00 724. 896. +#> 2 theta 0.254 0.239 0.129 0.126 0.0737 0.488 1.00 532. 657. # Check sampling diagnostics fit_mcmc$diagnostic_summary() @@ -565,7 +565,7 @@Examples
#> [1] 0 0 #> #> $ebfmi -#> [1] 1.1148699 0.8012192 +#> [1] 1.1148479 0.7568734 #> # Get posterior draws @@ -575,22 +575,22 @@Examples
#> , , variable = lp__ #> #> chain -#> iteration 1 2 -#> 1 -7.0 -6.8 -#> 2 -7.9 -6.9 -#> 3 -7.4 -6.8 -#> 4 -6.7 -6.8 -#> 5 -6.9 -10.2 +#> iteration 1 2 +#> 1 -7.0 -8.1 +#> 2 -7.9 -7.9 +#> 3 -7.4 -7.0 +#> 4 -6.7 -6.8 +#> 5 -6.9 -6.8 #> #> , , variable = theta #> #> chain -#> iteration 1 2 -#> 1 0.17 0.23 -#> 2 0.46 0.18 -#> 3 0.41 0.28 -#> 4 0.25 0.23 -#> 5 0.18 0.62 +#> iteration 1 2 +#> 1 0.17 0.088 +#> 2 0.46 0.097 +#> 3 0.41 0.167 +#> 4 0.25 0.292 +#> 5 0.18 0.238 #> #> # ... with 995 more iterations @@ -616,11 +616,6 @@Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.-# For models fit using MCMC, if you like working with RStan's stanfit objects -# then you can create one with rstan::read_stan_csv() -# stanfit <- rstan::read_stan_csv(fit_mcmc$output_files()) - - # Run 'optimize' method to get a point estimate (default is Stan's LBFGS algorithm) # and also demonstrate specifying data as a path to a file instead of a list my_data_file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.data.json") @@ -630,7 +625,7 @@
Examples
#> 6 -5.00402 0.000246518 8.73164e-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 @@ -641,12 +636,12 @@Examples
# 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.03582 +#> Initial log joint probability = -11.6636 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 5 -6.74802 0.000232501 1.48433e-06 1 1 8 +#> 5 -6.74802 0.00109631 1.77159e-05 1 1 8 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance -#> Finished in 0.1 seconds. +#> Finished in 0.2 seconds. fit_laplace <- mod$laplace(data = my_data_file, mode = fit_optim, draws = 2000) #> Calculating Hessian #> Calculating inverse of Cholesky factor @@ -671,14 +666,14 @@Examples
#> iteration: 1700 #> iteration: 1800 #> iteration: 1900 -#> Finished in 0.1 seconds. +#> Finished in 0.2 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.696 0.318 -8.64 -6.75 -#> 2 lp_approx__ -0.504 -0.233 0.703 0.320 -1.97 -0.00198 -#> 3 theta 0.266 0.248 0.123 0.122 0.100 0.498 +#> variable mean median sd mad q5 q95 +#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> +#> 1 lp__ -7.26 -6.97 0.807 0.300 -8.67 -6.75 +#> 2 lp_approx__ -0.514 -0.222 0.798 0.305 -1.93 -0.00172 +#> 3 theta 0.270 0.254 0.125 0.122 0.0996 0.507 # Run 'variational' method to use ADVI to approximate posterior fit_vb <- mod$variational(data = stan_data, seed = 123) @@ -687,8 +682,8 @@Examples
#> This procedure has not been thoroughly tested and may be unstable #> or buggy. The interface is subject to change. #> ------------------------------------------------------------ -#> Gradient evaluation took 1.2e-05 seconds -#> 1000 transitions using 10 leapfrog steps per transition would take 0.12 seconds. +#> Gradient evaluation took 1.1e-05 seconds +#> 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds. #> Adjust your expectations accordingly! #> Begin eta adaptation. #> Iteration: 1 / 250 [ 0%] (Adaptation) @@ -704,7 +699,7 @@Examples
#> 300 -6.186 0.339 0.010 MEDIAN ELBO CONVERGED #> Drawing a sample of size 1000 from the approximate posterior... #> COMPLETED. -#> Finished in 0.1 seconds. +#> Finished in 0.2 seconds. fit_vb$summary() #> # A tibble: 3 × 7 #> variable mean median sd mad q5 q95 @@ -752,48 +747,48 @@Examples
fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40, history_size=50, max_lbfgs_iters=100) #> Warning: Number of PSIS draws is larger than the total number of draws returned by the single Pathfinders. This is likely unintentional and leads to re-sampling from the same draws. -#> Path [1] :Initial log joint density = -6.748022 +#> Path [1] :Initial log joint density = -8.866534 #> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 2 -6.748e+00 3.660e-04 9.724e-08 1.000e+00 1.000e+00 51 -6.176e+00 -6.176e+00 -#> Path [1] :Best Iter: [2] ELBO (-6.176168) evaluations: (51) -#> Path [2] :Initial log joint density = -6.810066 +#> 5 -6.748e+00 3.406e-04 2.829e-06 1.000e+00 1.000e+00 126 -6.250e+00 -6.250e+00 +#> Path [1] :Best Iter: [3] ELBO (-6.238275) evaluations: (126) +#> Path [2] :Initial log joint density = -12.781290 #> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 3.617e-04 1.786e-06 1.000e+00 1.000e+00 101 -6.202e+00 -6.202e+00 -#> Path [2] :Best Iter: [4] ELBO (-6.201718) evaluations: (101) -#> Path [3] :Initial log joint density = -7.451465 +#> 5 -6.748e+00 1.589e-03 3.507e-05 1.000e+00 1.000e+00 126 -6.162e+00 -6.162e+00 +#> Path [2] :Best Iter: [4] ELBO (-6.140443) evaluations: (126) +#> Path [3] :Initial log joint density = -7.160474 #> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.012e-04 3.850e-07 1.000e+00 1.000e+00 126 -6.225e+00 -6.225e+00 -#> Path [3] :Best Iter: [4] ELBO (-6.186839) evaluations: (126) -#> Path [4] :Initial log joint density = -18.081755 +#> 5 -6.748e+00 1.830e-04 1.466e-07 1.000e+00 1.000e+00 126 -6.227e+00 -6.227e+00 +#> Path [3] :Best Iter: [2] ELBO (-6.155847) evaluations: (126) +#> Path [4] :Initial log joint density = -15.099639 #> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 8.265e-04 1.795e-05 1.000e+00 1.000e+00 126 -6.189e+00 -6.189e+00 -#> Path [4] :Best Iter: [5] ELBO (-6.188909) evaluations: (126) -#> Path [5] :Initial log joint density = -7.075204 +#> 5 -6.748e+00 2.032e-03 6.062e-05 1.000e+00 1.000e+00 126 -6.233e+00 -6.233e+00 +#> Path [4] :Best Iter: [3] ELBO (-6.206690) evaluations: (126) +#> Path [5] :Initial log joint density = -8.969584 #> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 2.957e-03 5.925e-05 1.000e+00 1.000e+00 101 -6.268e+00 -6.268e+00 -#> Path [5] :Best Iter: [3] ELBO (-6.207400) evaluations: (101) -#> Path [6] :Initial log joint density = -6.950110 +#> 5 -6.748e+00 3.443e-04 2.894e-06 1.000e+00 1.000e+00 126 -6.229e+00 -6.229e+00 +#> Path [5] :Best Iter: [4] ELBO (-6.164928) evaluations: (126) +#> Path [6] :Initial log joint density = -7.603579 #> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 1.668e-03 2.284e-05 1.000e+00 1.000e+00 101 -6.226e+00 -6.226e+00 -#> Path [6] :Best Iter: [3] ELBO (-6.178796) evaluations: (101) -#> Path [7] :Initial log joint density = -10.742807 +#> 5 -6.748e+00 1.364e-04 6.236e-07 1.000e+00 1.000e+00 126 -6.247e+00 -6.247e+00 +#> Path [6] :Best Iter: [4] ELBO (-6.232661) evaluations: (126) +#> Path [7] :Initial log joint density = -6.767406 #> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 8.636e-04 1.223e-05 1.000e+00 1.000e+00 126 -6.253e+00 -6.253e+00 -#> Path [7] :Best Iter: [2] ELBO (-6.147651) evaluations: (126) -#> Path [8] :Initial log joint density = -8.722796 +#> 3 -6.748e+00 1.821e-03 5.050e-06 9.750e-01 9.750e-01 76 -6.198e+00 -6.198e+00 +#> Path [7] :Best Iter: [3] ELBO (-6.197967) evaluations: (76) +#> Path [8] :Initial log joint density = -7.131671 #> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 3.316e-04 2.692e-06 1.000e+00 1.000e+00 126 -6.185e+00 -6.185e+00 -#> Path [8] :Best Iter: [5] ELBO (-6.185211) evaluations: (126) -#> Path [9] :Initial log joint density = -6.756313 +#> 5 -6.748e+00 1.518e-04 1.054e-07 1.000e+00 1.000e+00 126 -6.299e+00 -6.299e+00 +#> Path [8] :Best Iter: [2] ELBO (-6.177966) evaluations: (126) +#> Path [9] :Initial log joint density = -12.644619 #> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 3 -6.748e+00 1.308e-03 4.802e-05 1.000e+00 1.000e+00 76 -6.202e+00 -6.202e+00 -#> Path [9] :Best Iter: [3] ELBO (-6.201510) evaluations: (76) -#> Path [10] :Initial log joint density = -7.046682 +#> 5 -6.748e+00 1.534e-03 3.280e-05 1.000e+00 1.000e+00 126 -6.242e+00 -6.242e+00 +#> Path [9] :Best Iter: [3] ELBO (-6.212996) evaluations: (126) +#> Path [10] :Initial log joint density = -9.270214 #> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 2.661e-03 4.972e-05 1.000e+00 1.000e+00 101 -6.199e+00 -6.199e+00 -#> Path [10] :Best Iter: [2] ELBO (-6.191324) evaluations: (101) -#> Total log probability function evaluations:1185 -#> Finished in 0.1 seconds. +#> 5 -6.748e+00 3.999e-04 3.679e-06 1.000e+00 1.000e+00 126 -6.217e+00 -6.217e+00 +#> Path [10] :Best Iter: [4] ELBO (-6.202150) evaluations: (126) +#> Total log probability function evaluations:1360 +#> Finished in 0.2 seconds. # Specifying initial values as a function fit_mcmc_w_init_fun <- mod$sample( diff --git a/docs/reference/model-method-sample-1.png b/docs/reference/model-method-sample-1.png index aa185638c..35206a7af 100644 Binary files a/docs/reference/model-method-sample-1.png and b/docs/reference/model-method-sample-1.png differ diff --git a/docs/reference/model-method-sample-2.png b/docs/reference/model-method-sample-2.png index 4cf81fa80..b078570c6 100644 Binary files a/docs/reference/model-method-sample-2.png and b/docs/reference/model-method-sample-2.png differ diff --git a/docs/reference/model-method-sample-3.png b/docs/reference/model-method-sample-3.png index c67b37ed1..35367ed42 100644 Binary files a/docs/reference/model-method-sample-3.png and b/docs/reference/model-method-sample-3.png differ diff --git a/docs/reference/model-method-sample.html b/docs/reference/model-method-sample.html index a0b5b1f3c..db271e25b 100644 --- a/docs/reference/model-method-sample.html +++ b/docs/reference/model-method-sample.html @@ -24,7 +24,7 @@ @@ -526,7 +526,7 @@Examples
# Otherwise use the `path` argument to specify the location of your # CmdStan installation.) set_cmdstan_path(path = NULL) -#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.35.0 +#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.36.0 # Create a CmdStanModel object from a Stan program, # here using the example model that comes with CmdStan @@ -628,8 +628,8 @@Examples
#> # A tibble: 2 × 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__ -7.30 -7.00 0.811 0.344 -8.83 -6.75 1.00 702. 776. -#> 2 theta 0.254 0.238 0.125 0.124 0.0807 0.483 1.00 634. 580. +#> 1 lp__ -7.35 -7.01 0.882 0.353 -9.14 -6.75 1.00 724. 896. +#> 2 theta 0.254 0.239 0.129 0.126 0.0737 0.488 1.00 532. 657. # Check sampling diagnostics fit_mcmc$diagnostic_summary() @@ -640,7 +640,7 @@Examples
#> [1] 0 0 #> #> $ebfmi -#> [1] 1.1148699 0.8012192 +#> [1] 1.1148479 0.7568734 #> # Get posterior draws @@ -650,22 +650,22 @@Examples
#> , , variable = lp__ #> #> chain -#> iteration 1 2 -#> 1 -7.0 -6.8 -#> 2 -7.9 -6.9 -#> 3 -7.4 -6.8 -#> 4 -6.7 -6.8 -#> 5 -6.9 -10.2 +#> iteration 1 2 +#> 1 -7.0 -8.1 +#> 2 -7.9 -7.9 +#> 3 -7.4 -7.0 +#> 4 -6.7 -6.8 +#> 5 -6.9 -6.8 #> #> , , variable = theta #> #> chain -#> iteration 1 2 -#> 1 0.17 0.23 -#> 2 0.46 0.18 -#> 3 0.41 0.28 -#> 4 0.25 0.23 -#> 5 0.18 0.62 +#> iteration 1 2 +#> 1 0.17 0.088 +#> 2 0.46 0.097 +#> 3 0.41 0.167 +#> 4 0.25 0.292 +#> 5 0.18 0.238 #> #> # ... with 995 more iterations @@ -691,11 +691,6 @@Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.-# For models fit using MCMC, if you like working with RStan's stanfit objects -# then you can create one with rstan::read_stan_csv() -# stanfit <- rstan::read_stan_csv(fit_mcmc$output_files()) - - # Run 'optimize' method to get a point estimate (default is Stan's LBFGS algorithm) # and also demonstrate specifying data as a path to a file instead of a list my_data_file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.data.json") @@ -716,9 +711,9 @@
Examples
# 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.90422 +#> Initial log joint probability = -6.989 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 4 -6.74802 0.00121095 1.33942e-05 1 1 7 +#> 4 -6.74802 0.000455385 0.000104592 0.9108 0.9108 7 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance #> Finished in 0.2 seconds. @@ -751,9 +746,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.97 0.693 0.308 -8.63 -6.75 -#> 2 lp_approx__ -0.493 -0.228 0.700 0.315 -1.89 -0.00185 -#> 3 theta 0.265 0.245 0.122 0.119 0.102 0.495 +#> 1 lp__ -7.23 -6.97 0.700 0.304 -8.62 -6.75 +#> 2 lp_approx__ -0.482 -0.222 0.697 0.301 -1.89 -0.00177 +#> 3 theta 0.273 0.257 0.121 0.123 0.104 0.502 # Run 'variational' method to use ADVI to approximate posterior fit_vb <- mod$variational(data = stan_data, seed = 123) @@ -779,7 +774,7 @@Examples
#> 300 -6.186 0.339 0.010 MEDIAN ELBO CONVERGED #> Drawing a sample of size 1000 from the approximate posterior... #> COMPLETED. -#> Finished in 0.1 seconds. +#> Finished in 0.2 seconds. fit_vb$summary() #> # A tibble: 3 × 7 #> variable mean median sd mad q5 q95 @@ -827,48 +822,47 @@Examples
fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40, history_size=50, max_lbfgs_iters=100) #> Warning: Number of PSIS draws is larger than the total number of draws returned by the single Pathfinders. This is likely unintentional and leads to re-sampling from the same draws. -#> Path [1] :Initial log joint density = -6.999713 +#> Path [1] :Initial log joint density = -14.842013 #> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 4.935e-04 1.167e-04 9.085e-01 9.085e-01 101 -6.235e+00 -6.235e+00 -#> Path [1] :Best Iter: [2] ELBO (-6.220514) evaluations: (101) -#> Path [2] :Initial log joint density = -6.963421 +#> 5 -6.748e+00 2.041e-03 6.008e-05 1.000e+00 1.000e+00 126 -6.245e+00 -6.245e+00 +#> Path [1] :Best Iter: [4] ELBO (-6.197550) evaluations: (126) +#> Path [2] :Initial log joint density = -13.719046 #> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 3.701e-04 7.882e-05 9.167e-01 9.167e-01 101 -6.331e+00 -6.331e+00 -#> Path [2] :Best Iter: [2] ELBO (-6.159890) evaluations: (101) -#> Path [3] :Initial log joint density = -6.794406 +#> 5 -6.748e+00 1.898e-03 4.974e-05 1.000e+00 1.000e+00 126 -6.222e+00 -6.222e+00 +#> Path [2] :Best Iter: [3] ELBO (-6.220670) evaluations: (126) +#> Path [3] :Initial log joint density = -6.815359 #> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 2.434e-04 9.233e-07 1.000e+00 1.000e+00 101 -6.183e+00 -6.183e+00 -#> Path [3] :Best Iter: [4] ELBO (-6.183157) evaluations: (101) -#> Path [4] :Initial log joint density = -6.999423 +#> 3 -6.748e+00 4.756e-03 9.139e-05 9.421e-01 9.421e-01 76 -6.278e+00 -6.278e+00 +#> Path [3] :Best Iter: [2] ELBO (-6.242127) evaluations: (76) +#> Path [4] :Initial log joint density = -17.875212 #> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 4.925e-04 1.164e-04 9.085e-01 9.085e-01 101 -6.107e+00 -6.107e+00 -#> Path [4] :Best Iter: [4] ELBO (-6.107025) evaluations: (101) -#> Path [5] :Initial log joint density = -17.406798 +#> 5 -6.748e+00 9.541e-04 2.212e-05 1.000e+00 1.000e+00 126 -6.214e+00 -6.214e+00 +#> Path [4] :Best Iter: [5] ELBO (-6.214309) evaluations: (126) +#> Path [5] :Initial log joint density = -6.766198 #> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.234e-03 3.202e-05 1.000e+00 1.000e+00 126 -6.124e+00 -6.124e+00 -#> Path [5] :Best Iter: [5] ELBO (-6.123731) evaluations: (126) -#> Path [6] :Initial log joint density = -6.778306 +#> 3 -6.748e+00 2.751e-03 1.480e-04 1.000e+00 1.000e+00 76 -6.182e+00 -6.182e+00 +#> Path [5] :Best Iter: [3] ELBO (-6.182449) evaluations: (76) +#> Path [6] :Initial log joint density = -17.054272 #> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 1.349e-04 3.452e-07 1.000e+00 1.000e+00 101 -6.229e+00 -6.229e+00 -#> Path [6] :Best Iter: [2] ELBO (-6.102031) evaluations: (101) -#> Path [7] :Initial log joint density = -16.742631 +#> 5 -6.748e+00 1.428e-03 3.932e-05 1.000e+00 1.000e+00 126 -6.264e+00 -6.264e+00 +#> Path [6] :Best Iter: [2] ELBO (-6.179165) evaluations: (126) +#> Path [7] :Initial log joint density = -18.498779 #> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.582e-03 4.527e-05 1.000e+00 1.000e+00 126 -6.275e+00 -6.275e+00 -#> Path [7] :Best Iter: [3] ELBO (-6.151199) evaluations: (126) -#> Path [8] :Initial log joint density = -9.611781 +#> 5 -6.748e+00 5.714e-04 1.045e-05 1.000e+00 1.000e+00 126 -6.239e+00 -6.239e+00 +#> Path [7] :Best Iter: [2] ELBO (-6.173540) evaluations: (126) +#> Path [8] :Initial log joint density = -9.008917 #> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 5.082e-04 5.350e-06 1.000e+00 1.000e+00 126 -6.224e+00 -6.224e+00 -#> Path [8] :Best Iter: [3] ELBO (-6.204548) evaluations: (126) -#> Path [9] :Initial log joint density = -6.795862 +#> 5 -6.748e+00 3.451e-04 2.910e-06 1.000e+00 1.000e+00 126 -6.200e+00 -6.200e+00 +#> Path [8] :Best Iter: [2] ELBO (-6.176862) evaluations: (126) +#> Path [9] :Initial log joint density = -7.868746 #> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 3 -6.748e+00 3.609e-03 4.044e-05 9.535e-01 9.535e-01 76 -6.173e+00 -6.173e+00 -#> Path [9] :Best Iter: [3] ELBO (-6.172749) evaluations: (76) -#> Path [10] :Initial log joint density = -7.466078 +#> 5 -6.748e+00 1.971e-04 1.133e-06 1.000e+00 1.000e+00 126 -6.234e+00 -6.234e+00 +#> Path [9] :Best Iter: [4] ELBO (-6.211410) evaluations: (126) +#> Path [10] :Initial log joint density = -6.753679 #> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 7.983e-04 1.992e-06 1.000e+00 1.000e+00 126 -6.169e+00 -6.169e+00 -#> Path [10] :Best Iter: [5] ELBO (-6.168690) evaluations: (126) -#> Total log probability function evaluations:1235 -#> Pareto k value (0.97) is greater than 0.7. Importance resampling was not able to improve the approximation, which may indicate that the approximation itself is poor. +#> 3 -6.748e+00 9.064e-04 2.757e-05 1.000e+00 1.000e+00 76 -6.257e+00 -6.257e+00 +#> Path [10] :Best Iter: [2] ELBO (-6.157033) evaluations: (76) +#> Total log probability function evaluations:1260 #> Finished in 0.2 seconds. # Specifying initial values as a function diff --git a/docs/reference/model-method-sample_mpi.html b/docs/reference/model-method-sample_mpi.html index 5aab9dce2..6a265288c 100644 --- a/docs/reference/model-method-sample_mpi.html +++ b/docs/reference/model-method-sample_mpi.html @@ -43,7 +43,7 @@ @@ -526,7 +526,6 @@Examples
# fit <- mod$sample_mpi(..., mpi_args = list("n" = 4)) # } - diff --git a/docs/reference/model-method-variables.html b/docs/reference/model-method-variables.html index 208a40b12..c30ec812b 100644 --- a/docs/reference/model-method-variables.html +++ b/docs/reference/model-method-variables.html @@ -24,7 +24,7 @@ diff --git a/docs/reference/model-method-variational-1.png b/docs/reference/model-method-variational-1.png index aa185638c..35206a7af 100644 Binary files a/docs/reference/model-method-variational-1.png and b/docs/reference/model-method-variational-1.png differ diff --git a/docs/reference/model-method-variational-2.png b/docs/reference/model-method-variational-2.png index 4cf81fa80..b078570c6 100644 Binary files a/docs/reference/model-method-variational-2.png and b/docs/reference/model-method-variational-2.png differ diff --git a/docs/reference/model-method-variational-3.png b/docs/reference/model-method-variational-3.png index c67b37ed1..35367ed42 100644 Binary files a/docs/reference/model-method-variational-3.png and b/docs/reference/model-method-variational-3.png differ diff --git a/docs/reference/model-method-variational.html b/docs/reference/model-method-variational.html index 68afc88a7..0837588e6 100644 --- a/docs/reference/model-method-variational.html +++ b/docs/reference/model-method-variational.html @@ -27,7 +27,7 @@ @@ -413,7 +413,7 @@Examples
# Otherwise use the `path` argument to specify the location of your # CmdStan installation.) set_cmdstan_path(path = NULL) -#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.35.0 +#> CmdStan path set to: /Users/jgabry/.cmdstan/cmdstan-2.36.0 # Create a CmdStanModel object from a Stan program, # here using the example model that comes with CmdStan @@ -515,8 +515,8 @@Examples
#> # A tibble: 2 × 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__ -7.30 -7.00 0.811 0.344 -8.83 -6.75 1.00 702. 776. -#> 2 theta 0.254 0.238 0.125 0.124 0.0807 0.483 1.00 634. 580. +#> 1 lp__ -7.35 -7.01 0.882 0.353 -9.14 -6.75 1.00 724. 896. +#> 2 theta 0.254 0.239 0.129 0.126 0.0737 0.488 1.00 532. 657. # Check sampling diagnostics fit_mcmc$diagnostic_summary() @@ -527,7 +527,7 @@Examples
#> [1] 0 0 #> #> $ebfmi -#> [1] 1.1148699 0.8012192 +#> [1] 1.1148479 0.7568734 #> # Get posterior draws @@ -537,22 +537,22 @@Examples
#> , , variable = lp__ #> #> chain -#> iteration 1 2 -#> 1 -7.0 -6.8 -#> 2 -7.9 -6.9 -#> 3 -7.4 -6.8 -#> 4 -6.7 -6.8 -#> 5 -6.9 -10.2 +#> iteration 1 2 +#> 1 -7.0 -8.1 +#> 2 -7.9 -7.9 +#> 3 -7.4 -7.0 +#> 4 -6.7 -6.8 +#> 5 -6.9 -6.8 #> #> , , variable = theta #> #> chain -#> iteration 1 2 -#> 1 0.17 0.23 -#> 2 0.46 0.18 -#> 3 0.41 0.28 -#> 4 0.25 0.23 -#> 5 0.18 0.62 +#> iteration 1 2 +#> 1 0.17 0.088 +#> 2 0.46 0.097 +#> 3 0.41 0.167 +#> 4 0.25 0.292 +#> 5 0.18 0.238 #> #> # ... with 995 more iterations @@ -578,11 +578,6 @@Examples
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.-# For models fit using MCMC, if you like working with RStan's stanfit objects -# then you can create one with rstan::read_stan_csv() -# stanfit <- rstan::read_stan_csv(fit_mcmc$output_files()) - - # Run 'optimize' method to get a point estimate (default is Stan's LBFGS algorithm) # and also demonstrate specifying data as a path to a file instead of a list my_data_file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.data.json") @@ -592,7 +587,7 @@
Examples
#> 6 -5.00402 0.000246518 8.73164e-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 @@ -603,12 +598,12 @@Examples
# 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.9339 +#> Initial log joint probability = -19.2814 #> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes -#> 4 -6.74802 0.000281861 5.43768e-05 0.9238 0.9238 7 +#> 5 -6.74802 0.000163806 1.63613e-06 1 1 8 #> Optimization terminated normally: #> Convergence detected: relative gradient magnitude is below tolerance -#> Finished in 0.2 seconds. +#> Finished in 0.1 seconds. fit_laplace <- mod$laplace(data = my_data_file, mode = fit_optim, draws = 2000) #> Calculating Hessian #> Calculating inverse of Cholesky factor @@ -633,14 +628,14 @@Examples
#> iteration: 1700 #> iteration: 1800 #> iteration: 1900 -#> Finished in 0.1 seconds. +#> Finished in 0.2 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.25 -6.97 0.728 0.304 -8.74 -6.75 -#> 2 lp_approx__ -0.505 -0.230 0.714 0.313 -2.05 -0.00175 -#> 3 theta 0.271 0.250 0.125 0.120 0.105 0.511 +#> variable mean median sd mad q5 q95 +#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> +#> 1 lp__ -7.24 -6.96 0.752 0.292 -8.69 -6.75 +#> 2 lp_approx__ -0.496 -0.208 0.731 0.290 -1.95 -0.00172 +#> 3 theta 0.270 0.248 0.123 0.116 0.0971 0.507 # Run 'variational' method to use ADVI to approximate posterior fit_vb <- mod$variational(data = stan_data, seed = 123) @@ -649,8 +644,8 @@Examples
#> This procedure has not been thoroughly tested and may be unstable #> or buggy. The interface is subject to change. #> ------------------------------------------------------------ -#> Gradient evaluation took 1.2e-05 seconds -#> 1000 transitions using 10 leapfrog steps per transition would take 0.12 seconds. +#> Gradient evaluation took 1.1e-05 seconds +#> 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds. #> Adjust your expectations accordingly! #> Begin eta adaptation. #> Iteration: 1 / 250 [ 0%] (Adaptation) @@ -697,7 +692,7 @@Examples
#> 5 -6.748e+00 2.145e-04 1.301e-06 1.000e+00 1.000e+00 126 -6.197e+00 -6.197e+00 #> Path [4] :Best Iter: [5] ELBO (-6.197118) evaluations: (126) #> Total log probability function evaluations:4379 -#> Finished in 0.1 seconds. +#> Finished in 0.2 seconds. fit_pf$summary() #> # A tibble: 3 × 7 #> variable mean median sd mad q5 q95 @@ -714,48 +709,49 @@Examples
fit_pf <- mod$pathfinder(data = stan_data, num_paths=10, single_path_draws=40, history_size=50, max_lbfgs_iters=100) #> Warning: Number of PSIS draws is larger than the total number of draws returned by the single Pathfinders. This is likely unintentional and leads to re-sampling from the same draws. -#> Path [1] :Initial log joint density = -7.129286 +#> Path [1] :Initial log joint density = -6.777948 #> Path [1] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 3.516e-03 7.903e-05 1.000e+00 1.000e+00 101 -6.220e+00 -6.220e+00 -#> Path [1] :Best Iter: [4] ELBO (-6.220449) evaluations: (101) -#> Path [2] :Initial log joint density = -17.101498 +#> 4 -6.748e+00 1.327e-04 3.358e-07 1.000e+00 1.000e+00 101 -6.183e+00 -6.183e+00 +#> Path [1] :Best Iter: [4] ELBO (-6.183163) evaluations: (101) +#> Path [2] :Initial log joint density = -8.072775 #> Path [2] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.403e-03 3.837e-05 1.000e+00 1.000e+00 126 -6.233e+00 -6.233e+00 -#> Path [2] :Best Iter: [3] ELBO (-6.158188) evaluations: (126) -#> Path [3] :Initial log joint density = -7.224287 +#> 5 -6.748e+00 2.399e-04 1.562e-06 1.000e+00 1.000e+00 126 -6.271e+00 -6.271e+00 +#> Path [2] :Best Iter: [4] ELBO (-6.239963) evaluations: (126) +#> Path [3] :Initial log joint density = -9.025342 #> Path [3] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 2.662e-04 2.842e-07 1.000e+00 1.000e+00 126 -6.221e+00 -6.221e+00 -#> Path [3] :Best Iter: [2] ELBO (-6.190753) evaluations: (126) -#> Path [4] :Initial log joint density = -7.290267 +#> 5 -6.748e+00 3.454e-04 2.916e-06 1.000e+00 1.000e+00 126 -6.285e+00 -6.285e+00 +#> Path [3] :Best Iter: [2] ELBO (-6.207932) evaluations: (126) +#> Path [4] :Initial log joint density = -9.983004 #> Path [4] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 4 -6.748e+00 5.139e-03 1.484e-04 1.000e+00 1.000e+00 101 -6.253e+00 -6.253e+00 -#> Path [4] :Best Iter: [3] ELBO (-6.223795) evaluations: (101) -#> Path [5] :Initial log joint density = -11.338980 +#> 5 -6.748e+00 6.283e-04 7.448e-06 1.000e+00 1.000e+00 126 -6.267e+00 -6.267e+00 +#> Path [4] :Best Iter: [3] ELBO (-6.107202) evaluations: (126) +#> Path [5] :Initial log joint density = -13.400879 #> Path [5] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.023e-03 1.591e-05 1.000e+00 1.000e+00 126 -6.195e+00 -6.195e+00 -#> Path [5] :Best Iter: [5] ELBO (-6.194597) evaluations: (126) -#> Path [6] :Initial log joint density = -16.944885 +#> 5 -6.748e+00 1.809e-03 4.509e-05 1.000e+00 1.000e+00 126 -6.206e+00 -6.206e+00 +#> Path [5] :Best Iter: [4] ELBO (-6.199332) evaluations: (126) +#> Path [6] :Initial log joint density = -7.627321 #> Path [6] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.484e-03 4.148e-05 1.000e+00 1.000e+00 126 -6.227e+00 -6.227e+00 -#> Path [6] :Best Iter: [3] ELBO (-6.204972) evaluations: (126) -#> Path [7] :Initial log joint density = -6.748701 +#> 5 -6.748e+00 1.419e-04 6.650e-07 1.000e+00 1.000e+00 126 -6.197e+00 -6.197e+00 +#> Path [6] :Best Iter: [4] ELBO (-6.176730) evaluations: (126) +#> Path [7] :Initial log joint density = -13.719529 #> Path [7] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 3 -6.748e+00 1.200e-04 1.293e-06 1.000e+00 1.000e+00 76 -6.259e+00 -6.259e+00 -#> Path [7] :Best Iter: [2] ELBO (-6.149195) evaluations: (76) -#> Path [8] :Initial log joint density = -6.748408 +#> 5 -6.748e+00 1.898e-03 4.974e-05 1.000e+00 1.000e+00 126 -6.198e+00 -6.198e+00 +#> Path [7] :Best Iter: [5] ELBO (-6.198257) evaluations: (126) +#> Path [8] :Initial log joint density = -8.734378 #> Path [8] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 2 -6.748e+00 1.425e-02 1.473e-04 1.000e+00 1.000e+00 51 -6.207e+00 -6.207e+00 -#> Path [8] :Best Iter: [2] ELBO (-6.206834) evaluations: (51) -#> Path [9] :Initial log joint density = -15.458578 +#> 5 -6.748e+00 3.325e-04 2.705e-06 1.000e+00 1.000e+00 126 -6.215e+00 -6.215e+00 +#> Path [8] :Best Iter: [3] ELBO (-6.210584) evaluations: (126) +#> Path [9] :Initial log joint density = -15.787917 #> Path [9] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 5 -6.748e+00 1.991e-03 6.002e-05 1.000e+00 1.000e+00 126 -6.285e+00 -6.285e+00 -#> Path [9] :Best Iter: [2] ELBO (-6.192523) evaluations: (126) -#> Path [10] :Initial log joint density = -6.748883 +#> 5 -6.748e+00 1.925e-03 5.805e-05 1.000e+00 1.000e+00 126 -6.251e+00 -6.251e+00 +#> Path [9] :Best Iter: [3] ELBO (-6.246013) evaluations: (126) +#> Path [10] :Initial log joint density = -7.311648 #> Path [10] : Iter log prob ||dx|| ||grad|| alpha alpha0 # evals ELBO Best ELBO Notes -#> 3 -6.748e+00 1.441e-04 1.727e-06 1.000e+00 1.000e+00 76 -6.246e+00 -6.246e+00 -#> Path [10] :Best Iter: [3] ELBO (-6.246075) evaluations: (76) -#> Total log probability function evaluations:1185 -#> Finished in 0.1 seconds. +#> 4 -6.748e+00 5.348e-03 1.585e-04 1.000e+00 1.000e+00 101 -6.229e+00 -6.229e+00 +#> Path [10] :Best Iter: [3] ELBO (-6.203261) evaluations: (101) +#> Total log probability function evaluations:1360 +#> Pareto k value (0.78) 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.2 seconds. # Specifying initial values as a function fit_mcmc_w_init_fun <- mod$sample( @@ -772,7 +768,7 @@Examples
#> #> Both chains finished successfully. #> Mean chain execution time: 0.0 seconds. -#> Total execution time: 0.3 seconds. +#> Total execution time: 0.4 seconds. #> fit_mcmc_w_init_fun_2 <- mod$sample( data = stan_data, diff --git a/docs/reference/read_cmdstan_csv.html b/docs/reference/read_cmdstan_csv.html index 37124bfc0..ab7ebbaae 100644 --- a/docs/reference/read_cmdstan_csv.html +++ b/docs/reference/read_cmdstan_csv.html @@ -22,7 +22,7 @@ @@ -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/RtmpiACQ3q/logistic-202407021545-1-30065a.csv" -#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021545-2-30065a.csv" -#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021545-3-30065a.csv" -#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-202407021545-4-30065a.csv" +#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-202503310849-1-4ed0d7.csv" +#> [2] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-202503310849-2-4ed0d7.csv" +#> [3] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-202503310849-3-4ed0d7.csv" +#> [4] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-202503310849-4-4ed0d7.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.68 -0.67 0.25 0.25 -1.10 -0.27 1.00 3980 2575 -#> beta[2] -0.26 -0.26 0.22 0.22 -0.64 0.09 1.00 4323 3108 -#> beta[3] 0.68 0.67 0.27 0.26 0.26 1.13 1.00 4167 3210 +#> beta[1] -0.66 -0.66 0.25 0.24 -1.07 -0.27 1.00 3828 2751 +#> beta[2] -0.27 -0.27 0.23 0.22 -0.65 0.09 1.00 4397 2844 +#> beta[3] 0.68 0.68 0.27 0.28 0.24 1.13 1.00 4288 2907 # Using read_cmdstan_csv # @@ -246,9 +246,9 @@Examples
#> List of 8 #> $ metadata :List of 42 #> ..$ stan_version_major : num 2 -#> ..$ stan_version_minor : num 35 +#> ..$ stan_version_minor : num 36 #> ..$ stan_version_patch : num 0 -#> ..$ start_datetime : chr "2024-07-02 21:45:26 UTC" +#> ..$ start_datetime : chr "2025-03-31 14:49:26 UTC" #> ..$ method : chr "sample" #> ..$ save_warmup : int 1 #> ..$ thin : num 1 @@ -266,15 +266,15 @@Examples
#> ..$ num_chains : num 1 #> ..$ id : num [1:4] 1 2 3 4 #> ..$ init : num [1:4] 2 2 2 2 -#> ..$ seed : num 2.06e+09 +#> ..$ seed : num 1.72e+09 #> ..$ refresh : num 100 #> ..$ sig_figs : num -1 -#> ..$ profile_file : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/logistic-profile-202407021545-1-8f8eaa.csv" +#> ..$ profile_file : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/logistic-profile-202503310849-1-480225.csv" #> ..$ save_cmdstan_config : int 0 -#> ..$ stanc_version : chr "stanc3 v2.35.0" +#> ..$ stanc_version : chr "stanc3 v2.36.0" #> ..$ 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.753 0.696 0.766 0.757 +#> ..$ step_size_adaptation: num [1:4] 0.785 0.802 0.787 0.715 #> ..$ model_name : chr "logistic_model" #> ..$ adapt_engaged : int 1 #> ..$ adapt_delta : num 0.8 @@ -285,9 +285,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.119 0.121 0.128 0.12 -#> .. ..$ sampling: num [1:4] 0.129 0.131 0.122 0.118 -#> .. ..$ total : num [1:4] 0.248 0.252 0.25 0.238 +#> .. ..$ warmup : num [1:4] 0.077 0.077 0.076 0.078 +#> .. ..$ sampling: num [1:4] 0.071 0.074 0.073 0.077 +#> .. ..$ total : num [1:4] 0.148 0.151 0.149 0.155 #> ..$ stan_variable_sizes :List of 4 #> .. ..$ lp__ : num 1 #> .. ..$ alpha : num 1 @@ -299,35 +299,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.119 0.121 0.128 0.12 -#> .. ..$ sampling: num [1:4] 0.129 0.131 0.122 0.118 -#> .. ..$ total : num [1:4] 0.248 0.252 0.25 0.238 +#> .. ..$ warmup : num [1:4] 0.077 0.077 0.076 0.078 +#> .. ..$ sampling: num [1:4] 0.071 0.074 0.073 0.077 +#> .. ..$ total : num [1:4] 0.148 0.151 0.149 0.155 #> $ inv_metric :List of 4 -#> ..$ 1: num [1:4] 0.0537 0.06 0.0539 0.075 -#> ..$ 2: num [1:4] 0.0427 0.0583 0.0515 0.083 -#> ..$ 3: num [1:4] 0.0455 0.062 0.0441 0.0752 -#> ..$ 4: num [1:4] 0.0443 0.0707 0.0544 0.0781 +#> ..$ 1: num [1:4] 0.0414 0.0575 0.0508 0.0651 +#> ..$ 2: num [1:4] 0.0478 0.0564 0.0458 0.068 +#> ..$ 3: num [1:4] 0.0464 0.0556 0.0444 0.0718 +#> ..$ 4: num [1:4] 0.0418 0.0554 0.0495 0.078 #> $ step_size :List of 4 -#> ..$ 1: num 0.753 -#> ..$ 2: num 0.696 -#> ..$ 3: num 0.766 -#> ..$ 4: num 0.757 -#> $ warmup_draws : 'draws_array' num [1:1000, 1:4, 1:105] -77.2 -77.2 -77.2 -65.2 -65.2 ... +#> ..$ 1: num 0.785 +#> ..$ 2: num 0.802 +#> ..$ 3: num 0.787 +#> ..$ 4: num 0.715 +#> $ warmup_draws : 'draws_array' num [1:1000, 1:4, 1:105] -82.8 -82.8 -82.8 -70.9 -67.5 ... #> ..- 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] -67.2 -64.2 -64.3 -65.2 -66.3 ... +#> $ post_warmup_draws : 'draws_array' num [1:1000, 1:4, 1:105] -64.9 -64.9 -66.2 -65.8 -65 ... #> ..- 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] 0.749 0 0 0.978 0.989 ... +#> $ warmup_sampler_diagnostics : 'draws_array' num [1:1000, 1:4, 1:6] 6.67e-01 0.00 1.24e-316 9.96e-01 1.00 ... #> ..- 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.865 1 0.991 0.942 0.714 ... +#> $ post_warmup_sampler_diagnostics: 'draws_array' num [1:1000, 1:4, 1:6] 1 0.983 0.825 0.992 0.992 ... #> ..- 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/read_sample_csv.html b/docs/reference/read_sample_csv.html index 9254a250a..1b99583c3 100644 --- a/docs/reference/read_sample_csv.html +++ b/docs/reference/read_sample_csv.html @@ -17,7 +17,7 @@ diff --git a/docs/reference/register_knitr_engine.html b/docs/reference/register_knitr_engine.html index efda0c271..fe4a508e3 100644 --- a/docs/reference/register_knitr_engine.html +++ b/docs/reference/register_knitr_engine.html @@ -20,7 +20,7 @@ diff --git a/docs/reference/set_cmdstan_path.html b/docs/reference/set_cmdstan_path.html index 1a31d8bed..db4659663 100644 --- a/docs/reference/set_cmdstan_path.html +++ b/docs/reference/set_cmdstan_path.html @@ -21,7 +21,7 @@ diff --git a/docs/reference/stan_threads.html b/docs/reference/stan_threads.html index 1875658f4..ebcfa75a1 100644 --- a/docs/reference/stan_threads.html +++ b/docs/reference/stan_threads.html @@ -17,7 +17,7 @@ diff --git a/docs/reference/write_stan_file.html b/docs/reference/write_stan_file.html index efb1bdff8..0645c8402 100644 --- a/docs/reference/write_stan_file.html +++ b/docs/reference/write_stan_file.html @@ -24,7 +24,7 @@ @@ -188,7 +188,7 @@Examples
f <- write_stan_file(stan_program) print(f) -#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpiACQ3q/model_7f12fc190dd23b0e462f7d73040dd97e.stan" +#> [1] "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpWzIPg0/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 92151a5c8..2f027f915 100644 --- a/docs/reference/write_stan_json.html +++ b/docs/reference/write_stan_json.html @@ -17,7 +17,7 @@ @@ -167,13 +167,13 @@Examples
#> "N": 5, #> "K": 2, #> "x": [ -#> [-1.3149626812135, -0.191761909283258], -#> [1.70603877388749, -0.282224274118901], -#> [0.177503683488102, -0.683561574477846], -#> [-0.393377531770713, 0.580194679530021], -#> [0.578306036031158, -1.06993557582488] +#> [0.594273774110513, 0.718888729854143], +#> [0.0591351681787969, 0.251651069028968], +#> [0.413398894737046, 1.35727443615177], +#> [-1.09777217457042, 0.404468471278607], +#> [0.711175257270441, 0.264364269837939] #> ], -#> "y": [10, 9, 8, 12, 11], +#> "y": [10, 11, 13, 11, 12], #> "z": [1, 0] #> } diff --git a/docs/reference/write_stan_tempfile.html b/docs/reference/write_stan_tempfile.html index efc551cde..5891e81a2 100644 --- a/docs/reference/write_stan_tempfile.html +++ b/docs/reference/write_stan_tempfile.html @@ -17,7 +17,7 @@ diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 93d8ac089..f502670b8 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -30,9 +30,6 @@- https://mc-stan.org/cmdstanr/articles/index.html - https://mc-stan.org/cmdstanr/articles/opencl.html -https://mc-stan.org/cmdstanr/articles/posterior.html