bwqs_r: Fitting Bayesian Weighted Quantile Sum regression models

View source: R/bwqs_main-revised.R

bwqs_rR Documentation

Fitting Bayesian Weighted Quantile Sum regression models

Description

Fits Random Bayesian Weighted Quantile Sum (BWQS) regressions for continuous outcomes. This model provides estimation for the mixture composition and overall effect of the mixture across different groups on the outcomes using bayesian framework.

Usage

bwqs_r(
  formula,
  mix_name,
  cluster_name,
  data,
  q,
  Dalp = NULL,
  chains = 1,
  iter = 1000,
  thin = 3,
  seed = 2019,
  start_value = NULL,
  c_int = c(0.025, 0.975),
  family = "gaussian"
)

Arguments

formula

Object of class formula specifying the relationship between the outcome and the covariates of the model not involved in the mixture variable. If the model has no covariates specify y ~ NULL.

mix_name

A character vector listing the variables contributing to a mixture effect.

cluster_name

A character string that specifiy which is the column of the dataset which contains the group number. Note that the cluster_name should be numeric, strings and factors are not allowed

data

The data.frame containing the variables (covariates and elements of the mixture) to be included in the model.

q

An integer to specify how mixture variables will be ranked, e.g. in quartiles (q = 4), deciles (q = 10), or percentiles (q = 100). If q = NULL then the values of the mixture variables are taken (these must be standardized or the domain must be the same).

Dalp

A vector containing the parameters of the Dirichlet distribution of the weights, the number of the elements of the vector has to be equal to the number of chemicals. If Dalp = NULL the domain is explored uniformly.

chains

An integer to specify the number of chain in Hamiltonian Monte Carlo algorithm. Default value chains = 1.

iter

An integer to specify the lenght of chain in Hamiltonian Monte Carlo algorithm. Default value iter = 10000.

thin

An integer to specify the thinning parameter in Hamiltonian Monte Carlo algorithm.

seed

An integer value to fix the seed. If seed = NULL the seed are randomly choosen.

start_value

A vector containing the initial value of the prior distribution, if it is equal to NULL random values are chosen.

c_int

A vector of two elements to specify the credible intervals for parameters, for 95% credible interval c_int = c(0.025,0.975) (default).

family

A string to specify the type of outcome. With the current implementation the possible values are only continuous - "gaussian" (default).

Details

The function bwqs uses the package rstan which allows the connection with STAN, a specific software, written in C++ for bayesian inference, for further information see https://mc-stan.org/.

Value

bwqs returns a list with two argument:

fit

An S4 object with all details of the Hamiltonian Monte Carlo, all the extractions from the posterior distribution and all values of the parameters

summary_fit

Table with the statistics of the parameters: mean, standard error of the mean, standard deviation, lower and upper values for the credible interval (with credible level specified by c_int), n_eff and Rhat. For further details see https://cran.r-project.org/web/packages/rstan/rstan.pdf

Author(s)

Nicolo Foppa Pedretti, Elena Colicino


ElenaColicino/bwqs documentation built on Feb. 26, 2023, 12:13 a.m.