Skip to contents

This vignette demonstrates the implementation of heterogeneous treed distributed lag mixture model (HDLMM).

Load data

Simulated data is available on GitHub. It can be loaded with the following code.

sbd_dlmtree <- get_sbd_dlmtree()

Data preparation

# Response and covariates
sbd_cov <- sbd_dlmtree %>% 
            select(bwgaz, ChildSex, MomAge, GestAge, MomPriorBMI, Race,
                    Hispanic, MomEdu, SmkAny, Marital, Income,
                    EstDateConcept, EstMonthConcept, EstYearConcept)

# Exposure data
sbd_exp <- list(PM25 = sbd_dlmtree %>% select(starts_with("pm25_")),
                TEMP = sbd_dlmtree %>% select(starts_with("temp_")),
                SO2 = sbd_dlmtree %>% select(starts_with("so2_")),
                CO = sbd_dlmtree %>% select(starts_with("co_")),
                NO2 = sbd_dlmtree %>% select(starts_with("no2_")))
sbd_exp <- sbd_exp %>% lapply(as.matrix)

Fitting the model

# Gaussian
hdlmm.fit <- dlmtree(formula = bwgaz ~ ChildSex + MomAge + MomPriorBMI +
                                        Race + Hispanic + SmkAny + EstMonthConcept,
                     data = sbd_cov,
                     exposure.data = sbd_exp,
                     family = "gaussian",
                     dlm.type = "linear", mixture = TRUE, het = TRUE,
                     hdlm.modifiers = c("ChildSex", "MomAge", "MomPriorBMI", "SmkAny"),
                     hdlm.modifier.splits = 15,
                     n.burn = 2500, n.iter = 10000, n.thin = 5)
#> Preparing data...
#> 
#> Running HDLMM:
#> Burn-in % complete 
#> [0--------25--------50--------75--------100]
#>  ''''''''''''''''''''''''''''''''''''''''''
#> MCMC iterations (est time: 12 minutes)
#> [0--------25--------50--------75--------100]
#>  ''''''''''''''''''''''''''''''''''''''''''
#> Compiling results...

Model fit summary

hdlmm.sum <- summary(hdlmm.fit)
hdlmm.sum
#> ---
#> HDLMM summary
#> 
#> Model run info:
#> - bwgaz ~ ChildSex + MomAge + MomPriorBMI + Race + Hispanic + SmkAny + EstMonthConcept 
#> - family: gaussian 
#> - 20 trees
#> - 2500 burn-in iterations
#> - 10000 post-burn iterations
#> - 5 thinning factor
#> - 5 exposures measured at 37 time points
#> - 10 two-way interactions (no-self interactions)
#> - 0.5 modifier sparsity prior
#> - 1 exposure sparsity prior
#> - 0.95 confidence level
#> 
#> Fixed effects:
#>                        Mean  Lower  Upper
#> *(Intercept)          1.469  0.843  2.205
#>  ChildSexM           -0.525 -1.930  0.427
#>  MomAge               0.000 -0.003  0.003
#> *MomPriorBMI         -0.021 -0.023 -0.018
#>  RaceAsianPI          0.030 -0.098  0.148
#>  RaceBlack            0.042 -0.088  0.174
#>  Racewhite            0.021 -0.101  0.143
#> *HispanicNonHispanic  0.253  0.230  0.275
#> *SmkAnyY             -0.396 -0.441 -0.349
#>  EstMonthConcept2     0.107 -0.041  0.187
#>  EstMonthConcept3     0.186 -0.105  0.308
#>  EstMonthConcept4     0.267 -0.112  0.430
#>  EstMonthConcept5     0.362 -0.011  0.543
#> *EstMonthConcept6     0.343  0.023  0.536
#> *EstMonthConcept7     0.372  0.149  0.553
#> *EstMonthConcept8     0.348  0.195  0.517
#> *EstMonthConcept9     0.419  0.271  0.559
#> *EstMonthConcept10    0.300  0.175  0.416
#> *EstMonthConcept11    0.199  0.094  0.301
#>  EstMonthConcept12    0.037 -0.034  0.116
#> ---
#> * = CI does not contain zero
#> 
#> Modifiers:
#>               PIP
#> ChildSex    1.000
#> MomAge      0.954
#> MomPriorBMI 0.992
#> SmkAny      0.283
#> ---
#> PIP = Posterior inclusion probability
#> 
#> residual standard errors: 0.007
#> ---
#> To obtain exposure effect estimates, use the 'shiny(fit)' function.

Launching Shiny app

# shiny(hdlmm.fit)