neuralsbi 0.4.0
The simulator can now run in parallel. Declare a
futureplan –library(future); plan(multisession)– and every function that calls a simulator (npe(),simulate_for_sbi(),npe_sequential(),sbc(),tarp(),posterior_predictive()) spreads the work across workers. There is no new argument to pass and no parallel variant to call: with no plan declared everything runs sequentially as before, andneuralsbimentions the two lines above once per session (options(neuralsbi.parallel_hint = FALSE)to silence it). Each chunk of parameters draws from its own L’Ecuyer-CMRG stream, so a givenset.seed()produces the same simulations sequentially and on any number of workers. See?nsbi_parallel.Long-running work now reports progress with an ETA – simulation and neural training alike, one progress step per simulation and per training epoch. With
progressrinstalled,neuralsbiemits standard progressr updates, soprogressr::handlers()andwith_progress()control reporting; without it, a built-in bar needing no extra packages does the job. The training bar targets the epoch at which early stopping would fire and revises that target as the validation loss improves. See?nsbi_progress.npe(),simulate_for_sbi(),npe_sequential(),sbc(),tarp(), andposterior_predictive()gain achunk_sizeargument controlling how many parameter rows go to the simulator per call. The default splits a run into about 64 chunks; because the split depends only on the number of simulations, results do not change with the number of workers. A simulator whose output must be produced in one call can setchunk_sizeto the full simulation budget.futureandprogressrareSuggests, not dependencies;parallel(base R) moves intoImports. # neuralsbi 0.3.7The test suite now skips its plotting tests when
ggplot2/GGallyare not installed, instead of failing. Both areSuggests, soR CMD checkunder_R_CHECK_FORCE_SUGGESTS_=false– the configuration CRAN uses on a machine without them – previously hit 5 errors fromrequire_ggplot2(). The newskip_if_no_ggplot2()/skip_if_no_ggally()helpers mirror theskip_if_no_torch()contract already used for the neural tests, so the suite runs everywhere.vignette("sir-time-varying-beta")reworks the epidemic model so that its posterior predictive tracks the observed case peaks instead of overshooting them. The introduction day and seed size are now inferred per state rather than fixed at two infections on 2020-01-21 (which left the epidemic’s phase to demographic noise: replicate simulations at one fixed parameter differed by a factor of several thousand at the peak bin), the ascertainment prior is pinned by spring-2020 seroprevalence (case counts alone identify only the product of ascertainment and incidence, and the unconstrained fit slides toward vast, barely-ascertained epidemics), and the regime-duration parameterization drops a coordinate that the simulator’s rescaling had left unidentified. The article reports the effective reproduction number Re(t) = beta(t) S(t) / (N gamma) computed from the simulator’s own susceptible trajectories, adds a prior-predictive check before training, and summarizes the posterior predictive by its median rather than its mean.
neuralsbi 0.3.6
- Parameters and outcomes can now be named. Name
prior_uniform()’slow/highorprior_normal()’smean(e.g.c(beta = 0, gamma = 0)), or attachcolnames()to a simulator’s output, and those names carry throughnpe(),sample(),map_estimate(),sbc(),expected_coverage(), andposterior_predictive()without any extra arguments.plot_sbc(),plot_coverage(),pairplot(), andplot_posterior_predictive()use the names for titles, legends, and facet labels; a name that happens to be valid R syntax ("beta[1]","rho","sigma^2") renders as its plotmath symbol (Greek letters, sub/superscripts) instead of literal text.
neuralsbi 0.3.5
- The SIR case study becomes a head-to-head comparison with the
pomppackage,vignette("sir-epidemic"). Both methods fit the same stochastic SIR epidemic:pompvia particle-filter MCMC (pmcmc),neuralsbivia neural posterior estimation. The vignette contrasts what each needs from the model —pompa measurement density,neuralsbionly a simulator — overlays the two posteriors, scores their agreement with a C2ST, and confirms the neural fit with SBC. The comparison is precomputed, sopompis needed only to regenerate the article, not to build or check the package.
neuralsbi 0.3.4
- Plotting is now built on
ggplot2andGGally::ggpairs()instead of base graphics.pairplot(),plot_sbc(),plot_coverage(),plot_tarp(), andplot_posterior_predictive()keep their signatures (pairplot()gains analphaargument) but now build and print aggplot/ggmatrixobject, returned invisibly for further customization.ggplot2andGGallymove toSuggests, following the same graceful-degradation pattern astorch: call any plotting function without them installed and you get an informative error, not a crash. - New vignette,
vignette("intro-to-sbi"): a short beginner tutorial covering the three ingredients (prior, simulator, observation), amortized training, and a first calibration check, using a g-and-k distribution simulator whose likelihood has no closed form.
neuralsbi 0.3.2
- README is now generated from
README.Rmd, so the usage example runs at render time and its output cannot drift from the code. The example is a plain linear regression: the posterior recovers the ground-truth coefficients, which the reader can check against ordinary least squares.
neuralsbi 0.3.1
- CRAN resubmission fixes. Routed the
summary()andas.data.frame()methods into the singlesummarieshelp topic (they had drifted into separate.Rdfiles with duplicated\aliasentries, which also produced duplicate HTML anchors). Wrappedtheta_{<d}in\eqn{}in themade_masksdocs so the Rd no longer drops braces. Dropped the bare “NPE” acronym from theDESCRIPTIONto avoid the spurious misspelling note.
neuralsbi 0.3.0
Defaults now match Python
sbi, so a workflow reads the same in both packages and results can be cross-checked. Changes tonpe()defaults: the density estimator is now"maf"(was"mdn"); MDN mixture components default to 10 (was 5); NSF spline bins default to 10 (was 8); the training batch size is 200 (was 100).max_epochsis raised to 2000 as a guard cap that early stopping (patience = 20) normally reaches first, mirroringsbi’s effectively-unbounded epoch budget.lr,validation_fraction,patience,clip_grad_norm,n_transforms, andhiddenalready matched. Pass any of these explicitly to recover the previous behavior.First CRAN submission. Dropped the development
.9000version suffix, removed the redundantAuthor/Maintainerfields (now derived fromAuthors@R), and tidied the package title.Embedding networks (roadmap v0.4).
embedding_mlp()builds a learned summary network that maps raw observations to a low-dimensional feature vector; pass it tonpe(..., embedding_net = )and the MDN, MAF, and NSF estimators condition on the features instead of the raw data, training the embedding jointly. The estimators still take rawxat thede_*boundary (dim_xis unchanged), so sampling andlog_probroute through the embedding automatically. Ignored, with a warning, bylinear_gaussian.
neuralsbi 0.2.4.9000 (development)
- Vignettes now show real output. They are precomputed: each vignette’s evaluated source lives in
vignettes/<name>.Rmd.orig, andvignettes/precompute.Rbakes it into a staticvignettes/<name>.Rmd(results, printed values, and figures inlined). CI and pkgdown re-render that static Markdown with no torch at build time, so the expensive neural training runs once, locally, instead of on every build. Re-runRscript vignettes/precompute.Rafter editing any.Rmd.orig. - Two-moons calibration study (
inst/benchmarks/two_moons_calibration.R): SBC, expected coverage, and TARP for a two-moons NSF fit, with figures written todocs/figures/(roadmap milestone M2).
neuralsbi 0.2.3.9000
- Package website built with pkgdown, deployed from CI to https://pedroliman.github.io/neuralsbi/.
- Four vignettes that build on each other: getting started, choosing a density estimator, checking the posterior, and the SIR case study (which now also demonstrates
npe_sequential()). Removed a truncated duplicate of the SIR vignette. - README rewritten to the standard terse form; authorship recorded in
DESCRIPTION(Pedro Nascimento de Lima, with ORCID).
neuralsbi 0.2.2.9000
- New
npe_sequential(): multi-round NPE targeting a single observation via truncated-prior proposals (TSNPE, Deistler et al. 2022). Each round truncates the prior to the highest-probability region of the current posterior and retrains on all accumulated simulations; the standard NPE loss stays valid, so no importance correction is needed. Returns annsbi_snpefit that works withposterior(),sample(), and the diagnostics, but is only valid at the targetedx_obs. Verified against the analytic linear-Gaussian posterior.
neuralsbi 0.2.1.9000
- New
tarp()diagnostic andplot_tarp()(Lemos et al. 2023): a joint expected-coverage test using random reference points, complementing the per-parametersbc()ranks. Detects posteriors with calibrated marginals but wrong correlation structure. - New
plot_posterior_predictive(): marginal predictive histograms with the observation marked; returns the observation’s predictive quantiles. - Leakage correction is now under test: with a bounded prior, the renormalized
log_prob()integrates to one over the support and returns-Infoutside it (test-posterior-normalization.R). - Fixed CI.
R CMD checkfailed on three counts: thenpe()example required libtorch (it now uses the torch-freelinear_gaussianestimator and runs unconditionally), the hand-maintainednpe.Rd/fit_mdn.Rdusage sections had drifted behind the code (missingn_restarts,clip_grad_norm,n_transforms, and the"maf"/"nsf"options), andCLAUDE.mdwas not in.Rbuildignore. Thetest-torchjob also failed because torch 0.17 refuses aTORCH_HOMEthat does not exist; the workflow now creates it first.
neuralsbi 0.2.0.9000
- Shared training engine for all neural estimators (
train_conditional_de()): best-of-n restarts, learning-rate decay on plateau, gradient clipping, per-epoch loss history. - Masked Autoregressive Flow (
density_estimator = "maf") and Neural Spline Flow ("nsf", autoregressive rational-quadratic splines) join the MDN and the closed-formlinear_gaussianbaseline. - Benchmark tasks (
task_gaussian_linear(),task_two_moons(),task_slcp(),task_sir()) shared between tests and theinst/benchmarks/head-to-head benchmark harness. -
summary()methods,as.data.frame()tidy accessor,plot_coverage(). - SIR applied case-study vignette.
- CI:
R CMD checkplus atest-torchjob with cached libtorch.
neuralsbi 0.1.0
- First pilot release: priors, single-round amortized
npe(),linear_gaussianand MDN estimators, posterior sampling with leakage correction, SBC, expected coverage, C2ST, posterior-predictive checks,pairplot(),plot_sbc().
