Learn R Programming

dlmtree

dlmtree is an R package that provides constrained distributed lag models (DLMs) using a regression tree approach within the Bayesian additive regression trees (BART) framework, referred to as treed DLMs. The package includes various extensions of treed DLMs, allowing for the incorporation of different scenarios like linear, non-linear associations, mixture exposures, and heterogeneous exposure effects. The package is built user-friendly with a single function with three arguments to specify treed DLMs. Functions for summarizing the model fit and visualization are also provided.

Treed DLM Overview

ModelTypeFamilyMixtureHeterogeneity
Treed distributed lag model (TDLM)2LinearGaussianXX
BinaryXX
CountXX
Treed distributed lag mixture model (TDLMM)2LinearGaussianOX
BinaryOX
CountOX
Treed distributed non-linear lag model (TDLNM)1, 4Non-linearGaussianXX
BinaryXX
MonotoneGaussianXX
BinaryXX
Heterogeneous distributed lag model (HDLM)3LinearGaussianXO
Heterogeneous distributed lag mixture model (HDLMM)LinearGaussianOO

Model Selection Guide

Installation

Installing package from GitHub:

# install.packages("devtools")
devtools::install_github("danielmork/dlmtree")
library(dlmtree)

Installing package from CRAN:

install.packages("dlmtree")
library(dlmtree)

References

The following paper describes this package, including a high-level overview of methods, R syntax and examples.

  1. Im, S., Wilson, A. and Mork, D. (In Press). “Structured Bayesian Regression Tree Models for Estimating Distributed Lag Effects: The R Package dlmtree.” The R Journal (arXiv preprint)

The majority of methods implemented in this package are described in the following methods papers as well as some on going work.

  1. Mork, D. and Wilson, A. (2022). “Treed distributed lag nonlinear models.” Biostatistics, 23(3), 754–771 (DOI: 10.1093/biostatistics/kxaa051, arXiv preprint)

  2. Mork, D. and Wilson, A. (2023). “Estimating perinatal critical windows of susceptibility to environmental mixtures via structured Bayesian regression tree pairs.” Biometrics, 79(1), 449-461 (DOI: 10.1111/biom.13568, arXiv preprint)

  3. Mork, D., Kioumourtzoglou, M. A., Weisskopf, M., Coull, B. A., and Wilson, A. (2024). “Heterogeneous Distributed Lag Models to Estimate Personalized Effects of Maternal Exposures to Air Pollution.” Journal of the American Statistical Association, 119(545), 14-26 (DOI: 10.1080/01621459.2023.2258595, arXiv preprint)

  4. Mork, D. and Wilson, A. (In press). “Incorporating prior information into distributed lag nonlinear models with zero-inflated monotone regression trees.” Bayesian Analysis. (DOI: 10.1214/23-BA1412, arXiv preprint)

Copy Link

Version

Install

install.packages('dlmtree')

Monthly Downloads

605

Version

1.1.1

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Daniel Mork

Last Published

February 3rd, 2026

Functions in dlmtree (1.1.1)

plot.summary.tdlnm

Returns variety of plots for model summary of class 'tdlnm'
dlmtreeHDLMGaussian

dlmtree model with shared HDLM approach
rcpp_pgdraw

Multiple draw polya gamma latent variable for var c[i] with size b[i]
dlmtree.control.family

Family control settings for dlmtree model fitting
plot.summary.tdlmm

Plots DLMMs for model summary of class 'tdlmm'
exposureCov

Exposure covariance structure
print

print
plot.summary.tdlm

Plots a distributed lag function for model summary of 'tdlm'
get_sbd_dlmtree

Download simulated data for dlmtree articles
splitpoints

Determines split points for continuous modifiers
dlmtree.control.het

Control settings for dlmtree model fitting, when used for heterogeneous models
monotdlnm_Cpp

dlmtree model with monotone tdlnm approach
mixEst

Calculates the lagged interaction effects with MIX matrix for linear models.
dlmtreeTDLM_cpp

dlmtree model with nested HDLM approach
dlmtreeTDLMNestedGaussian

dlmtree model with nested Gaussian approach
rtmvnorm

Truncated multivariate normal sampler, mean mu, cov sigma, truncated (0, Inf)
pm25Exposures

PM2.5 Exposure data
ruleIdx

Calculates the weights for each modifier rule
summary

summary
sim.hdlmm

Creates simulated data for HDLM & HDLMM
sim.tdlmm

Creates simulated data for TDLM & TDLMM
tdlnm_Cpp

dlmtree model with tdlnm approach
tdlmm_Cpp

dlmtree model with tdlmm approach
ppRange

Makes a 'pretty' output of a group of numbers
drawTree

Draws a new tree structure
estDLM

Calculates subgroup-specific lag effects for heterogeneous models
dlnmEst

Calculates the distributed lag effect with DLM matrix for non-linear models.
scaleModelMatrix

Centers and scales a matrix
predict

predict
shiny

shiny
zeroToInfNormCDF

Integrates (0,inf) over multivariate normal
zinbCo

Time-series exposure data for ZINB simulated data
pip

Calculates posterior inclusion probabilities (PIPs) for modifiers in HDLM & HDLMM
dlnmPLEst

Calculates the distributed lag effect with DLM matrix for non-linear models.
plot.summary.monotone

Returns variety of plots for model summary of class 'monotone'
splitPIP

Calculates the posterior inclusion probability (PIP).
sim.tdlnm

Creates simulated data for TDLNM
dlmtree

Fit tree structured distributed lag models
adj_coexposure

Adjusting for expected changes in co-exposure (TDLMM)
dlmEst

Calculates the distributed lag effect with DLM matrix for linear models.
cppIntersection

fast set intersection tool assumes sorted vectors A and B
diagnose.summary.hdlm

diagnose
dlmtree.control.mcmc

MCMC control settings for dlmtree model fitting
dlmtreeHDLMMGaussian

dlmtree model with HDLMM approach
dlmtree.control.diagnose

Diagnostic control settings for dlmtree model fitting
dlmtree.control.hyper

Hyperparameter control settings for dlmtree model fitting
dlmtree-package

dlmtree: Bayesian Treed Distributed Lag Models
dlmtreeTDLMFixedGaussian

dlmtree model with fixed Gaussian approach
dlmtreeGPGaussian

dlmtree model with Gaussian process approach
combine.models

Combines information from DLMs of single exposure
combine.models.tdlmm

Combines information from DLMs of mixture exposures.
coExp

Randomly sampled exposure from Colorado counties
dlmtree.control.mix

Control settings for dlmtree model fitting, when used for mixture models
dlmtree.control.monotone

Control settings for dlmtree model fitting, when used for monotone model
dlmtree.control.tdlnm

Control settings for dlmtree model fitting, when used for TDLNM
dlmtreeGPFixedGaussian

dlmtree model with fixed Gaussian process approach