Fit the BDLIM model with all 4 patterns of modification
Usage
bdlim4(
y,
exposure,
covars,
group,
id = NULL,
df,
nits,
nburn = round(nits/2),
nthin = 1,
parallel = FALSE,
family = "gaussian"
)
Arguments
- y
A vector of outcomes
- exposure
A matrix of exposures with one row for each individual
- covars
A matrix or data.frame of covariates This should not include the grouping factor (see group below). This may include factor variables.
- group
A vector of group memberships. This should be a factor variable.
- id
An optional vector of individual IDs if there are repeated measures or other groupings that a random intercept should be included for. This must be a factor variable.
- df
Degrees of freedom for the weight functions
- nits
Number of MCMC iterations.
- nburn
Number of MCMC iterations to be discarded as burn in. The default is half if the MCMC iterations. This is only used for WAIC in this function but is passed to summary and plot functions and used there.
- nthin
Thinning factors for the MCMC. This is only used for WAIC in this function but is passed to summary and plot functions and used there.
- parallel
Logical to use parallel computing for 4 models. If TRUE then the min of 4 and number of cores available will be used.
- family
Family of model to be used. Supported options are "gaussian" for a normal/Gaussian linear model and "binomial" for a logistic model.
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.4940 0.3600 0.1452 0.0008
#>
#> Modification pattern WAIC (lower is better fit):
#> *bw* b w n
#> 1 1635.946 1637.782 1644.031 1656.078
#>
#> 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)
sfit_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)
#>
#>
#> Model fit statistics:
#> *bw* b w n
#> 0.4940 0.3600 0.1452 0.0008
#>
#>
#> Estimated cumulative effects:
#> group mean median sd q2.5 q97.5 pr_gr0
#> F -0.01659887 -0.008101259 0.06340898 -0.1663946 0.1041476 0.4092
#> M -0.44644829 -0.446032044 0.08075686 -0.6050052 -0.2913208 0.0000
#>
#>
#> Estimated covariate regression coefficients:
#> name mean median sd q2.5
#> interceptF 5.6583604865 5.587622037 6.324598745 -6.899013907
#> interceptM 6.1139550664 6.113260967 6.328272199 -6.343814379
#> MomPriorBMI -0.0160120545 -0.016071038 0.003164924 -0.022310237
#> MomAge 0.0009648609 0.001019695 0.003001433 -0.005132967
#> raceAsianPI -0.0193478000 -0.022201013 0.176731906 -0.370170412
#> raceBlack -0.1009289662 -0.106402046 0.182161721 -0.461531498
#> racewhite -0.0492555570 -0.052519489 0.169597474 -0.383898780
#> HispanicNonHispanic 0.2561880862 0.256460145 0.040328323 0.177703903
#> EstMonthConcept2 -0.1456010127 -0.145619513 0.094047066 -0.334729657
#> EstMonthConcept3 -0.1018310104 -0.100479865 0.097587152 -0.293708791
#> EstMonthConcept4 -0.1777050692 -0.177051413 0.093697149 -0.360857515
#> EstMonthConcept5 -0.0997951260 -0.099628993 0.087543279 -0.271519613
#> EstMonthConcept6 -0.1854240922 -0.184277602 0.083848860 -0.353776238
#> EstMonthConcept7 -0.0449401834 -0.044617866 0.085212533 -0.207681656
#> EstMonthConcept8 0.1527704643 0.155778943 0.096301796 -0.045010557
#> EstMonthConcept9 0.3135320710 0.311492996 0.092667590 0.124903697
#> EstMonthConcept10 0.4140296008 0.416152617 0.092321730 0.230822948
#> EstMonthConcept11 0.2225742542 0.223369810 0.086595098 0.048908501
#> EstMonthConcept12 0.0766681663 0.078415748 0.084882644 -0.091700980
#> EstYearConcept -0.0021152456 -0.002081239 0.003139907 -0.008022602
#> q97.5 pr_gr0
#> 17.510728856 0.8172
#> 18.136105017 0.8348
#> -0.009919573 0.0000
#> 0.006838140 0.6360
#> 0.336220510 0.4588
#> 0.263360542 0.2780
#> 0.290153392 0.3756
#> 0.335402888 1.0000
#> 0.039281343 0.0616
#> 0.084253984 0.1540
#> 0.008351850 0.0300
#> 0.078444107 0.1276
#> -0.024539907 0.0148
#> 0.119829195 0.3036
#> 0.331562633 0.9372
#> 0.490990030 0.9996
#> 0.589078559 1.0000
#> 0.388623796 0.9932
#> 0.241981946 0.8176
#> 0.004053558 0.2536
#>
#>
#> BDLIM fit on 1000 observations. Estimated residual standard deviation is 0.542 (0.519,0.568). WAIC is 1635.946.
#>
#> Use `plot(); for the summary.bdlim4 object to view estimated distributed lag functions. The `dlfun' object in the summary object contains estimates of the lag functions.
# graph the estimated distributed lag functions for each group
plot(sfit_sex)
# }