Skip to contents

Front door

The main fitter, its formula surface, and the mode / family helpers.

tulpa()
Fit a tulpa model
tulpa_parse_formula() print(<tulpa_parsed_formula>)
Parse a mixed-model formula
findbars()
Find all bar terms in a formula's parse tree
nobars()
Remove all bar terms from a formula's parse tree
inference_mode_info()
Print inference mode information
validate_mode()
Validate that a fit used the expected mode
tulpa_family() print(<tulpa_family>)
Construct a minimal tulpa_family for simulation
tulpa_gaussian()
Fit a Gaussian linear model via tulpa's generic engine
tulpa_build_model_data()
Build model matrices from a parsed formula
tulpa_simulate() print(<tulpa_simulate>)
Simulate data from a tulpa model

Tier 2 – structured approximations

Laplace, nested Laplace, and the free-Sigma random-effect backends.

tulpa_laplace()
Fit a model via Laplace approximation
tulpa_laplace_beta()
Fit a beta-regression model via Laplace, estimating the precision
print(<tulpa_nested_laplace>) tulpa_nested_laplace()
Nested Laplace approximation for latent Gaussian models
print(<tulpa_nested_laplace_joint>) print(<tulpa_nested_laplace_joint_multi>) tulpa_nested_laplace_joint()
Joint multi-likelihood nested Laplace approximation
fit_st_nested() print(<tulpa_st_nested>)
Fit an additive spatiotemporal GLM by nested Laplace
tulpa_hyper_grid()
Outer hyperparameter-grid integration with a user-supplied inner fit
tulpa_re_cov_nested()
Nested-Laplace integration over random-effect covariances
tulpa_re_aghq()
Adaptive Gauss-Hermite refinement of a grouped random-effect covariance
tulpa_eb()
Empirical-Bayes random-effect covariances
tulpa_em_laplace()
Fit a latent-variable model via EM + Laplace approximation
tulpa_em_mc()
Generic Monte-Carlo EM driver
agq_fit()
Adaptive Gauss-Hermite quadrature for one-RE GLMMs
fit_spde()
Fit a spatial model using SPDE Laplace approximation
tulpa_ep()
Expectation-Propagation fit for a GLM
tulpa_multinomial() print(<tulpa_multinomial>)
Multinomial (nominal K-class) logistic regression via Laplace
tulpa_ordinal() coef(<tulpa_ordinal>) print(<tulpa_ordinal>)
Ordinal (ordered K-class) cumulative-logit regression via Laplace
imh_laplace()
Independence Metropolis-Hastings with Laplace proposal

Tier 1 – exact MCMC and debias

tulpa_gibbs()
Fit via Polya-Gamma Gibbs sampler
tulpa_re_cov_gibbs()
Gibbs estimation of random-effect covariances (exact-target debias)
tulpa_nuts_beta()
Fit a beta-regression model via NUTS (joint sampling of beta + log_phi)
tulpa_nuts_spde()
Sample an SPDE GLM via NUTS, optionally jointly over Matern hypers
tulpa_tgmrf()
Fit a custom tgmrf latent block
tgmrf() print(<tgmrf>) summary(<tgmrf>)
User-defined GMRF latent block
tgmrf_cpp()
User-defined GMRF latent block, compiled C++ backend
tulpa_cache_dir()
Default cache directory for tgmrf_cpp()-compiled DLLs
tulpa_cache_clear()
Remove compiled blocks from the tgmrf_cpp() cache
mala()
Metropolis-adjusted Langevin algorithm (MALA)
tulpa_integrator()
Select the symplectic integrator for HMC and NUTS
with_tulpa_integrator()
Run an expression under a chosen symplectic integrator

Other approximations

pathfinder()
Pathfinder: variational warm-start via L-BFGS + ELBO scoring
bridge_sampling()
Bridge sampling for marginal likelihood

Latent structure

Spatial, temporal, and varying-coefficient constructors.

spatial() print(<tulpa_spatial_field_fit>) print(<tulpa_spatial_field>)
Areal spatially varying coefficient field
spatial_car()
CAR / ICAR spatial structure
spatial_car_proper()
Proper CAR spatial structure
spatial_bym2()
BYM2 spatial structure
spatial_gp() print(<tulpa_gp>) print(<tulpa_hsgp>)
Gaussian process spatial structure (NNGP)
spatial_multiscale() print(<tulpa_multiscale>)
Multi-scale Gaussian process spatial structure
spatial_svc() print(<tulpa_svc>)
Spatially varying coefficient structure
spatial_rsr() print(<tulpa_rsr>)
Restricted spatial regression (RSR)
spatial_spde()
SPDE spatial field (Matern via triangular mesh)
spatial_spde_custom()
SPDE spatial field from custom matrices
temporal_rw1()
RW1 temporal structure (first-order random walk)
temporal_rw2()
RW2 temporal structure (second-order random walk)
temporal_ar1()
AR1 temporal structure (first-order autoregressive)
temporal_ar2()
AR(2) temporal latent field (second-order autoregressive)
temporal_ar() print(<tulpa_temporal_latent_block>)
AR(p) temporal latent field (general-order autoregressive)
temporal_gp() print(<tulpa_temporal_gp>)
Gaussian process temporal structure
temporal_multiscale() print(<tulpa_temporal_multiscale>)
Multi-scale temporal structure
temporal_tvc() print(<tulpa_tvc>)
Time-varying coefficient structure
temporal_rtr()
Restricted temporal regression (RTR)
spatiotemporal()
Spatiotemporal interaction specifications for tulpa
spatiotemporal_gp()
Non-separable spatiotemporal GP
svc() summary(<tulpa_svc_posterior>) print(<tulpa_svc_posterior>) print(<tulpa_svc_summary>)
Extract spatially-varying coefficients from a fitted model
tvc() print(<tulpa_tvc_posterior>) print(<tulpa_tvc_summary>) summary(<tulpa_tvc_posterior>)
Extract temporally-varying coefficients from a fitted model
latent()
Mark an expression as a latent block in a tulpa formula
latent_factor() print(<tulpa_latent>)
Create a latent factor specification
adjacency() print(<tulpa_adjacency>)
Construct a spatial adjacency graph for areal models
check_adjacency() print(<tulpa_adjacency_check>)
Validate a spatial adjacency matrix
node_index()
Map cell identifiers to graph node indices
compute_nngp_neighbors()
Compute nearest neighbors for NNGP
tulpa_bar_field_specs()
Expand a varying-coefficient bar into per-column field specs
tulpa_bar_field_replicate()
Replicate an areal graph across the levels of a factor (replicated CAR)
tulpa_is_spatial_bar()
Recognize an inline varying-coefficient bar

Priors

The prior surface and the individual prior builders.

tulpa_priors() print(<tulpa_priors>) print(<tulpa_prior>) format(<tulpa_prior_normal>) format(<tulpa_prior_half_normal>) format(<tulpa_prior_half_cauchy>) format(<tulpa_prior_gamma>) format(<tulpa_prior_exponential>) format(<tulpa_prior_beta>) format(<tulpa_prior_pc>) format(<tulpa_prior>)
Prior specification for tulpa models
priors_default()
Show default priors for a tulpa family
prior_from_spec()
Build a prior list for tulpa_nested_laplace() from a tulpa spec object
prior_normal()
Normal prior
prior_beta()
Beta prior
prior_gamma()
Gamma prior
prior_exponential()
Exponential prior
prior_half_cauchy()
Half-Cauchy prior
prior_half_normal()
Half-normal prior
prior_pc()
Penalized complexity (PC) prior
re_cov_pc_lkj_prior()
PC + LKJ hyperprior for a random-effect covariance

Methods, criteria, and prediction

tulpa_criteria() print(<tulpa_criteria>)
Model criteria from a pointwise log-likelihood
pointwise_loglik() dic() cpo() waic(<tulpa_fit>) loo(<tulpa_fit>)
DIC, CPO, WAIC and PSIS-LOO on a fit
wbic() print(<tulpa_wbic>)
Widely applicable Bayesian information criterion (WBIC)
tulpa_kfold()
K-fold cross-validation for a tulpa fit
tulpa_reloo()
Selective refit of high-Pareto-k observations (reloo)
tulpa_psis()
Pareto-smoothed importance sampling
tulpa_loglik()
Streaming pointwise log-likelihood
bayes_R2()
Bayesian R-squared
tulpa_powerscale_sensitivity()
Power-scaling prior / likelihood sensitivity
compare_models()
Compare models by information criteria
model_average()
Model-averaged predictions
posterior_predict()
Posterior predictive replicates
pp_check()
Posterior predictive check
prior_predict() print(<tulpa_prior_predict>)
Prior predictive simulation
reexports tidy glance
Objects exported from other packages

Reading a fit

Accessors for a fitted model: the coefficient surface, the posterior draws in whatever representation the backend produced, and the extracted latent effects.

print(<tulpa_fit>) summary(<tulpa_fit>) coef(<summary.tulpa_fit>) print(<summary.tulpa_fit>)
Summarize and print a tulpa fit
tulpa_fit_summary()
Build the summary of a tulpa fit around a coefficient table
fixef()
Fixed-effect coefficients (lme4-compatible)
ranef()
Random-effect summaries
VarCorr()
Random-effect variances and correlations
posterior_sample()
Posterior parameter sample from a fit
mcmc_draws()
MCMC chain draws from a fit
tulpa_posterior_draws()
Posterior draws from a nested-Laplace fit
tulpa_outer_grid()
The outer hyperparameter grid of a nested-Laplace fit
tulpa_draws_array()
Posterior draws as a 3D array
as_draws() as_draws_array() as_draws_matrix() as_draws_df() as_draws_rvars()
Posterior draws in the posterior package's format
print(<tulpa_temporal_field_fit>) print(<tulpa_temporal_field>) temporal() print(<tulpa_temporal_posterior>) summary(<tulpa_temporal_posterior>) print(<tulpa_temporal_summary>)
Extract temporal effects from a fitted model
spatiotemporal_effects() print(<tulpa_st_summary>)
Extract spatiotemporal effects from fitted model
smooth_effects()
Extract fitted covariate smooths
field_effects()
Spatial field effects per unit
latent_factors()
Extract latent factor posteriors from fit

Diagnostics

Convergence for sampled fits, approximation reliability for deterministic ones, and the residual / goodness-of-fit surface both share.

diagnostics() print(<laplace_diagnostics>)
Posterior diagnostics for a fitted model
check_diagnostics()
Quick convergence check
diagnostic_summary() print(<tulpa_diagnostic_summary>)
Comprehensive diagnostic summary
energy_bfmi()
Energy Bayesian Fraction of Missing Information (E-BFMI)
select_main_params()
Select the "main" model parameters for diagnostic display
n_divergent()
Number of divergent transitions
geweke_test() print(<tulpa_geweke>)
Geweke convergence test
moran_i()
Moran's I test for spatial autocorrelation in residuals
durbin_watson()
Durbin-Watson test for temporal autocorrelation
tulpa_variogram() plot(<tulpa_variogram>) print(<tulpa_variogram>)
Empirical semivariogram of residuals
pit_residuals()
PIT (probability integral transform) residuals
tulpa_pit()
Probability integral transform from a predictive CDF
test_uniformity()
Test uniformity of PIT residuals
test_dispersion()
Test for over- or underdispersion
test_outliers()
Test for outliers (simulation envelope)
test_zero_inflation()
Test for zero inflation
check_model()
Diagnostic panel plot
spatial_range()
Extract spatial range and variance from a fitted spatial model
temporal_corr()
Extract temporal correlation parameters from a fitted model
post_hoc_lm() print(<post_hoc_lm>)
Fit a post-hoc linear model on estimated parameters

Calibration

Simulation-based calibration. Where the diagnostics above score one fit, these score whether an inference algorithm’s posteriors are calibrated across the generative model, by reading the whole marginal CDF.

Plots

plot_rhat()
Plot Rhat convergence diagnostic
plot_ess()
Plot effective sample size diagnostic
plot_acf()
Plot autocorrelation functions
plot_energy()
Plot energy diagnostic (E-BFMI)
plot_divergences()
Plot divergent transitions
plot_pairs()
Plot bivariate parameter posteriors (pairs plot)
plot_diagnostics()
Diagnostic plotting functions for tulpa models
plot_map()
Plot spatial predictions as a map
plot_map_panel()
Plot multiple maps in a grid

Outer-grid integration and utilities

The node designs the outer hyperparameter integration is laid on, the axis-provenance surface, and the small numerical helpers.

ccd_grid()
Central composite design (CCD) grid for nested-Laplace integration
ccd_weights()
Corrected R-INLA CCD integration weights
ccd_to_theta()
Map standardised CCD coordinates to physical hyperparameters
hyper_axis_spec() print(<tulpa_hyper_axis_spec>)
Describe one outer-grid hyperparameter axis
auto_grid()
Mark an outer-grid setting as a default rather than a pin
is_auto_grid()
Is an outer-grid setting marked as a default?
rubins_pool()
Pool multiple imputation draws via Rubin's rules
sn_cdf()
Skew-normal CDF
sn_quantile()
Skew-normal quantile
sn_match()
Match three cumulants to a skew-normal parameterisation
tulpa_profile()
Profile a fit by solver phase
tulpa_check_control()
Validate a control = list() surface against its canonical key set