View source: R/flexreg_binom.R
flexreg_binom | R Documentation |
The function fits some flexible regression models for bounded discrete responses via a Bayesian approach to inference based on Hamiltonian Monte Carlo algorithm.
Available regression models are the flexible beta-binomial (type = "FBB"
, default), the beta-binomial (type = "BetaBin"
), and the binomial one (type = "Bin"
).
flexreg_binom(
formula,
data,
type = "FBB",
n,
link.mu = "logit",
prior.beta = "normal",
hyperparam.beta = 100,
hyper.theta.a = NULL,
hyper.theta.b = NULL,
link.theta = NULL,
prior.psi = NULL,
hyperparam.psi = NULL,
n.chain = 1,
n.iter = 5000,
warmup.perc = 0.5,
thin = 1,
verbose = TRUE,
...
)
formula |
an object of class " |
data |
an optional |
type |
a character specifying the type of regression model. Current options are |
n |
a character specifying the name of the variable containing the total number of trials. |
link.mu |
a character specifying the link function for the mean model. Currently, |
prior.beta |
a character specifying the prior distribution for the regression coefficients of the mean model, |
hyperparam.beta |
a positive numeric (vector of length 1) specifying the hyperprior scale parameter for the prior distribution of |
hyper.theta.a |
a numeric (vector of length 1) specifying the first shape parameter for the beta prior distribution of |
hyper.theta.b |
a numeric (vector of length 1) specifying the second shape parameter for the beta prior distribution of |
link.theta |
a character specifying the link function for the overdispersion model. Currently, |
prior.psi |
a character specifying the prior distribution for the regression coefficients of the overdispersion model, |
hyperparam.psi |
a positive numeric (vector of length 1) specifying the hyperprior scale parameter for the prior distribution of |
n.chain |
a positive integer specifying the number of Markov chains. The default is 1. |
n.iter |
a positive integer specifying the number of iterations for each chain (including warm-up). The default is 5000. |
warmup.perc |
the percentage of iterations per chain to discard. |
thin |
a positive integer specifying the period for saving samples. The default is 1. |
verbose |
a logical (with default |
... |
additional arguments from |
Let Y be a random variable whose distribution can be specified in the type
argument and \mu
be the mean of Y/n.
The flexreg_binom
function links the parameter \mu
to a linear predictor through a function g_1(\cdot)
specified in link.mu
:
g_1(\mu) = x^t \bold{\beta},
where \bold{\beta}
is the vector of regression coefficients for the mean model.
The prior distribution and the related hyperparameter of \bold{\beta}
can be specified in prior.beta
and hyperparam.beta
.
By default, link.theta="identity"
, meaning that the overdispersion parameter \theta
is assumed to be constant.
In that case, the prior distribution for \theta
is a beta with shape hyperparameters a
and b
that can be specified in hyper.theta.a
and hyper.theta.b
.
If not specified, a=b=1
, otherwise if only one hyperparameter is specified, the other is set equal.
It is possible to extend the model by linking \theta
to an additional (possibly overlapping) set of covariates through a proper link
function g_2(\cdot)
specified in the link.theta
argument:
g_2(\theta) = z^t \bold{\psi},
where \bold{\psi}
is the vector of regression coefficients for the overdispersion model.
The prior distribution and the related hyperparameter of \bold{\psi}
can be specified in prior.psi
and hyperparam.psi
.
In flexreg_binom
, the regression model for the mean and, where appropriate, for the overdispersion parameter can be specified in the
formula
argument with a formula of type y ~ x1 + x2 | z1 + z2
where covariates on the left of "|" are included in the regression model
for the mean, whereas covariates on the right of "|" are included in the regression model for the overdispersion.
If the second part is omitted, i.e., y ~ x1 + x2
, the overdispersion is assumed constant for each observation.
The flexreg_binom
function returns an object of class `flexreg`
, i.e. a list with the following elements:
call |
the function call. |
type |
the type of regression model. |
formula |
the original formula. |
link.mu |
a character specifing the link function in the mean model. |
link.theta |
a character specifing the link function in the overdispersion model. |
model |
an object of class |
response |
the response variable, assuming values in (0, 1). |
design.X |
the design matrix for the mean model. |
design.Z |
the design matrix for the overdispersion model (if defined). |
Ascari, R., Migliorati, S. (2021). A new regression model for overdispersed binomial data accounting for outliers and an excess of zeros. Statistics in Medicine, 40(17), 3895–3914. doi:10.1002/sim.9005
## Not run:
data(Bacteria)
fbb <- flexreg_binom(y ~ females, n = "n", data = Bacteria, type = "FBB")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.