Package: drmTMB 0.7.0

Shinichi Nakagawa

drmTMB: Distributional Regression Models Using Template Model Builder

Fast distributional regression models for univariate and bivariate responses using Template Model Builder. The current implementation focuses on Gaussian, Student-t, and skew-normal location-scale models, known sampling covariance, phylogenetic location effects, random-effect scale models, bivariate residual correlation, positive-continuous, 'Tweedie' semi-continuous, strict-proportion, zero-one bounded, and denominator-aware proportion families, fixed-effect Bernoulli/binomial event-probability models, and fixed-effect Poisson, negative-binomial, zero-inflated, zero-truncated, hurdle count, and ordinal cumulative-logit models. Additional response-family models are staged for later phases. Every fitted family also exposes a distributional-output and adequacy layer: randomized quantile-residual worm and QQ plots that detect fixed-effect shape and atom misspecification, and conditional-quantile, exceedance, and centile outputs with plug-in (uncalibrated) intervals.

Authors:Shinichi Nakagawa [aut, cre, cph]

drmTMB_0.7.0.tar.gz
drmTMB_0.7.0.zip(r-4.7-x86_64)drmTMB_0.7.0.zip(r-4.7-arm64)drmTMB_0.7.0.zip(r-4.6-x86_64)drmTMB_0.7.0.zip(r-4.6-arm64)
drmTMB_0.7.0.tar.gz(r-4.7-arm64)drmTMB_0.7.0.tar.gz(r-4.7-x86_64)drmTMB_0.7.0.tar.gz(r-4.6-arm64)drmTMB_0.7.0.tar.gz(r-4.6-x86_64)
drmTMB_0.7.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
drmTMB/json (API)

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

Bug tracker:https://github.com/itchyshin/drmtmb/issues

Pkgdown/docs site:https://itchyshin.github.io

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

On CRAN:

Conda:

cpp

5.71 score 318 scripts 59 exports 8 dependencies

Last updated from:4996a6f768. Checks:10 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK402
linux-devel-x86_64OK441
source / vignettesOK584
linux-release-arm64OK469
linux-release-x86_64OK430
windows-devel-arm64OK467
windows-devel-x86_64OK567
windows-release-arm64OK464
windows-release-x86_64OK488
wasm-releaseOK206

Exports:animalassociate_pairsassociationbetabeta_binomialbfbiv_associatebiv_gaussianbiv_lognormalbiv_studentcategoricalcentile_chartcheck_drmcorpaircorpairscumulative_logitdrm_controldrm_formuladrm_phylo_penaltydrm_phylo_penalty_sweepdrmTMBexceedancefitted_distributionfixefgrimpute_modelimputedis_convergedlatent_normallognormalmake_meshmarginal_parametersmeta_known_Vmeta_Vmeta_vcov_bivariatemimiss_controlnbinom2phylophylo_interactionplot_corpairsplot_parameter_surfacepredict_parametersprediction_gridprofile_targetsqq_plotranefrelmatrho_latentrho12skew_normalspatialspatial_coordsstructured_effectsstudenttruncated_nbinom2tweedieworm_plotzero_one_beta

Dependencies:clilatticelifecycleMatrixRcppRcppEigenrlangTMB

Adding distribution families
Scope first | Start with the mathematical contract | Define the registry entry | Do not assume identity links | Connect the family to the builder | Implement the likelihood | Add simulation and method support | Write tests before calling the family implemented | Update user and developer documentation | Close with an after-task audit

Last update: 2026-09-15
Started: 2026-09-15

Animal models and additive relatedness
What is fitted today | Start with the smallest useful model | What to inspect | Rendered checks

Last update: 2026-09-15
Started: 2026-09-15

Association between mixed outcome pairs
The question in an ecological example | One call, two stages | What a binary outcome contributes | Reviewed pair classes | Standard error and confidence interval | When the estimate or interval is withheld | Can the association itself be modelled? | How this differs from rho12

Last update: 2026-09-15
Started: 2026-09-15

Bivariate non-Gaussian models: choose a joint or staged association
Start by choosing the association scale | Direct joint model: two positive traits | Real example: penguin size after measured composition differences | Direct joint model: two heavy-tailed traits | Staged association: different kinds of outcome | What is currently outside these routes

Last update: 2026-09-15
Started: 2026-09-15

Can I fit and report this model?
Before reporting | Evidence and exact tested scopes | Capability tiers, defined once | Historical capability skim (technical evidence) | Detailed route evidence | Tier 1: inference-ready | Gaussian structured random effects: selected anchor cells | Ordinary (unstructured) random effects: point-trustworthy, coverage pending | Unstructured non-Gaussian fixed effects | Ordinary non-Gaussian random slopes: profile intervals with caveats | Gamma sigma random intercept: narrow coverage-backed interval | Tier 2: recovery-only | Tier 3: diagnostic-only | Tier 4: not available or rejected by design | Known limitations for 0.7.0 | Frozen-margin association intervals | Missing data | Full per-family capability map | Choosing an interval method | Where the exhaustive detail lives

Last update: 2026-09-15
Started: 2026-09-15

Changing residual coupling with rho12
Equations for the implemented model | Worked example: behaviour coupling and disturbance | What should I report? | Reading group-level covariance | First slope-slope covariance slice | Boundaries for this covariance layer

Last update: 2026-09-15
Started: 2026-09-15

Choosing response families
At a glance | Why sigma is not always phi | Reporting variation | Implemented univariate families | Bounded and ordered families | Bivariate Gaussian families

Last update: 2026-09-15
Started: 2026-09-15

Comparing drmTMB with other packages
What this article compares | Checked against a separate estimation engine | Comparison 1: contagious bovine pleuropneumonia across periods and herds | Comparison 2: the pooled BCG vaccine effect | Comparison 3: does heterogeneity itself differ by allocation design? | Checked against ordinal | Comparison 4: does serving temperature shift wine bitterness ratings? | Comparison 5: do judges differ, and does that change the temperature effect? | Checked against a package built on the same machinery | Comparison 6: does reaction-time variability grow with sleep deprivation? | Comparison 7: are male penguins more variable in body mass than females? | Comparison 8: are satiated owl broods more variable, not just quieter? | What these eight comparisons show | Reproducing these numbers

Last update: 2026-09-15
Started: 2026-09-15

Coordinate-spatial structured effects
What is fitted today | Start with the smallest useful model | Geographic coordinates and the fixed-kappa mesh route | What to inspect | Rendered checks | Boundaries

Last update: 2026-09-15
Started: 2026-09-15

Count abundance and extra zeros
Model Equation And Syntax | A Soil-Invertebrate Example | When Zeros Are A Separate Process | Current Boundary

Last update: 2026-09-15
Started: 2026-09-15

Distributional regression with drmTMB
Install the pre-CRAN release | Fit your first model | Learning path | Check before interpreting

Last update: 2026-09-15
Started: 2026-09-15

Errors, warnings, and convergence
Start with check_drm() | Use drm_control() for optimizer limits | If the optimizer did not converge | If pdHess is false | When bivariate phylogenetic correlations are near a boundary | Penalized / MAP estimation for weakly-identified phylogenetic components | Choosing between maximum likelihood and REML | Separate optimization from uncertainty | Model-specific advice | What is planned but not automatic yet | Further reading

Last update: 2026-09-15
Started: 2026-09-15

First-week intervals: fit, profile, and boundary
Default recipe (read once) | Fit a small random-intercept model | Inventory targets, then profile the RE-SD | Read profile.boundary before you trust the interval | What to read next

Last update: 2026-09-15
Started: 2026-09-15

Formula grammar
Current status map | Offsets

Last update: 2026-09-15
Started: 2026-09-15

Handling missing data
Capability matrix | What is fitted now | Choosing the predictor family | Relation to gllvmTMB and glmmTMB | Missing responses | Partial bivariate response pairs | Missing predictors | Binary missing predictors | Non-Gaussian responses with binary missing predictors | Ordered missing predictors | Unordered missing predictors | Strict proportion missing predictors | Boundary proportion missing predictors | Denominator-aware proportion missing predictors | Count missing predictors | Positive continuous missing predictors | Semi-continuous missing predictors with exact zeros | Grouped and structured predictor models | Current boundaries

Last update: 2026-09-15
Started: 2026-09-15

Implementation map
How to read the project maps | Family and component map | Current capability and evidence map | Random-effect and dependence map | Slope coverage at a glance | Current future-work lanes | Common planned requests

Last update: 2026-09-15
Started: 2026-09-15

Implemented source map
Routing overview | Implemented paths | What the source map protects | C++ modularization boundary | Validation-debt register | Current boundaries

Last update: 2026-09-15
Started: 2026-09-15

Julia engine: future support
What to use now | What future Julia support would need to establish | Scope boundary

Last update: 2026-09-15
Started: 2026-09-15

Known-matrix relatedness with relmat
When is relmat() the right tool? | Choosing K or Q | Two concrete examples | What is fitted today | Start with the smallest useful model | What to inspect | Rendered checks

Last update: 2026-09-15
Started: 2026-09-15

Model selection with AIC and BIC
Gaussian REML After Mean-Model Selection | Tail Assumption | Structural Zeros | Scale Formula | A 200-Replicate Article-Support Simulation | Practical Checklist

Last update: 2026-09-15
Started: 2026-09-15

Phylogenetic mixed models
The phylogenetic covariance | A small tree with ape::rcoal() | Simulating a Gaussian trait with phylogenetic signal | Fitting with phylo(1 | species) | Reading the phylogenetic signal | Uncertainty for the two SDs | Non-Gaussian responses | A larger fit, for reference | What phylo() fits today | References

Last update: 2026-09-15
Started: 2026-09-15

Proportions and success rates
Choose The Proportion Route | Plain Binomial Equation And Syntax | Beta-Binomial Equation And Syntax | Seed Germination Example | Strict Continuous Proportions | Continuous Proportions With Exact Boundaries | Current Boundary

Last update: 2026-09-15
Started: 2026-09-15

Random-effects meta-analysis with known sampling variances
The model | A simulated dataset | Fitting the model | The pooled effect | Between-study heterogeneity | Cross-check against metafor | REML for the heterogeneity | Meta-regression: moderators on the mean | Multiple effect sizes per study | Layered heterogeneity: an experimental contract | Known sampling variance is not a weight | Correlated effect sizes: a small dense covariance example | Notes on the function names | Reference

Last update: 2026-09-15
Started: 2026-09-15

Robust continuous responses
Model equation and R syntax | A seedling growth example | Check the fitted robust model | Interpret coefficients by parameter | Compare with the Gaussian model | Current boundary

Last update: 2026-09-15
Started: 2026-09-15

Structural dependence overview
Pick the route | What to read next | Fitted versus planned

Last update: 2026-09-15
Started: 2026-09-15

Testing likelihoods
The contract | Tier 1: comparator checks | Tier 2: simulation recovery | Independent likelihood checks | Bivariate and coscale checks | Boundary and rejection tests | Fast and long tests | Before closing a task

Last update: 2026-09-15
Started: 2026-09-15

Two-tree phylogenetic interactions
What is fitted today | A small count example | Independent pairs are a different question | When to reach for relmat() | What this does not claim

Last update: 2026-09-15
Started: 2026-09-15

What can I fit today?
Stable-core matrix | One response | Two responses | Structural dependence | Planned, not implemented | Correlation layers | A practical trait protocol | Where to go next

Last update: 2026-09-15
Started: 2026-09-15

When variance carries signal, Part 1: location-scale models
Model equations and matching R syntax | Grouped effects do not change the meaning of sigma | Interpret sigma on the SD or variance scale | Worked example: growth mean and predictability | Curved responses and interactions | Continue to Part 2 | Current implementation boundaries

Last update: 2026-09-15
Started: 2026-09-15

When variance carries signal, Part 2: location-scale-scale models
Personality, predictability, and repeatability | Simulate and fit the three submodels | Read the fitted scales and calculate repeatability | What this example supports | Reference

Last update: 2026-09-15
Started: 2026-09-15

Which scale are you modelling?
Residual standard deviation | Mean-model random intercept | Residual-scale random intercept | Random-effect scale formula | One location model, several scale quantities | A copy-run scale audit | Residual scale: sigma ~ temperature | Known sampling variance: meta_V(V = V) | Random-effect scale: sd(population) ~ habitat | Side-by-side guide | Correlations: group-level versus residual | Family A versus Family B | Current boundary

Last update: 2026-09-15
Started: 2026-09-15

Working with large data
What is implemented now | Large tip counts and se_group_sd | What this does not solve yet | Choose the interval route deliberately | Check the fit with the storage choice in mind | Avoid accidental full-row output | Benchmark before the full run | What the current development benchmarks say | Practical checklist

Last update: 2026-09-15
Started: 2026-09-15

Readme and manuals

Help Manual

Help pageTopics
Animal-model structured-effect markeranimal
Likelihood comparison guard for drmTMB fitsanova.drmTMB
Associate two frozen marginal drmTMB fitsassociate_pairs
Extract a pair association estimateassociation association.drm_pair_association
Beta response familybeta
Beta-binomial response familybeta_binomial
Fit two margins and construct a frozen-margin association in one callbiv_associate
Bivariate Gaussian response familybiv_gaussian
Bivariate lognormal response familybiv_lognormal
Bivariate Student-t response familybiv_student
Unordered categorical missing-predictor familycategorical
Model-conditional centile chartcentile_chart centile_chart.drmTMB
Check convergence and diagnostic flags for a drmTMB fitcheck_drm check_drm.drmTMB
Confidence intervals for a frozen-margin associationconfint.drm_pair_association
Confidence intervals for fitted model parametersconfint.drmTMB
Inspect legacy interval output from a halted Julia bridgeconfint.drmTMB_julia
Latent random-effect correlation formula markercorpair
Extract fitted correlation pairscorpairs corpairs.drmTMB
Cumulative logit ordinal response familycumulative_logit
Control fitting and fitted-object storagedrm_control
Build a drmTMB formula objectbf drm_formula
Penalty / prior specification for a phylogenetic location-scale fitdrm_phylo_penalty
Prior-sensitivity sweep for the phylogenetic correlation penaltydrm_phylo_penalty_sweep
Fit a distributional regression model with TMBdrmTMB
Exceedance probability from a fitted modelexceedance exceedance.drmTMB
Fitted distribution accessorfitted_distribution fitted_distribution.drmTMB
Extract fitted response valuesfitted.drmTMB
Extract fixed-effect coefficientscoef.drmTMB fixef fixef.drmTMB
Define a missing-predictor modelimpute_model
Extract fitted missing-predictor summariesimputed imputed.drmTMB
Check whether a fit convergedis_converged is_converged.default is_converged.drmTMB
Construct a latent-normal association kernellatent_normal
Lognormal response familylognormal
Construct a fixed-kappa SPDE meshmake_mesh
Marginal summaries of predicted distributional parametersmarginal_parameters marginal_parameters.drmTMB
Known sampling covariance markermeta_V
Build paired bivariate sampling covariancemeta_vcov_bivariate
Missing-predictor model markermi
Configure missing-data handlingmiss_control
Stable native reader contractsnative_reader_contracts
Negative binomial 2 response familynbinom2
Phylogenetic structured-effect markerphylo
Bipartite phylogenetic interaction markerphylo_interaction
Plot fitted correlation-pair summariesplot_corpairs
Plot predicted distributional-parameter surfacesplot_parameter_surface
Plot profile-likelihood curvesplot.profile.drmTMB
Predict distributional parameters in long formatpredict_parameters predict_parameters.drmTMB
Predict a frozen-margin pair associationpredict.drm_pair_association
Predict distributional parameterspredict.drmTMB
Predict from a legacy Julia-bridge 'drmTMB' fitpredict.drmTMB_julia predict.drmTMB_julia_xfam
Build prediction grids for distributional-parameter summariesprediction_grid prediction_grid.drmTMB
List confidence-interval targets for a fitted modelprofile_targets
Compute profile-likelihood curves for fitted model targetsprofile.drmTMB
Normal QQ plot of randomized quantile residualsqq_plot
Random-effect scale formula syntaxrandom_effect_scale_formulas sd sd1 sd2 sd_phylo sd_phylo1 sd_phylo2
Extract conditional random-effect estimatesranef ranef.drmTMB
User-supplied relatedness structured-effect markerrelmat
Extract model residualsresiduals.drmTMB
Extract a latent-scale correlation from a legacy Julia-bridge fitrho_latent
Extract residual correlation rho12rho12 rho12.drmTMB
Extract fitted scale or dispersionsigma.drmTMB
Simulate from a fitted modelsimulate.drmTMB
Skew-normal response familyskew_normal
Spatial structured-effect markerspatial
Transform longitude and latitude to planar spatial coordinatesspatial_coords
Extract structured-effect metadatastructured_effects structured_effects.default structured_effects.drmTMB
Student-t response familystudent
Summarize a fitted modelsummary.drmTMB
Summarise a legacy Julia-bridge 'drmTMB' fitsummary.drmTMB_julia
Summary for a legacy Julia cross-family fitsummary.drmTMB_julia_xfam
Zero-truncated negative binomial 2 response familytruncated_nbinom2
Tweedie response familytweedie
Alpha-scale covariance for a frozen-margin associationvcov.drm_pair_association
Extract standard model-fit quantitiesAIC.drmTMB BIC.drmTMB deviance.drmTMB df.residual.drmTMB logLik.drmTMB model-fit-extractors nobs.drmTMB vcov.drmTMB
Extractor unavailable for a legacy cross-family Julia fitvcov.drmTMB_julia_xfam
Extract likelihood weightsweights.drmTMB
Worm plot of randomized quantile residualsworm_plot
Zero-one beta response familyzero_one_beta