Plot for Summary pf BDLIM
Usage
# S3 method for summary.bdlim4
plot(x, ...)
Examples
# \donttest{
# run BDLIM with modification by ChildSex
fit_sex <- bdlim4(
y = sbd_bdlim$bwgaz,
exposure = sbd_bdlim[,paste0("pm25_",1:37)],
covars = sbd_bdlim[,c("MomPriorBMI","MomAge","race","Hispanic",
"EstMonthConcept","EstYearConcept")],
group = as.factor(sbd_bdlim$ChildSex),
df = 5,
nits = 5000,
parallel = FALSE
)
#> fitting bw
#> fitting b
#> fitting w
#> fitting n
#> postprocessing
#> postprocessing
# show model comparison results
fit_sex
#>
#> Call:
#> bdlim4(y = sbd_bdlim$bwgaz, exposure = sbd_bdlim[, paste0("pm25_",
#> 1:37)], covars = sbd_bdlim[, c("MomPriorBMI", "MomAge", "race",
#> "Hispanic", "EstMonthConcept", "EstYearConcept")], group = as.factor(sbd_bdlim$ChildSex),
#> df = 5, nits = 5000, parallel = FALSE)
#>
#> Modification pattern probabilities (higher is better fit):
#> *bw* b w n
#> 0.5316 0.3612 0.1060 0.0012
#>
#> Modification pattern WAIC (lower is better fit):
#> *bw* b w n
#> 1 1634.63 1636.322 1644.544 1656.145
#>
#> Note: Model probabilities tend to favor more complex models compared to WAIC. It is recomended to use model probabilities for selecting the modification pattern and WAIC to compare degrees of freedom for the weight function.
#summarize results
sfit_sex <- summary(fit_sex)
# graph the estimated distributed lag functions for each group
plot(sfit_sex)
# can save plot as an object and modify with ggplot2
library(ggplot2)
plt <- plot(sfit_sex)
plt + ggtitle("My plot with BDLIM") +
ylab("Estimated expected difference in\nBWGAZ per 1 ug/m3 increase in exposure")
# the summary file has the data to make this plot
head(sfit_sex$dlfun)
#> group time mean median sd q2.5 q97.5
#> 1 F 1 -0.0003490371 -9.270483e-05 0.007816792 -0.01706734 0.017316128
#> 2 F 2 -0.0009985932 -4.063122e-04 0.006361837 -0.01543235 0.012458078
#> 3 F 3 -0.0016288140 -9.604084e-04 0.005140199 -0.01362299 0.008198118
#> 4 F 4 -0.0022203644 -1.413547e-03 0.004306654 -0.01266242 0.005071297
#> 5 F 5 -0.0027539091 -1.699400e-03 0.003990050 -0.01217955 0.003228750
#> 6 F 6 -0.0032101129 -2.139796e-03 0.004145476 -0.01282832 0.002611162
#> pr_gr0
#> 1 0.4856
#> 2 0.4376
#> 3 0.3800
#> 4 0.3292
#> 5 0.2592
#> 6 0.2228
# }