bdlim: Bayesian distributed lag interaction models

View source: R/bdlim.R

bdlimR Documentation

Bayesian distributed lag interaction models

Description

This estimates the Bayesian distributed lag interaction model (BDLIM).

Usage

bdlim(
  Y,
  X,
  Z,
  G,
  inter.model = "all",
  family = gaussian,
  niter = 1000,
  nburn = round(niter/2),
  nthin = 1,
  basis.opts,
  prior,
  seed
)

Arguments

Y

Vector of outcomes.

X

Matrix of exposures over an evenly spaced grid. There should be no missing exposures.

Z

Design matrix of covariates. The design matrix for G will be added automatically, including an intercept.

G

Vector indicating group membership. This should be a factor.

inter.model

Indicator of how G enters the model. If 'bw' both the betas and weight functions will vary between groups. If 'b' then only the betas will vary between groups. If 'w' then only the wieght function will vary by group. If "n" then neither beta or the wieght function will vary by group. If a vector of any combination of the four choices is provided then those models will be run and compared. The option 'all' runs all four models and compares them.

family

A description of the error distribution and link function to be used in the model. Currently, Gaussian and binomial are supported.

niter

Number of MCMC iterations including burnin.

nburn

Number of MCMC iterations to be discarded as burnin.

nthin

Number of draws taken to obtain one sample.

basis.opts

List with the entries: type = the type of basis used, either 'face' (default) or "ns" or "bs" for splines or "gam" for presmoothing the exposure with a gam following defaults from mgcv; knots = the number of knots used for method face; knot_locations = the location of internal knots for the spline basis; pve = the percent of variance explained by the PCs for method face; df = the df for ns method.

prior

List with the entries: sigma = a numeric 2-vector with the shape and rate parameters for the prior in the error precision (1/sigma^2); betavar = the prior variance for beta; and gamma = the prior variance for the covarites. The priors on beta and gamma are iid normal mean zero.

seed

A seed to be set before each model is run.

Value

An object of class 'bdlim'.

Author(s)

Ander Wilson


AnderWilson/regimes documentation built on Aug. 5, 2023, 8:30 a.m.