The function fits some flexible regression models for bounded continuous responses (e.g., proportions and rates) via a Bayesian approach to inference based on Hamiltonian Monte Carlo algorithm.
Available regression models are the flexible beta regression model (type = "FB", default), the variance inflated beta (type = "VIB"), the beta (type = "Beta"), as well as their augmented versions.
flexreg(
formula,
zero.formula = NULL,
one.formula = NULL,
data,
type = "FB",
link.mu = "logit",
prior.beta = "normal",
hyperparam.beta = NULL,
prior.omega0 = "normal",
hyperparam.omega0 = NULL,
prior.omega1 = "normal",
hyperparam.omega1 = NULL,
link.phi = NULL,
prior.phi = NULL,
hyperparam.phi = NULL,
prior.psi = NULL,
hyperparam.psi = NULL,
n.chain = 1,
n.iter = 5000,
warmup.perc = 0.5,
thin = 1,
verbose = TRUE,
...
)The flexreg function returns an object of class `flexreg`, i.e. a list with the following elements:
callthe function call.
typethe type of regression model.
formulathe overall formula.
auga character specifing the absence of the augmentation ("No") or the presence of augmentation in zero ("0"), one ("1"), or both ("01").
link.mua character specifing the link function in the mean model.
link.phia character specifing the link function in the precision model.
modelan object of class `stanfit` containing the fitted model.
responsethe response variable, assuming values in (0, 1).
design.Xthe design matrix for the mean model.
design.Zthe design matrix for the precision model (if defined).
design.X0the design matrix for the augmented model in zero (if defined).
design.X1the design matrix for the augmented model in one (if defined).
an object of class "formula": a symbolic description of the mean model (y ~ x) or the mean and precision models (y ~ x | z) to be fitted (see Details).
an object of class "formula": a symbolic description of the zero augmented model to be fitted (see Details).
an object of class "formula": a symbolic description of the one augmented model to be fitted (see Details).
an optional data.frame, list, or object that is coercible to a data.frame through as.data.frame containing the variables in the model. If not found in data, the variables in formula, zero.formula, and one.formula are taken from the environment from which the function flexreg is called.
a character specifying the type of regression model. Current options are "FB" (flexible beta, default), "VIB" (variance inflated beta), and "Beta".
a character specifying the link function for the mean model (mu). Currently, "logit" (default), "probit", "cloglog", and "loglog" are supported.
a character specifying the prior distribution for the regression coefficients of the mean model, beta. Currently, "normal" (default) and "cauchy" are supported.
a positive numeric (vector of length 1) specifying the hyperprior scale parameter for the prior distribution of beta regression coefficients. The default is 100 if the prior is "normal", 2.5 if it is "cauchy".
a character specifying the prior distribution for the regression coefficients of the augmented model in zero, omega0. Currently, "normal" (default) and "cauchy" are supported.
a positive numeric (vector of length 1) specifying the hyperprior scale parameter for the prior distribution of omega0 regression coefficients. The default is 100 if the prior is "normal", 2.5 if it is "cauchy".
a character specifying the prior distribution for the regression coefficients of the augmented model in one, omega1. Currently, "normal" (default) and "cauchy" are supported.
a positive numeric (vector of length 1) specifying the hyperprior scale parameter for the prior distribution of omega1 regression coefficients. The default is 100 if the prior is "normal", 2.5 if it is "cauchy".
a character specifying the link function for the precision model (phi). Currently, "identity" (default), "log", and "sqrt" are supported.
a character specifying the prior distribution for precision parameter phi if
link.phi = "identity". Currently, "gamma" (default) and "unif" are supported.
a positive numeric (vector of length 1) specifying the hyperprior parameter for the prior distribution of phi. If the prior is "gamma", the value identifies the gamma's shape and rate parameters (the default is 0.001). If the prior is "uniform" the hyperparameter must be specified to define the upper limit of the support of phi.
a character specifying the prior distribution for the regression coefficients of the precision model psi (not supported if link.phi = "identity"). Currently, "normal" (default) and "cauchy" are supported.
a positive numeric (vector of length 1) specifying the hyperprior scale parameter for the prior distribution of psi regression coefficients. The default is 100 if the prior is "normal", 2.5 if it is "cauchy".
a positive integer specifying the number of Markov chains. The default is 1.
a positive integer specifying the number of iterations for each chain (including warm-up). The default is 5000.
the percentage of iterations per chain to discard.
a positive integer specifying the period for saving samples. The default is 1.
a logical (with default TRUE) indicating whether to print intermediate output.
additional arguments from sampling.
Let Y be a continuous bounded random variable whose distribution can be specified in the type argument and \(\mu\) be the mean of Y.
The flexreg function links the parameter \(\mu\) to a linear predictor through a function \(g_1(\cdot)\) specified in link.mu:
$$g_1(\mu) = \bold{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, respectively.
By default, the precision parameter \(\phi\) is assumed to be constant.
The prior distribution and the related hyperparameter of \(\phi\) can be specified in prior.phi and hyperparam.phi.
It is possible to extend the model by linking \(\phi\) to an additional (possibly overlapping) set of covariates through a proper link
function \(g_2(\cdot)\) specified in the link.phi argument:
$$g_2(\phi) = \bold{z}^t \bold{\psi},$$ where \(\bold{\psi}\) is the vector of regression coefficients for the precision model.
The prior distribution and the related hyperparameter of \(\bold{\psi}\) can be specified in prior.psi and hyperparam.psi.
In the function flexreg, the regression model for the mean and, where appropriate, for the precision 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 precision.
If the second part is omitted, i.e., y ~ x1 + x2, the precision is assumed constant for each observation.
In presence of zero values in the response, one has to link the parameter \(q_0\), i.e., the probability of augmentation in zero, to an additional (possibly overlapping) set of covariates through a logit link function:
$$g_3(q_{0}) = \bold{x}_{0}^t \bold{\omega_0},$$ where \(\bold{\omega_0}\) is the vector of regression coefficients for the augmented model in zero.
The prior distribution and the related hyperparameter of \(\bold{\omega_0}\) can be specified in prior.omega0 and hyperparam.omega0.
In presence of one values in the response, one has to link the parameter \(q_1\), i.e., the probability of augmentation in one, to an additional (possibly overlapping) set of covariates through a logit link function:
$$g_4(q_{1}) = \bold{x}_{1}^t \bold{\omega_1},$$ where \(\bold{\omega_1}\) is the vector of regression coefficients for the augmented model in one.
The prior distribution and the related hyperparameter of \(\bold{\omega_1}\) can be specified in prior.omega1 and hyperparam.omega1.
If both the augmented models in zero and one are specified, the link function is a bivariate logit.
In flexreg function, the augmented models in zero and/or one can be specified in the
zero.formula and/or one.formula arguments with a formula of type ~ x.
Left hand side in zero.formula and one.formula can be omitted; if specified, they have to be the same as left hand side in formula.
Di Brisco, A. M., Migliorati, S. (2020). A new mixed-effects mixture model for constrained longitudinal data. Statistics in Medicine, 39(2), 129--145. doi:10.1002/sim.8406
Di Brisco, A. M., Migliorati, S., Ongaro, A. (2020). Robustness against outliers: A new variance inflated regression model for proportions. Statistical Modelling, 20(3), 274--309. doi:10.1177/1471082X18821213
Ferrari, S.L.P., Cribari-Neto, F. (2004). Beta Regression for Modeling Rates and Proportions. Journal of Applied Statistics, 31(7), 799--815. doi:10.1080/0266476042000214501
Migliorati, S., Di Brisco, A. M., Ongaro, A. (2018) A New Regression Model for Bounded Responses. Bayesian Analysis, 13(3), 845--872. doi:10.1214/17-BA1079
if (FALSE) {
data("Reading")
FB <- flexreg(accuracy.adj ~ iq, data = Reading, type="FB")
# Regression model with one augmentation:
AFB1 <- flexreg(accuracy ~ dyslexia | iq + dyslexia + iq:dyslexia,
one.formula = ~ iq + dyslexia, data = Reading, type="FB")
}
Run the code above in your browser using DataLab