Templated Unified Library for Posterior Approximation in Bayesian Hierarchical Models
Overview
A general-purpose engine for fitting Bayesian hierarchical models with spatial fields, temporal effects, spatially varying coefficients, and multiple inference backends. Scalable spatial structure includes Hilbert space approximate Gaussian processes (HSGP; Riutort-Mayol et al. 2023 doi:10.1007/s11222-022-10167-2), nearest-neighbor Gaussian processes (NNGP; Datta et al. 2016 doi:10.1080/01621459.2015.1044091), intrinsic conditional autoregressive models (ICAR; Besag, York, and Mollie 1991 doi:10.1007/BF00116466), the reparameterized Besag-York-Mollie model (BYM2; Riebler et al. 2016 doi:10.1177/0962280216660421), and stochastic partial differential equation fields (SPDE; Lindgren, Rue, and Lindstrom 2011 doi:10.1111/j.1467-9868.2011.00777.x). Temporal structure covers random walks, autoregressive processes, and Gaussian processes. Inference is tiered by correctness guarantee: exact Hamiltonian Monte Carlo with the No-U-Turn sampler, Laplace and nested Laplace approximations with hyperparameter integration (Rue, Martino, and Chopin 2009 doi:10.1111/j.1467-9868.2008.00700.x), and variational inference. Model-specific packages plug observation likelihoods into the engine through a templated C++ callback interface.
- Three vignettes ship with the package (quickstart, inference modes, spatial models). The other ten (priors, temporal models, model comparison, calibration, reliability, data formatting, random slopes, EM + Laplace, checkpointing, custom latent processes) are articles on the package website, https://gillescolling.com/tulpa/articles/.
energy_bfmi()is exported: E-BFMI from a vector of per-iteration Hamiltonian energies and their chain ids, diffed within each chain and reported for the worst chain, so a model package's energy diagnostic uses the same computation as tulpa's.print(summary(fit))leaves out theReliabilitysection when the fit's record has nothing to report under it, as on a plain Laplace fit, instead of ending on a bare header (#961).
Show all changes in 0.7.5Hide the rest of the changes in 0.7.5
- The Polya-Gamma Gibbs areal kernels (binomial ICAR, BYM2 and restricted ICAR, negative-binomial ICAR) sample the ICAR prior the other backends sample on a disconnected graph. Each component's level, an island's whole value, now carries the field's own precision, where the kernels gave it a flat prior and an island a near-flat N(0, 1000) one. On a chain with a separated island the Gibbs island read 14.5 against the sampler's 0.32 and pulled the mainland and the intercept with it; it now reads 0.30. A component with no observation is drawn from its prior instead of refused. On a connected graph nothing changes (#963).
field_effects()andposterior_predict()on a Gibbs BYM2 fit use the combined fieldsigma * (sqrt(rho) * s * phi + sqrt(1 - rho) * theta)that enters the linear predictor, where they summed the two unit-scale components (#964).- An isolated node is reported with what the field does with it: an ICAR field gives it its own N(0, 1 / tau) level and a BYM2 field unit variance on its structured part, both as a message; a proper CAR field leaves it without a prior and warns. The constructors had warned that every field is improper there (#962).
From NEWS.md in the release
Install
Health
- OK13 OK2026-10-17
- WARNING12 OK, 1 WARNING2026-10-01
- OK13 OK2026-09-25
- ERROR12 OK, 1 ERROR2026-09-23
- OK5 OK2026-09-10
Documentation
The repository also keeps web-only articles.
- Help pages
- 208 (16 internal)includes a package overview page
- Examples that run
- 59%103 run in a plain check (1 of them under a condition) · 73 only when donttest examples are enabled (R CMD check --as-cran)
- Exported functions with examples
- 97%
- Documented parameters
- 94%
- Return-value docs
- 99%
- Help pages citing references
- 14%
Downloads
Repository
- PRs merged (all time)
- 12%
- Median days to close, 50 most recently updated closed issues
- 0
- Median days to close, 50 most recently updated closed PRs
- 0
Releases over time
Issues over time
Commits over time
10 development-tooling and community-health practices detected across 7 families in the upstream repository
Checks run against github.com/gcol33/tulpa on 2026-10-25.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-10-23
pkgdown site last built 2026-10-22
Show all practicesHide 3 practices
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-03-29Seen in the repository: CLAUDE.mdNamed in .Rbuildignore: .claude, CLAUDE.mdNamed in .gitignore: .claudePull request it wrote: opened by a project memberCommits: 58 by its own account · at least 1,211 crediting it in the message
- Claude Opus 4.796 commits · Apr to May 2026
- Claude Fable 555 commits · Jul 2026
- Claude Opus 4.837 commits · Jun to Jul 2026
- Claude Sonnet 4.62 commits · Apr 2026
- Claude Opus 4.61 commit · Mar 2026
Some of these counts are a minimum, because the search stopped before the oldest commits.
Dependencies
Installing tulpa adds 5 packages (4 with compiled code, 4.5 MB of source tarballs). Heaviest: Rcpp 1.8 MB, RcppEigen 1.7 MB, RcppParallel 744 KB.
Code & Tests
People & History
Pick two releases to compare their code metrics.
- 0.7.5Latest2026-10-19 · current release · diff ↗ ·
added 6 exports
energy_bfmi, field_effects, tulpa_fit_summary, tulpa_joint_inner_vcov_mixture, tulpa_outer_grid, wbic - 0.6.02026-09-24 · diff ↗
- 0.5.02026-09-21 · diff ↗ ·
removed 2 exports
laplace_diagnostics, mcmc_diagnosticsadded 22 exports
auto_grid_place, family_names, pointwise_loglik, tulpa_batched_pareto_k, tulpa_grid_axis, tulpa_grid_log_quad, tulpa_hyper_check_copy_slab, tulpa_hyper_copy_slab_density, tulpa_hyper_draws, tulpa_hyper_grid_supports, tulpa_hyper_slice_home, tulpa_iter_progress, tulpa_joint_axis_specs_from_grid, tulpa_joint_grid_batch, tulpa_joint_inner_vcov_blocks, tulpa_normalise_weights_safe, tulpa_rpg, tulpa_spde_log_hyperprior, tulpa_spde_precision_Q, tulpa_theta_matrix, validate_gp, validate_temporal_multiscale - 0.2.02026-09-09
- RR 4.6.0 released · 2026-04-24
Package metadata
- First published
- 2026-09-09
- Total releases
- 4 / 1 yrs
- License
- MIT + file LICENSE OSI
- Minimum R
- ≥ 4.1.0
- Download size
- 4.2 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("tulpa")The package provides a citation file that builds its entry when R runs it. Run citation() to see it.
The repository also keeps a CITATION.cff.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-26, which the citation names so these numbers can be found later. More on citing and the projects behind them.