Package 'bws'

Title: Bayesian Weighted Sums
Description: An interface to the Bayesian Weighted Sums model implemented in 'RStan'. It estimates the summed effect of multiple, often moderately to highly correlated, continuous predictors. Its applications can be found in analysis of exposure mixtures. The model was proposed by Hamra, Maclehose, Croen, Kauffman, and Newschaffer (2021) <doi:10.3390/ijerph18041373>. This implementation includes an extension to model binary outcome.
Authors: Phuc H. Nguyen [aut, cre]
Maintainer: Phuc H. Nguyen <[email protected]>
License: GPL (>= 2)
Version: 0.1.0
Built: 2024-12-25 07:00:25 UTC
Source: CRAN

Help Index


The 'bws' package.

Description

An interface to the Bayesian Weighted Sums model implemented in RStan. It estimates the summed effect of multiple, often moderately to highly correlated, continuous predictors. Its applications can be found in analysis of exposure mixtures. The model was proposed by Hamra, Maclehose, Croen, Kauffman, and Newschaffer (2021) This implementation include an extension to model binary outcome.

References

Stan Development Team (2020). RStan: the R interface to Stan. R package version 2.21.2. https://mc-stan.org


Bayesian Weighted Sums

Description

Fits a Bayesian Weighted Sums as described in Bayesian Weighted Sums: A Flexible Approach to Estimate Summed Mixture Effects. Ghassan B. Hamra 1, Richard F. MacLehose, Lisa Croen, Elizabeth M. Kauffman and Craig Newschaffer. 2021. International Journal of Environmental Research and Public Health. An extension for binary outcome is included.

Usage

bws(iter, y, X, Z = NULL, alpha = NULL, family = "gaussian", ...)

Arguments

iter

Number of Hamiltonian Monte Carlo iterations

y

Am n-vector of outcomes

X

An n-by-p matrix of mixtures to be weighted-summed

Z

Default NULL. A matrix of confounders whose linear effects are estimated

alpha

A p-vector of hyperparameters for the Dirichlet prior on the weights. Default to be a vector of 1's.

family

A string "gaussian" for linear regression and "binomial" for logistic regression

...

Additional arguments for rstan::sampling

Value

An object of class stanfit returned by rstan::sampling

Examples

N <- 50; P <- 3; K <- 2
X <- matrix(rnorm(N*P), N, P)
Z <- matrix(rnorm(N*K), N, K)  # confounders
theta0 <- 0.5; theta1 <- 1.25
w <- c(0.3, 0.2, 0.5)
beta <- c(0.5, 0.3)
y <- theta0 + theta1*(X%*%w) + Z%*%beta + rnorm(N)
fit <- bws::bws(iter = 2000, y = y, X = X, Z = Z, family = "gaussian",
                chains = 2, cores = 2, refresh = 0)