Skip to content

flexstanr

0.2.0Package record

Portable Backend Layer for 'Stan' Models

2packages depend
962downloads / year
83.3%test coverage
13/13flavors OK

Overview

About

Gives a 'Stan'-based R package one interface for fitting its models through either 'rstan' or 'cmdstanr', neither of which is required to install this package (install whichever you use). Collects and validates sampler options, guarding against mixing one backend's argument vocabulary into the other, dispatches the fit to the chosen backend, and exposes backend-agnostic accessors for reading posterior draws, extracting parameters, and running generated quantities. The host package supplies its own compiled models; flexstanr resolves them from the calling package at run time, so the same code works whichever backend is installed.

Changes in 0.2.0
  • 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.
Show all changes in 0.2.0Hide the rest of the changes in 0.2.0
  • 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.

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 2.2 min · r-oldrel-windows-x86_64
Status changes
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK7 OK2026-07-18
Advisories

none known

Documentation

In release 0.2.0
READMEYes · 734 wordsVignettesYes · 2 · evaluation depends on the environmentNEWSYes · 100% structured · mentions 0.2.0Citation fileNoWebsiteYes · pkgdown
Help pages
33 (25 internal)includes a package overview page
Examples that run
38%3 run in a plain check (2 of them under a condition) · 5 never run
Exported functions with examples
100%
Documented parameters
100%
Return-value docs
100%
Help pages citing references
0%

Downloads

962
CRAN downloads in the past year
Rank #13,908 · ~3/day · ~80/mo
Daily download trend is not available in this view yet.
25930 days
84390 days
9621 year
Compare downloads with other packages →
Also on31 r2u3 autocran

Repository

1Stars
0Forks
4Open issues
0Open PRs
0Releases
25Commits
1Commit identities
25 commits · Last activity 2026-10-19 · 0% stars, 30d · Default branch at 0.3.0, ahead of CRAN 0.2.0 (checked 2026-10-21)
Responsiveness
How these are sampled
PRs merged (all time)
89%
Median days to close, 50 most recently updated closed issues
1
Median days to close, 50 most recently updated closed PRs
1

Stars over time

2026-07-18 · 02026-08-12 · 1
PracticesBeta

9 development-tooling and community-health practices detected across 5 families in the upstream repository

Checks run against github.com/accidda/flexstanr on 2026-10-21.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Docs source (3)
pkgdown

GitHub Pages site last deployed 2026-10-19 · The repository has a site deploy workflow

pkgdown site last built 2026-10-19

Coverage (1)
Coverage reporting
CRAN release process (1)
cran-comments.md
Show all practicesHide 1 practice
Lint, format, editor (2)
lintrLint workflow
How this is detected·Detection ruleset v4 (2026-10-20)

Dependencies

Declared dependencies
12 external dependencies (excludes base and recommended)

Installing flexstanr adds 1 package (1 with compiled code, 343 KB of source tarballs). Heaviest: parallelly 343 KB.

Depends (1)
R >= 4.1.0
Imports (3)
methodsparallellytools
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
2direct
0indirect
Imports 2
Depends, Imports or LinkingTo, most downloaded first

People & History

People (2)
Author, Maintainer since 0.1.0 (2026)
Releases (2)

Pick two releases to compare their code metrics.

  • 0.2.0Latest
    record
    2026-08-25 · current release · diff ↗ ·
    added 1 export
    test_threaded
  • 0.1.0
    record
    2026-07-17
  • R
    R 4.6.0 released · 2026-04-24

Package metadata

First published
2026-07-17
Total releases
2 / 1 yrs
License
MIT + file LICENSE OSI
Additional repositories
stan-dev.r-universe.dev
Minimum R
≥ 4.1.0
Download size
56 KB

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("flexstanr")
Pearson, C., & Voglesonger, W. (2026). flexstanr: Portable Backend Layer for 'Stan' Models (Version 0.2.0) [Computer software]. https://doi.org/10.32614/CRAN.package.flexstanr

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for flexstanr version 0.2.0 [Data set]. HJJB, LLC. Data release v2026-10-23. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-23, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy