$sample() reads each chain's CSV file once instead of twice. The columns
of $sampler_diagnostics() are now in the order of the CSV file. (#1312)
as_cmdstan_fit() now reads draws from the CSV files when they're first
requested (like fits from $sample() do). Reading a large fit to look at a few
variables takes much less memory. (#1294)
read_cmdstan_csv() and as_cmdstan_fit() can now read gzip-compressed
CmdStan CSV files ending in .csv.gz and bzip2-compressed files ending in
.csv.bz2. CmdStanR now requires data.table 1.18.0 or later. (#1027, #1217)
check_cmdstan_toolchain() now waits longer for WSL to respond and
says so when it doesn't, instead of reporting that no WSL distribution
is installed. (#1297)
$log_prob(), $grad_log_prob(), and other model methods are now faster
after initialization because they avoid repeated stale-binding checks. (#1274)
install_cmdstan() now retries a download without the token if GitHub
rejects the one in GITHUB_PAT, and warns the token may not be valid. (#909)
install_cmdstan() now offers to copy the make/local flags of the
current installation into the new one before building it, so the new CmdStan is
built with the same flags. In an interactive session it shows the previous
make/local and asks if the copy_make_local argument isn't set to TRUE or
FALSE. (#1267)
cmdstan_make_local() now skips flags that are already in make/local.
Previously copying the flags of a previous installation after every upgrade
added the same lines again each time. (#1266)
Chain IDs in generated filenames are now zero-padded to at least two digits,
for example 01 instead of 1. (#1244)
When using CmdStan through WSL, paths for output, diagnostic, profile, config, and metric files now remain accessible to Windows R when an explicit output directory is supplied. (#1110; related: #1113)
Lists of matrices/vectors and data frames can now be supplied for variables
declared as int in the Stan program. Previously these worked only for real
variables and errored for int ones. (#817)
Data frame columns that are not numeric, integer, logical, or
factor are now an error. Previously data.matrix() silently coerced them, so a
character column reached Stan as alphabetically ordered integer codes. Convert
the column explicitly, e.g. with as.integer(), if integer codes are what you
want. (#1225)
Lists of logical vectors/matrices are now converted to integers like logical variables are, instead of erroring. (#1225)
Supplying a factor for a variable not declared as int is now an error. (#1225)
Factors are now accepted for length-1 int arrays (e.g. array[1] int x),
which previously errored. (#1225)
The CMDSTANR_NO_VER_CHECK R option and environment variable are deprecated
as of CmdStanR 1.0.0; use the lowercase cmdstanr_no_ver_check forms instead.
check_cmdstan_toolchain() now locates Windows toolchains using R_TOOLS_SOFT and falls back to PATH, improving support for alternate R distributions and future Rtools releases. (#1211)
$compile() now works with named stanc_options values such as
canonicalize. The values were shell-quoted for Make and the same quoted
strings were also passed to stanc directly, which rejected them. (#1227)
$compile() now enables allow-undefined for user headers supplied through
cpp_options, not just through the user_header argument. $check_syntax()
and $format() also now correctly enable allow-undefined for models that use
a user header. (#1227, #1234)
stanc failures during $compile() are now reported immediately, with the
stanc error message. Previously they surfaced several steps later. (#1227)
Errors for include paths that do not exist now report the resolved absolute path. (#1227)
Numeric stanc_options values such as list("max-line-length" = 78) are no
longer dropped. (#1233)
$compile() now refreshes $code() and $variables() after a successful
compilation. (#1228)
$compile() now discards standalone functions exposed from an earlier
version of the Stan program. They must be exposed again with
$expose_functions() after a recompilation. (#1228)
$compile() now reuses the include paths and the user header of the previous
compilation when they are not supplied again. Recompiling a model that uses
#include directives or a user header through the same object previously
failed because those inputs were dropped. (#1234)
$compile() now recompiles when include_paths change. Previously the model
went on using the executable built against the old paths while $variables()
and $include_paths() described the new ones, so data and initial values were
validated against a program that was not running. (#1235)
A user_header supplied to cmdstan_model() is now used by a later
$compile(). Previously it was only honored when the model was compiled
immediately. (#1234)
$compile() now accepts user_header = NULL to compile without a user
header. Previously a header, once supplied, could not be removed. (#1235)
$compile() now recompiles when the user header changes. Previously a
different header was ignored if the executable was otherwise up to date. (#1235)
$compile() now reduces duplicate USER_HEADER/user_header entries in
cpp_options to the one actually used, so $cpp_options() no longer reports
the ignored spelling after a successful compilation. (#1235)
A $compile() call that finds the executable up to date no longer erases
$cpp_options(). (#1235)
$expose_functions() now works after a $compile() call that found the
executable up to date. (#1235)
$expose_functions() on a model with no executable, such as one created with
compile = FALSE or compiled with dry_run = TRUE, now reports that it cannot
expose functions instead of failing with "argument is of length zero". (#1235)
A failed compilation no longer moves $exe_file() or replaces the generated
C++ used by $hpp_file() and fit$init_model_methods(). Previously a failure
at the C++ stage left the old executable paired with model methods generated
from the new program. (#1235)
$compile() now warns when cpp_options are supplied but the existing
executable is up to date, so nothing is rebuilt and the options are not applied.
The check is best effort. For an executable the model object compiled itself it
compares the options passed to Make against those requested, and treats
anything the binary reports but was never passed as inherited from make/local
and so unchanged by a rebuild. For one adopted from an earlier session only the
few STAN_* flags the binary reports can be checked, and anything else passes
unremarked. It can also warn when nothing would in fact change: an option
inherited from make/local that the binary does not report looks like a request
the executable lacks, and one that was both passed explicitly and set in
make/local looks like something a rebuild would drop when it would be
inherited again. Use force_recompile = TRUE when a supplied option has to take
effect. (#1235)
$cpp_options() now also reports options the executable was built with that
were never passed to $compile(), such as those inherited from make/local,
when the binary reports them. $sample() and friends previously refused
threads_per_chain for an executable that did have threading. (#1019, #1235)
cmdstan_model() no longer runs the model executable twice to read its build
metadata. (#1236)
$cpp_options() no longer reports options the executable was not built with.
Previously a request that did not rebuild the model was recorded as though it
had, so $sample() could fail with "the model executable was built with
threading enabled" for a binary that had no threading. (#1019, #1235)
$format(overwrite_file = TRUE) now refreshes $variables() along with
$code(), which previously kept describing the program as it was before
formatting. (#1235)
$compile() now errors if the newly compiled executable cannot be installed,
restoring the previous executable. Previously the replacement was unchecked, so
a failure could silently leave the model with no executable at all. (#1235)
$compile() now errors instead of installing an executable over a directory.
An executable path that names a directory, which $exe_file() and
cmdstan_model(exe_file = ) both accept without checking, previously had that
directory renamed aside as though it were the old executable and a file put in
its place. (#1235)
$compile() now checks that it can record the compiled model before replacing
the executable, so a failure at that point can no longer leave a new executable
on disk that the model object knows nothing about. (#1235)
A duplicated USER_HEADER or user_header entry in cpp_options now selects
the last one, matching what Make does with repeated assignments. Previously
the first was compiled with and the rest were left in cpp_options. (#1235)
A USER_HEADER or user_header entry in cpp_options set to NULL now
clears a previously configured user header instead of being ignored. It stands
for an explicit USER_HEADER=, which Make takes as clearing anything set
before it, so the model previously compiled with no header while continuing to
report the old one. (#1235)
A $compile() that fails because the user header does not exist now still
records the header. Previously the request was discarded, so $check_syntax()
and $format() reported the model's own undefined functions as errors and a
bare retry after creating the file compiled with no header at all. (#1235)
CmdStanModel methods now correctly handle #include directories with spaces
in their paths. (#820)
$include_paths() now returns absolute paths, and relative include paths are
resolved when the model object is created or $compile() is called rather than
on each stanc call. Previously a model created from a relative path could
resolve #include directives against the wrong directory if the working
directory changed. (#1229)
$cpp_options() no longer includes a STAN_VERSION entry read from the model
executable's metadata. It was never a C++ option; use $cmdstan_version() instead. (#1215)
CmdStanModel methods now use executable metadata regardless of the
capitalization of C++ option names. Any executable reporting threading enabled
requires the corresponding threads or threads_per_chain argument. (#765, #1100)
Pathfinder fits used as initial values now use uniform weights when CmdStan already PSIS-resampled their draws, avoiding a second application of importance weights. (#1206)
Pathfinder fits used as initial values now correctly treat draws with different initialization parameter values as distinct even when their log weights are equal, and collapse duplicate resampled draws while retaining their selection frequency. (#1207)
pathfinder() now passes separately supplied initial values to every path
instead of using only the first path's initial values. (#1206)
pathfinder() now respects save_single_paths = TRUE instead of always
passing 0 to CmdStan.
pathfinder() now uses threads argument (num_threads is deprecated),
to be consistent with other methods.
The num_paths documentation for pathfinder() now notes that running
multiple paths in parallel requires compiling with
cpp_options = list(stan_threads = TRUE) and setting threads. (#896)
The save_latent_dynamics argument is now limited to $sample(),
$sample_mpi(), and $variational(), matching the CmdStan algorithms
that support diagnostic CSV output.
Informative error when exposing functions using names that are reserved keywords (@VisruthSK, #1154)
save_cmdstan_config and save_metric default to FALSE but can be
set to TRUE for an entire R session via new global options. (#1159)
The compilation spinner can now be disabled for an entire R session by setting
the new cmdstanr_spinner global option to FALSE. The spinner shown while
installing or rebuilding CmdStan and while checking syntax also respects this
option, and is no longer shown when knitting. (#486)
save_metric_files() now gives an informative error when metric files were
not created and keeps saved metric files after the fitted model is garbage-collected. (#1021)
cmdstan_model() no longer fails when MAKEFLAGS enables directory-printing
output while reading STANCFLAGS from make. (#1163)
cmdstan_model() now retains include paths when initialized with both a Stan file
and a precompiled executable (#1094).
$generate_quantities() now also accepts CmdStanMLE, CmdStanLaplace,
and CmdStanPathfinder fitted model objects as fitted_params. (#1203)
$generate_quantities() now reports per-process execution times with
CmdStan 2.39 or newer, and read_cmdstan_csv() returns these times from
standalone generated quantities CSV files. (#1168)
laplace() no longer overwrites the internally generated optimizer CSV when
mode = NULL and output_basename is supplied. The internally generated
optimizer CSV now uses the filename <output_basename>-mode-01.csv.
CmdStanModel objects created using compile_model_methods = TRUE that are
then saved and reloaded no longer error in model fitting methods. Model methods
are recompiled lazily if needed. (#1158)
CmdStan versions older than 2.35.0 are no longer supported. (#1144)
Minimum R version increased to 4.0.0. (#1144)
Removed legacy Windows toolchain paths for older CmdStan releases. (#1144)
CMDSTANR_USE_MSYS_TOOLCHAIN is now deprecated and ignored (with a warning). (#1144)
Removed deprecated items (replacements in parentheses). (#1061)
read_sample_csv() (read_cmdstan_csv())write_stan_tempfile() (write_stan_file())jacobian_adjustment argument to fit$log_prob() and similar methods (jacobian argument)output_samples argument to model$variational() (draws argument)hessian argument to fit$init_model_methods() (hessian method always compiled now)model$compile():
threads (cpp_options = list(stan_threads = TRUE))compile_hessian_method (always compiled)model$sample():
cores and num_cores (parallel_chains)num_chains (chains)num_warmup (iter_warmup)num_samples (iter_sampling)validate_csv (diagnostics)save_extra_diagnostics (save_latent_dynamics)max_depth (max_treedepth)stepsize (step_size)sampler_diagnostics() with fixed_param=TRUEloo method (#1057)loo method (#1015)make (#1036)untar to fix installation errors (#1034)make/local when exposing functions or model methods (#1003)optimize and loo methods (#1060)rstan::read_stan_csv due to incompatibility with newer CmdStan outputs (#1018)cmdstanr_print_line_numbers for printing line numbers (#1017)CMDSTANR_USE_RTOOLS environment variable to force stock RTools on Windows by @andrjohns in #980inc_warmup argument to $unconstrain_draws() by @andrjohns in #985$unconstrain_draws() returning incorrect assumptions in some cases by @andrjohns in #983CmdStanFit objects as initial values by @SteveBronder in #937show_messages and show_exceptions arguments to all methods for controlling output by @andrjohns in #897unconstrain_draws() method to specify draws format of return by @andrjohns in #886cmdstanr EBFMI diagnostic threshold with CmdStan by @andrjohns in #892cmdstanr_print_line_numbers to add line number to model printing by @sbfnk in #967save_metric and save_cmdstan_config by @venpopov in #932rstan::extract() using a combination of cmdstanr and posterior by @jgabry in #955psis_resample and calculate_lp arguments added to Pathfinder method by @SteveBronder in #903cmdstanr_warn_inits added to disable warnings about partially specified initial values by @jgabry in #913output_dir documentation by @jgabry in #929num_paths by @andrjohns in #964compile_stanalone=TRUE but no functions are found by @jgabry in #956inv_metric argument with only 1 parameter by @venpopov in #935laplace method by @jgabry in #800pathfinder method by @SteveBronder in #848jacobian_adjustment argument to jacobian by @jgabry in #879expose_functions() method to expose Stan functions to R by @andrjohns in #702. See ?expose_functions.?init_model_methods.wsl=TRUE in install_cmdstan() to install CmdStan
for use with WSL. This can offer significant speedups compared to native
Windows execution. (#677, @andrjohns)In cmdstan_default_path() we now ignore directories inside .cmdstan that don't start
with "cmdstan-". (#651)
Fixed Windows issue related to not locating grep.exe or when it is located in a path
with spaces. (@weshinsley, #661, #663)
Fixed a bug with diagnostic checks when ebfmi is NaN.
Fixed a bug that caused issues when using ~ or . in paths supplied to the
cmdstanr_write_stan_file_dir global option.
Fixed a bug that caused the time() method fail when some of the chains failed to finish
succesfully.
Refactored toolchain installation and checks for R 4.x on Windows and added support for Rtools42. (#645)
Expanded the use of CMDSTAN environment variable to point to CmdStan installation
or directory containing CmdStan installations. (#643)
New vignette on how to handle deprecations using the $format() method. (#644)
format="draws_rvars" in the $draws() method due to a
bug. Until this is fixed users can make use of posterior::as_draws_rvars() to
convert draws from CmdStanR to the draws_rvars format. (#640)Fixed bug that caused stdour/stderr not being read at the end of optimization. (#522)
Fixed issue with handling NA as the reported external process
status. (#544, @myshkin)
Fixed issue with handling models with no parameters and CmdStan 2.27+.
Default directory changed to .cmdstan instead of .cmdstanr so that
CmdStanPy and CmdStanR can use the same CmdStan installations. Using .cmdstanr
will continue to be supported until version 1.0 but install_cmdstan() will now
default to .cmdstan and CmdStanR will first look for .cmdstan before falling
back on .cmdstanr. (#454)
New method diagnose() for CmdstanModel objects exposes CmdStan's diagnose
method for comparing Stan's gradient computations to gradients computed via
finite differences. (#485)
New method $variables() for CmdstanModel objects that returns a list of
variables in the Stan model, their types and number of dimensions. Does
not require the model to be compiled. (#519)
New method $format() for auto-formatting and canonicalizing the Stan models. (#625)
Added the option to create CmdStanModel from the executable only with the
exe_file argument. (#564)
Added a convenience argument user_header to $compile() and cmdstan_model()
that simplifies the use of an external .hpp file to compile with the model.
Added the cmdstanr_force_recompile global option that is used for forcing
recompilation of Stan models. (#580)
New method $code() for all fitted model objects that returns the Stan code
associated with the fitted model. (#575)
New method $diagnostic_summary() for CmdStanMCMC objects that summarizes the
sampler diagnostics (divergences, treedepth, ebfmi) and can regenerate the
related warning messages. (#205)
New diagnostics argument for the $sample() method to specify which
diagnostics are checked after sampling. Replaces validate_csv argument. (#205)
Added E-BFMI checks that run automatically post sampling. (#500, @jsocolar)
New methods for posterior::as_draws() for CmdStanR fitted model objects.
These are just wrappers around the $draws() method provided for convenience. (#532)
write_stan_file() now choose file names deterministically based on the code
so that models do not get unnecessarily recompiled when calling the function
multiple times with the same code. (#495, @martinmodrak)
The dir argument for write_stan_file() can now be set with a global
option. (#537)
write_stan_json() now handles data of class "table". Tables are converted
to vector, matrix, or array depending on the dimensions of the table. (#528)
Improved processing of named lists supplied to the data argument to JSON
data files: checking whether the list includes all required elements/Stan
variables; improved differentiating arrays/vectors of length 1 and scalars
when generating JSON data files; generating floating point numbers with
decimal points to fix issue with parsing large numbers. (#538)
install_cmdstan() now automatically installs the Linux ARM CmdStan when
Linux distributions running on ARM CPUs are detected. (#531)
New function as_mcmc.list() for converting CmdStanMCMC objects to mcmc.list
objects from the coda package. (#584, @MatsuuraKentaro)
Fixed issue with retrieving draws with models with spaces in their names. (#453)
Fixed bug with spaces in path to the temporary folder on Windows. (#460)
Fixed issue with not reporting model executable name clashing with folder name. (#461)
New function as_cmdstan_fit() that creates CmdStanMCMC/MLE/VB objects
directly from CmdStan CSV files. (#412)
read_cmdstan_csv() now also returns chain run times for MCMC sampling CSV
files. (#414)
Faster CSV reading for multiple chains. (#419)
New $profiles() method for fitted model objects accesses profiling
information from R if profiling used in the Stan program. Support for profiling
Stan programs requires CmdStan >= 2.26. (#434)
New vignette on profiling Stan programs. (#435)
New vignette on running Stan on the GPU with OpenCL. OpenCL device ids can now also be specified at runtime. (#439)
New check for invalid parameter names when supplying init values. (#452, @mike-lawrence)
Suppressing compilation messages when not in interactive mode. (#462, @wlandau)
New error_on_NA argument for cmdstan_version() to optionally return NULL
(instead of erroring) if the CmdStan path is not found (#467, @wlandau).
Global option cmdstanr_max_rows can be set as an alternative to specifying
max_rows argument to the $print() method. (#470)
New output_basename argument for the model fitting methods. Can be used in
conjunction with output_dir to get completely predictable output CSV file
paths. (#471)
New format argument for $draws(), $sampler_diagnostics(),
read_cmdstan_csv(), and as_cmdstan_fit(). This controls the format of the
draws returned or stored in the object. Changing the format can improve speed
and memory usage for large models. (#482)
Fixed reading inverse mass matrix with values written in scientific format in the CSV. (#394)
Fixed error caused by an empty data list. Previously if a model didn't require
data then data had to either be NULL or be a non-empty list, but now list()
is allowed. (#403)
Added $sample_mpi() for MCMC sampling with MPI. (#350)
Added informative messages on compile errors caused by precompiled headers (PCH). (#384)
Added the cmdstanr_verbose option for verbose mode. Intended for
troubleshooting, debugging and development. See end of How does CmdStanR work?
vignette for details. (#392)
New $loo() method for CmdStanMCMC objects. Requires computing pointwise
log-likelihood in Stan program. (#366)
The fitted_params argument to the $generate_quantities() method now also
accepts CmdStanVB, posterior::draws_array, and posterior::draws_matrix
objects. (#390)
The $optimize() method now supports all of CmdStan's tolerance-related
arguments for (L)BFGS. (#398)
The documentation for the R6 methods now uses @param, which allows package
developers to import the CmdStanR documentation using roxygen2's
@inheritParams. (#408)
Fixed bug with reading Stan CSV when grep used coloring by default (#364,#371)
Depend on posterior v0.1.3 to avoid a potential error in $summary(). (#383)
Added support for native execution on the macOS with the M1 ARM-based CPU. (#375)
Added threading support via threads argument for $optimize() and $variational()
(was already available via threads_per_chain for $sample()). (#369)
Fixed bug with processing stanc_options in check_syntax(). (#345)
Fixed bug on access to one variable via draws(). (#348)
compile() and check_syntax() methods gain argument pedantic for turning
on pedantic mode, which warns about issues with the model beyond syntax errors.
(#361)Fix potential indexing error if using read_cmdstan_csv() with CSV files
created by CmdStan without CmdStanR. (#291, #292, @johnlees)
Fix error when returning draws or sampler diagnostics for a fit with only warmup and no samples. (#288, #293)
Fix trailing slashes issue for dir in cmdstan_model() and output_dir
in fitting methods. (#281, #294)
Fix dimensions error when processing a list of matrices passed in as data. (#296, #302)
Fix reporting of time after using fixed_param method. (#303, #307)
With refresh = 0, no output other than error messages is printed with
$optimize() and $variational(). (#324)
Fix issue where names of generated files could clash. (#326, #328)
Fix missing include_paths in $syntax_check(). (#335, @mike-lawrence)
CSV reading is now faster by using data.table::fread(). (#318)
install_cmdstan() gains argument version for specifying which version of
CmdStan to install. (#300, #308)
New function check_cmdstan_toolchain() that checks if the appropriate
toolchains are available. (#289)
$sample() method for CmdStanModel objects gains argument chain_ids for
specifying custom chain IDs. (#319)
Added support for the sig_figs argument in CmdStan versions 2.25 and above. (#327)
Added checks if the user has the necessary permissions in the RTools and temporary folders. (#343)
User is notified by message at load time if a new release of CmdStan is available. (#265, #273)
write_stan_file() replaces write_stan_tempfile(), which is now deprecated.
With the addition of the dir argument, the file written is not necessarily
temporary. (#267, #272)
eng_cmdstan() and function register_knitr_engine() that
allow Stan chunks in R markdown documents to be processed using CmdStanR
instead of RStan. The new vignette R Markdown CmdStan Engine provides a
demonstration. (#261, #264, @bearloga)