Formula lines: describe how clearance (CL) and volume (V) vary between subjects.
Custom calculation: the do block computes the concentration curve.
Observation line: compares that curve with measured concentrations.
The shared pk label allows clearance and volume effects to be correlated.
Formulas and a custom calculation live in the same model declaration.
StanBlocks example. Turing currently rejects this ragged response. Body of the existing @brm begin … end declaration; complete code and data in appendix B. kernel runs the calculation for each subject.
Subjects and measurements can fit together
The same PK example
# Subject axis: one row per subject.subject=["alice", "bob"],dose=[100.0, 80.0],# Observation axis: one row per sample, interleaved by subject.obs_subject=["alice", "bob", "alice", "bob", "alice"],time=[0.5, 0.25, 1.5, 1.0, 3.0],concentration=[8.1, 7.6, 5.2, 4.9, 2.1],
Two subjects, five measurements.
Each subject has a dose, clearance, and volume. Each measurement has a time and a subject label.
ragged(time, obs_subject) groups the times for the calculation. The response uses the same grouping.
Describe subject differences with formulas; evaluate the curve at each subject’s measurement times.
Data fields passed to the declaration on the previous slide. The interleaved rows are intentional.
The same approach reaches larger models
Existing BRM examples with custom scientific calculations
Warfarin PK/PD
Subject effects feed concentration calculations and an ODE for drug response.
Same probability model, different variables for the sampler
Sample the coefficient directly
Often useful when the data strongly identify the coefficient.
Sample a scaled coefficient
Often useful when the data provide less information.
BRM’s HSGP example can choose between these forms separately for each coefficient.
The example models motorcycle-impact acceleration over time, with a Gaussian process for the mean and another for the noise level. It uses all 133 observations and 20 basis functions per process.
One model, three recorded fits
Corrected HSGP study · StanBlocks sampling
Each coefficient gets its own choice. Zero is fully noncentered; one is fully centered. The two selection procedures need not agree.
Noncentered pilot10,000 draws · 34 divergencesmax split R-hat 1.0012 · min bulk/tail ESS 2,514 / 2,886
Fresh partially centered fit10,000 draws · 16 divergencesmax split R-hat 1.0007 · min bulk/tail ESS 2,533 / 1,797
Separate online extension10,000 draws · 0 divergencesmax split R-hat 1.0018 · min bulk/tail ESS 2,318 / 2,775
One chain per fit. These counts do not establish a general improvement in speed or accuracy. Split R-hat compares parts of the same chain.
No corrected Turing samples. Target-value agreement and warmed gradient runtime still need verification.
Make predictions with the fitted model
Keep the meaning of the regression when the data change
During fitting
Store the category levels, scaling constants, spline knots, and GP basis used to construct the model.
For new measurements
Apply those same transformations to new inputs, so the posterior coefficients still have the same meaning.
For new subjects
Choose explicitly how new group effects are generated. Check that the model and execution path support the requested prediction.
Custom model components should fit into the prediction workflow as well as the model declaration.
Current operations have documented limits; this is not a claim that every custom component already supports every prediction task.
A possible future: Julia models on GPUs
A concrete direction to investigate
The compiler path exists
Reactant compiles Julia computations through MLIR and XLA for CPU, GPU, and TPU execution.
It also documents a probabilistic-programming interface, including custom log-density functions.
BRM integration remains to be shown
A possible next step is to compile suitable Julia model code through this path.
Compatibility, gradients, and useful performance need to be demonstrated on actual BRM models.
Keep the model declaration useful as more of its computation can run on accelerators.
Use concise formulas for the regression parts, and combine them with custom model code when the science needs more.
The PK example shows the idea today. The larger examples show where it can go—and which execution and prediction details still need work.
Current execution support
Appendix A
Model component
Execution
Current boundary
Population and distributional regression
StanBlocks + Turing
Shared formulas, links, and prior addresses.
Group effects, advanced terms, modified responses
Both, within limits
Individual features and their combinations have specific supported subsets.
Ordinary Julia callables without a Stan translation
Turing
Density, gradient, transform, and prediction requirements still apply.
Custom structural code written for StanBlocks
StanBlocks
A Julia implementation is needed before Turing can execute that code.
Corrected HSGP centering study
StanBlocks sampled
No corrected Turing samples; see the study-specific checks in appendix E.
This table covers the two paths discussed here. BRM also has vectorized Julia execution and a narrower experimental NativePPL path; neither is presented as a verified GPU backend.
StanBlocks example; Turing does not yet support the ragged-response wrapper. Julia setup: using BayesianRegressionModels, Distributions. Code and data are read from the executable feature atlas.
Cited authors and prospective guests have not reviewed or endorsed this deck. Immutable scientific-source revisions and further references are in the README.