bkmrdlm: Bayesian kernel machine regression - distributed lag model

View source: R/bkmrdlm.R

bkmrdlmR Documentation

Bayesian kernel machine regression - distributed lag model

Description

This estimates the Bayesian kernel machine regression - distributed lag model (BKMR-DLM).

Usage

bkmrdlm(
  y,
  x,
  z,
  niter,
  nburn = round(niter/2),
  nthin = 1,
  prior_sigma = c(0.1, 0.1),
  prior_tau = 0.1,
  kappa = 1,
  basis.opts = list(type = "gam", pve = 0.9),
  gaussian = TRUE,
  polydegree = 2
)

Arguments

y

Vector of outcomes.

x

A list of matricies. Each Matric should be n by T with each row being the T-vector of exposures for one individuals. When only one exposure is used x can be a matrix instead of a list.

z

a matrix or design frame of covaiates and confounds. This can be ommited.

niter

Number of MCMC iterations including burnin.

nburn

The number of iterations to be discarded as burnin.

nthin

Thining, every nthin-th draw from the posterior will be saved.

prior_sigma

Vector of length 2 with the parameters for the gamma prior on sigma^-2

prior_tau

the prior variance on log(tau^2).

kappa

scale parameter, rho/kappa~chisq(1).

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; pve = the percent of variance explained by the PCs for method face; df = the df for ns method.

gaussian

Use a Gaussian kernel (TRUE, default) or a polynomial kernel (FALSE)

polydegree

Degree of polynomial when polynomial kernel is used. Only applies when gaussian=FALSE.

Value

An object of class 'bkmrdlm'.

Author(s)

Ander Wilson

Examples

 
library(regimes)
#simulate data from scenario A
dat <- simBKMRDLM(n = 200, scenario="A", sd=1, seed=1234)
# Estimate model
# This may take a few minutes
# Increase iterations for a real analysis
fit <- bkmrdlm(y=dat$y,
               x=dat$x,
               z=dat$z,
               niter=100,
               gaussian=FALSE,
               polydegree=2)
               
summary(fit)
plot(fit)

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