Title: | Bayesian Zero-Inflated Bernoulli Regression Model |
---|---|
Description: | Fits a Bayesian zero-inflated Bernoulli regression model handling (potentially) different covariates for the zero-inflated and non zero-inflated parts. See Moriña D, Puig P, Navarro A. (2021) <doi:10.1186/s12874-021-01427-2>. |
Authors: | David Moriña Soler [aut, cre]
|
Maintainer: | David Moriña Soler <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.0.5 |
Built: | 2025-02-23 04:32:40 UTC |
Source: | https://github.com/cran/bayesZIB |
This package fits a Bayesian Bernoulli zero-inflated regression model handling different covariates for the zero-inflated and non zero-inflated parts.
Package: | bayesZIB |
Type: | Package |
Version: | 0.0.5 |
Date: | 2023-09-09 |
License: | GPL version 2 or newer |
LazyLoad: | yes |
The package implements a new Bayesian Bernoulli zero-inflated. This model is able to distinguish between two sources of zeroes (structural and non-structural) on the basis of a Bayesian framework, using rstan
. All the convergence and goodness-of-fit tests from rstan
are available.
David Moriña (Universitat de Barcelona), Pedro Puig (Universitat Autònoma de Barcelona) and Albert Navarro (Universitat Autònoma de Barcelona)
Mantainer: David Moriña Soler <[email protected]>
set.seed(1234) x <- rbinom(20, 1, 0.4) # Structural zeroes y <- rbinom(20, 1, 0.7*x) # Non-structural zeroes fit <- bayesZIB(y~1|1, priors=list(c(0,0.5), c(0.5,1))) print(fit$fit, pars=c("theta", "beta"))
set.seed(1234) x <- rbinom(20, 1, 0.4) # Structural zeroes y <- rbinom(20, 1, 0.7*x) # Non-structural zeroes fit <- bayesZIB(y~1|1, priors=list(c(0,0.5), c(0.5,1))) print(fit$fit, pars=c("theta", "beta"))
Fit Bernoulli zero-inflated regression models in a Bayesian framework.
bayesZIB(formula, data, priors=NULL, chains=3, iter=2000, adapt_delta=0.8, max_treedepth=10, verbose=FALSE, cores=getOption("mc.cores", 1L))
bayesZIB(formula, data, priors=NULL, chains=3, iter=2000, adapt_delta=0.8, max_treedepth=10, verbose=FALSE, cores=getOption("mc.cores", 1L))
formula |
symbolic description of the model, see details. |
data |
arguments controlling formula processing via |
priors |
|
chains |
a positive integer specifying the number of Markov chains. The default is 3. |
iter |
a positive integer specifying the number of iterations for each chain (including warmup). The default is 2000. |
adapt_delta |
for the No-U-Turn Sampler (NUTS), the variant of Hamiltonian Monte Carlo used used by |
max_treedepth |
maximum depth parameter. Positive integer, defaults to 10. When the maximum allowed tree depth is reached it indicates that NUTS is terminating prematurely to avoid excessively long execution time. |
verbose |
|
cores |
number of cores to use when executing the chains in parallel, which defaults to 1 but according to the Stan documentation it is recommended to set the |
Zero-inflated models are two-component mixture models combining a point mass at zero with a proper count distribution. Thus, there are two sources of zeros: zeros may come from both the point mass and from the Bernoulli component. For modeling the unobserved state (zero vs. Bernoulli), a binary model is used that captures the probability of zero inflation. in the simplest case only with an intercept but potentially containing regressors. For this zero-inflation model, a binomial model with an appropriate link function is used.
The formula can be used to specify both components of the model: If a formula of type y ~ x1 + x2
is supplied, then the same regressors are employed in both components. This is equivalent to y ~ x1 + x2 | x1 + x2
. Of course, a different set of regressors could be specified for the Bernoulli and zero-inflation component, e.g., y ~ x1 + x2 | z1 + z2 + z3
giving the logistic regression model y ~ x1 + x2
conditional on (|
) the zero-inflation model y ~ z1 + z2 + z3
. A simple inflation model where all zero counts have the same probability of belonging to the zero component can by specified by the formula y ~ x1 + x2 | 1
.
An object of class "bayesZIB", i.e., a list with components including
Call |
text string with the original call to the function |
x |
design matrix for the zero-inflated part |
z |
design matrix for the non zero-inflated part |
fit |
an object of S4 class |
David Moriña (Universitat de Barcelona), Pedro Puig (Universitat Autònoma de Barcelona) and Albert Navarro (Universitat Autònoma de Barcelona)
Mantainer: David Moriña Soler <[email protected]>
set.seed(1234) x <- rbinom(20, 1, 0.4) # Structural zeroes y <- rbinom(20, 1, 0.7*x) # Non-structural zeroes fit <- bayesZIB(y~1|1, priors=list(c(0, 0.5), c(0.5, 1))) print(fit$fit, pars=c("theta", "beta"))
set.seed(1234) x <- rbinom(20, 1, 0.4) # Structural zeroes y <- rbinom(20, 1, 0.7*x) # Non-structural zeroes fit <- bayesZIB(y~1|1, priors=list(c(0, 0.5), c(0.5, 1))) print(fit$fit, pars=c("theta", "beta"))