Skip to contents

flexstanr 0.3.0

  • New backend_diagnostics() reports the numbers used to judge whether a fit can be trusted, in the same shape for both backends (#40, #41): R-hat and bulk and tail ESS per parameter (computed by ‘posterior’), and divergent transitions, max treedepth hits, and E-BFMI per chain (all post-warmup), plus the number of chains, post-warmup iterations, and the max_treedepth setting. It applies no thresholds and signals no warnings (posterior’s ESS warnings are suppressed); deciding what counts as a failed fit is left to the host package. It needs the suggested ‘posterior’ package and errors with an install hint when it is missing.
  • Sampler diagnostics delegate to cmdstanr’s public diagnostic_summary() and rstan’s get_bfmi(), with narrow adapters for per-chain rstan counts and undefined energy. Undefined E-BFMI values are consistently NA, and cmdstanr fixed-parameter fits report NA for the sampler columns and max_treedepth.
  • The suggested cmdstanr backend now requires cmdstanr >= 0.5.0 (for diagnostic_summary()).
  • use_flexstanr() adds backend_diagnostics to the host package’s generated @importFrom flexstanr list, alongside the other backend_*() accessors.

flexstanr 0.2.0

CRAN release: 2026-08-25

  • backend_extract() now states its return shape as a contract rather than leaving it to the backend (#34). pars defaults to NULL, which extracts every parameter, and a new format argument picks the representation: "list" (the default) is rstan::extract()-compatible, "draws" returns a posterior draws array with the chain structure intact, and "matrix" returns a plain draws x variables matrix – the shape backend_generate_quantities() takes as draws_mat. Each format has the same shape whichever backend produced the fit, so downstream code no longer has to branch on the backend. Existing calls are unaffected: format defaults to the shape backend_extract() already returned.
  • Bug fix: the cmdstanr backend returned a scalar parameter as a dimensionless vector, while rstan::extract() returns a 1-D array of length S for a scalar in every call form. Code that reshapes off dim() (aperm() errors outright on a dimensionless vector) therefore behaved differently depending on which backend produced the fit. The cmdstanr path now matches rstan. A vector[1] is still kept as an S x 1 matrix on both backends, as rstan does.
  • stan_options(threading = TRUE) turns on scheduler-aware threading (ported from hestia): flexstanr splits the cores the process is allowed to use – detected with parallelly::availableCores(), respecting HPC schedulers and cgroup quotas – between chain-parallelism and within-chain (reduce_sum) threads, using all available cores by default (cap with max_cores), and reports what it chose. fit_model() applies the split per backend, compiling the cmdstanr model with threading enabled when needed. The new exported test_threaded() lets a host package’s fit function warn when its model cannot use the offered threads. See the new “Parallel and threaded fitting” vignette.
  • rstan and cmdstanr are now equally optional backends. rstan moved from Imports to Suggests, so flexstanr installs and loads without either package; selecting a backend whose package is not installed fails with an actionable error, and an attach-time message points the way when neither is present. Install whichever backend you use (#30).
  • use_flexstanr() now generates the host package’s re-export file (with a do-not-edit banner) in addition to editing its DESCRIPTION, and its signature mirrors usethis::use_package() (min_version, remote). It wires in flexstanr only; pick and declare a backend (rstan or cmdstanr) yourself.

flexstanr 0.1.0

CRAN release: 2026-07-17

Initial release: a portable Stan-backend layer that a Stan-based R package can fit its models through, using either rstan (default) or, optionally, cmdstanr.