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 |
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.
Stan Development Team (2020). RStan: the R interface to Stan. R package version 2.21.2. https://mc-stan.org
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.
bws(iter, y, X, Z = NULL, alpha = NULL, family = "gaussian", ...)
bws(iter, y, X, Z = NULL, alpha = NULL, family = "gaussian", ...)
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 |
An object of class stanfit
returned by rstan::sampling
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)
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)