The function fits some flexible regression models for continuous bounded 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"), and 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.iter = 5000,
burnin.perc = 0.5,
n.chain = 1,
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.
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 model (y ~ x | z) to be fitted.
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 base::as.data.frame containing the variables in the model. If not found in data, the variables in 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 standard deviation parameter for the prior distribution of beta regression coefficients. A value of 100 is suggested if the prior is "normal", 2.5 if "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 standard deviation parameter for the prior distribution of omega0 regression coefficients. A value of 100 is suggested if the prior is "normal", 2.5 if "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 standard deviation parameter for the prior distribution of omega1 regression coefficients. A value of 100 is suggested if the prior is "normal", 2.5 if "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 (a value of 0.001 is suggested). 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 standaerd deviation parameter for the prior distribution of psi regression coefficients. A value of 100 is suggested if the prior is "normal", 2.5 if "cauchy".
a positive integer specifying the number of iterations for each chain (including warmup). The default is 5000.
the percentage of iterations per chain to discard.
a positive integer specifying the number of Markov chains. The default is 1.
a positive integer specifying the period for saving samples. The default is 1.
TRUE (default) or FALSE: flag indicating whether to print intermediate output.
additional arguments for rstan::sampling.
Let \(\mu\) be the mean of a random variable Y, whose distribution can be specified in the type argument.
The flexreg function links the parameter \(\mu\) to a linear predictor through a function \(g(\cdot)\) specified in link.mu:
$$g(\mu_i) = \bold{x}_i^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, 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 \(q(\cdot)\) specified in the link.phi argument:
$$q(\phi_i) = \bold{z}_i^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 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 and 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 responses, one has to link the parameter \(q_0\) to an additional (possibly overlapping) set of covariates through a logit link function:
$$g_0(q_{0i}) = \bold{x}_{0i}^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 responses, one has to link the parameter \(q_1\) to an additional (possibly overlapping) set of covariates through a logit link function:
$$g_1(q_{1i}) = \bold{x}_{1i}^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, the augmented models in zero and/or one can be specified in the
zero.formula and/or one.formula argument 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