Package: spDBL 1.2.0

Xiang Chen

spDBL: Dynamic Bayesian Learning for Spatiotemporal Mechanistic Models

Emulates the output of spatiotemporal mechanistic simulators, a field on a spatial grid at each time step, with a matrix-variate dynamic linear model whose posterior is available in closed form, processing large grids as sequences of spatial blocks, and predicts the output at untried inputs. Calibrates simulator parameters to noisy field data without further simulator runs: a design Gaussian process supplies the emulator's autoregressive inputs, and 'Stan' (through the suggested package 'rstan') samples the parameters conditionally on emulator posterior draws, with the emulator field and a dynamic spatial discrepancy integrated out. Follows Banerjee, Chen, Frankenburg and Zhou (2025) <https://jmlr.org/papers/v26/22-0896.html>.

Authors:Xiang Chen [aut, cre], Sudipto Banerjee [aut]

spDBL_1.2.0.tar.gz
spDBL_1.2.0.zip(r-4.7-x86_64)spDBL_1.2.0.zip(r-4.7-arm64)spDBL_1.2.0.zip(r-4.6-x86_64)spDBL_1.2.0.zip(r-4.6-arm64)spDBL_1.2.0.zip(r-4.5-x86_64)
spDBL_1.2.0.tgz(r-4.6-x86_64)spDBL_1.2.0.tgz(r-4.6-arm64)spDBL_1.2.0.tgz(r-4.5-x86_64)spDBL_1.2.0.tgz(r-4.5-arm64)
spDBL_1.2.0.tar.gz(r-4.7-arm64)spDBL_1.2.0.tar.gz(r-4.7-x86_64)spDBL_1.2.0.tar.gz(r-4.6-arm64)spDBL_1.2.0.tar.gz(r-4.6-x86_64)
spDBL_1.2.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
spDBL/json (API)

# Install 'spDBL' in R:
install.packages('spDBL', repos = c('https://xiangchen-stat.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/xiangchen-stat/spdbl/issues

Pkgdown/docs site:https://xiangchen-stat.github.io

Uses libs:
  • c++– GNU Standard C++ Library v3
Datasets:

On CRAN:

Conda:

cpp

5.20 score 450 downloads 79 exports 29 dependencies

Last updated from:73d425a9ec. Checks:15 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK200
linux-devel-x86_64OK215
source / vignettesOK368
linux-release-arm64OK195
linux-release-x86_64OK246
macos-release-arm64OK281
macos-release-x86_64OK482
macos-oldrel-arm64OK157
macos-oldrel-x86_64OK443
windows-devel-arm64OK346
windows-devel-x86_64OK276
windows-release-arm64OK321
windows-release-x86_64OK225
windows-oldrel-x86_64OK238
wasm-releaseOK164

Exports:BSBS_bigdata_Rcal_Bt_btcal_errorbarcal_errorbar_meancal_jacobian_logit_uniformcalibration_fitcalibration_predictcalibration_preparecalibration_validatecheck_pdscompute_analytical_waiccompute_sample_waicdMTigemulator_learnemulator_predictexpitFFFF_1step_R_IFF_1step_R_sigma2RFF_bigdata_RFF_IFF_sigma2RFFBSFFBS_IFFBS_predict_bigdata_RFFBS_predict_exactFFBS_predict_MCFFBS_samplingFFBS_sampling_IFFBS_sampling_sigma2RFFBS_sigma2Rgen_calibrate_datagen_calibrate_data_uncorrgen_exp_kernelgen_expsq_kernelgen_F_ls_AR1gen_F_ls_AR1_EPgen_F_ls_AR2gen_F_ls_AR2_EPgen_ffbs_csvgen_ffbs_datagen_gp_kernelgen_Jtgen_pd_matrixgen_pdegen_prior_u_tau2gen_ran_matrixgenerate_gridgenerate.grid.exactgenerate.grid.lrgenerate.grid.rowsnakeinv_chollppd_id_1tlppd_IG_1tlppd_IW_1tmake_pdsMNIG_samplerMNIW_RMNIW_R_naiiveMNIW_samplerplot_panel_heatmap_9plot_panel_heatmap_9_calplot_panel_heatmap_9_cal_nolabprepare_dataquick_heatquick_saveread_big_csv_quickrecover_from_EP_exactrecover_from_EP_MCrmn_cholrmn_chol_moresample_y_eta_onescale_back_uniformscale_uniformSIRupdate_muSigma_eta_oneupdate_y_etaupdate_y_eta_one

Dependencies:bitbit64clicliprcpp11crayongluehmskeeplifecyclemagrittrmatrixsamplingmniwpillarpkgconfigprettyunitsprogressR6RcppRcppEigenreadrrlangtibbletidyselecttzdbutf8vctrsvroomwithr

From saved SIR simulations to field-data calibration
Load simulations and observations | Fit the dynamic emulator | Predict without new PDE trajectories | Prepare field observations | One iteration for each emulator draw | Eta histograms | Recover discrepancy and field predictions | Panel: TAU2, U, Z | Reproduce or extend the run

Last update: 2026-11-16
Started: 2026-11-01

Analytical and Sample-Based MNIW Model Comparison
Likelihood and posterior | Fit a multivariate regression | Analytical calculation | Compare with posterior draws | Optional comparison with loo | Compare sequential covariate subsets | References

Last update: 2026-11-16
Started: 2026-11-04

PDE Emulation with FFBS
What this tutorial shows | Main idea | 1. Load packages and example data | 2. Introduce the learning and prediction wrappers | Learning step: emulator_learn() | Prediction step: emulator_predict() | 3. Fit the emulator and predict new PDE outputs | What is returned? | 4. Visualize the true PDE solution | 5. Compare FFBS emulation with the PDE solution | 6. Check predictive uncertainty | Practical tips | Summary

Last update: 2026-11-16
Started: 2026-04-08

The GP and probability model behind calibration
Emulator coefficient sampling | Two GP calculations | Spatial recovery and covariance | Field-data likelihood | Marginal discrepancy sampling | Modular posterior pooling | Uncertainty and limitations

Last update: 2026-11-16
Started: 2026-11-01

Readme and manuals

Help Manual

Help pageTopics
Backward sampler for the Forward Filter Backward Sampler (FFBS)BS
Out-of-core backward smoothingBS_bigdata_R
Update the posterior mean and covariance of the discrepancy fieldcal_Bt_bt
Compute median and 95% credible interval across rowscal_errorbar
Compute mean and 95% credible interval across rowscal_errorbar_mean
Log absolute Jacobian of the logit-uniform transformationcal_jacobian_logit_uniform
Fit modular calibration conditional on emulator posterior drawscalibration_fit
Recover fields at the calibrated observation times and locationscalibration_predict
Prepare a fitted emulator for PDE-free calibrationcalibration_prepare
Validate offline calibration predictions against held-out simulationscalibration_validate
Check and repair a matrix to be positive definite and symmetriccheck_pds
Analytical WAIC for an MNIW multivariate regression posteriorcompute_analytical_waic
WAIC from paired coefficient and covariance drawscompute_sample_waic
Log density of the matrix-T distribution with inverse-gamma right covariancedMTig
Saved SIR simulations and synthetic field observations for calibrationdt_calibration
Example emulation datasetdt_emulation
Fit an FFBS-based dynamic emulatoremulator_learn
Predict simulator output from a fitted emulatoremulator_predict
Logistic (expit) functionexpit
Forward Filter for the MNIW dynamic linear modelFF
Single forward filter step (identity right-covariance)FF_1step_R_I
Single forward filter step (scalar right-covariance, sigma-squared times R)FF_1step_R_sigma2R
Forward Filter for big data stored in CSV files (MNIW model)FF_bigdata_R
Forward Filter with identity right-covarianceFF_I
Forward Filter for the scalar-sigma-squared-times-R modelFF_sigma2R
Forward Filter Backward Sampler (MNIW model)FFBS
Forward Filter Backward Sampler (identity right-covariance)FFBS_I
Out-of-core exact predictionFFBS_predict_bigdata_R
Exact posterior predictive mean using FFBS smoothed states (MNIW model)FFBS_predict_exact
Monte Carlo prediction using FFBS output (MNIW model)FFBS_predict_MC
Draw posterior samples from FFBS output (MNIW model)FFBS_sampling
Draw posterior samples from FFBS output (identity right-covariance)FFBS_sampling_I
Draw posterior samples from FFBS output (scalar sigma-squared-times-R model)FFBS_sampling_sigma2R
Forward Filter Backward Sampler (scalar sigma-squared-times-R model)FFBS_sigma2R
Generate synthetic calibration data with correlated discrepancygen_calibrate_data
Generate synthetic calibration data with uncorrelated discrepancygen_calibrate_data_uncorr
Compute an exponential GP kernel matrixgen_exp_kernel
Compute a squared-exponential (Gaussian) GP kernel matrixgen_expsq_kernel
Build AR(1) covariate list from a list of response matricesgen_F_ls_AR1
Build AR(1) covariate list for the episode-block modelgen_F_ls_AR1_EP
Build AR(2) covariate list from a list of response matricesgen_F_ls_AR2
Build AR(2) covariate list for the episode-block modelgen_F_ls_AR2_EP
Generate synthetic FFBS data and write to CSV filesgen_ffbs_csv
Generate synthetic FFBS data in memorygen_ffbs_data
Compute a Gaussian Process covariance kernel matrixgen_gp_kernel
Compute the cross-covariance matrix between observed and new locationsgen_Jt
Generate a random positive definite matrixgen_pd_matrix
Simulate a spatially extended SIR PDE modelgen_pde
Sample prior discrepancy trajectory and variance sequencegen_prior_u_tau2
Generate a random matrix with entries scaled to [-1, 1]gen_ran_matrix
Generate block indices for big data grid traversalgenerate_grid
Generate an exact block grid analyticallygenerate.grid.exact
Generate a flexible block grid with left-to-right traversalgenerate.grid.lr
Generate a flexible block grid with snake traversalgenerate.grid.rowsnake
Invert a matrix via its Cholesky factorisationinv_chol
One-step log posterior predictive density (identity right-covariance model)lppd_id_1t
One-step log posterior predictive density (scalar sigma-squared-times-R model)lppd_IG_1t
One-step log posterior predictive density (MNIW / inverse-Wishart model)lppd_IW_1t
Force a matrix to be positive definite and symmetricmake_pds
Sample from the Matrix Normal Inverse Gamma (MNIG) distributionMNIG_sampler
MNIW posterior updateMNIW_R
Naive MNIW posterior updateMNIW_R_naiive
Sample from the Matrix Normal Inverse Wishart (MNIW) distributionMNIW_sampler
Plot a 3-by-3 panel of heatmaps across selected time stampsplot_panel_heatmap_9
Plot a 3-by-3 panel of calibration heatmapsplot_panel_heatmap_9_cal
Plot a 3-by-3 panel of calibration heatmaps without axis labelsplot_panel_heatmap_9_cal_nolab
Plot calibrated mechanistic parameter samplesplot.spDBL_calibration
Prepare PDE emulator training and testing data from CSV filesprepare_data
Quick raster heatmapquick_heat
Save a ggplot to a timestamped PNG filequick_save
Read a rectangular block from a large CSV fileread_big_csv_quick
Recover episode-partitioned data to original time dimension (exact)recover_from_EP_exact
Recover episode-partitioned posterior samples to original time dimensionrecover_from_EP_MC
Draw one sample from a matrix-normal distribution (Cholesky parameterisation)rmn_chol
Draw multiple samples from a matrix-normal distribution (Cholesky parameterisation)rmn_chol_more
Draw predictive samples from a precomputed mean and covariancesample_y_eta_one
Invert a uniform scaling transformationscale_back_uniform
Scale a vector to the unit interval via a uniform transformationscale_uniform
Right-hand side of the spatially extended SIR ODESIR
Print and predict from a prepared calibration objectpredict.spDBL_calibration_input print.spDBL_calibration_input spDBL_calibration_input-methods
Print, summarize and predict from a fitted emulatorpredict.spDBL_emulator print.spDBL_emulator spDBL_emulator-methods summary.spDBL_emulator
Summarize modular calibration samplessummary.spDBL_calibration
Compute posterior predictive mean and covariance without sampling (single sample)update_muSigma_eta_one
Update the likelihood of observations given PDE parameters (Monte Carlo)update_y_eta
Update the likelihood of observations given PDE parameters (single sample)update_y_eta_one