Learn R Programming

FlexReg (version 1.1)

flexreg: Flexible Regression Models for Proportions

Description

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"), and the beta one (type="Beta").

Usage

flexreg(
  formula,
  data,
  type = "FB",
  link.mu = "logit",
  prior.beta = "normal",
  hyperparam.beta = 100,
  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,
  ...
)

Value

The flexreg function returns an object of class `flexreg`, i.e. a list with the following elements:

call

the function call.

formula

the original formula.

link.mu

a character specifing the link function in the mean model.

link.phi

a character specifing the link function in the precision model.

model

an object of class `stanfit` containing the fitted model.

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 precision model (if defined).

Arguments

formula

an object of class `formula`: a symbolic description of the model to be fitted (of type y ~ x or y ~ x | z).

data

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.

type

a character specifying the type of regression model. Current options are the flexible beta regression model "FB" (default), the variance inflated beta "VIB", and the beta one "Beta".

link.mu

a character specifying the link function for the mean model (mu). Currently, "logit" (default), "probit", "cloglog", and "loglog" are supported.

prior.beta

a character specifying the prior distribution for the beta regression coefficients of the mean model. Currently, "normal" (default) and "cauchy" are supported.

hyperparam.beta

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".

link.phi

a character specifying the link function for the precision model (phi). Currently, "identity" (default), "log" and "sqrt" are supported.

prior.phi

a character specifying the prior distribution for precision parameter phi if link.phi = "identity". Currently, "gamma" (default) and "unif" are supported.

hyperparam.phi

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 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.

prior.psi

a character specifying the prior distribution for psi regression coefficients of the precision model (not supported if link.phi is "identity"). Currently, "normal" (default) and "cauchy" are supported.

hyperparam.psi

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".

n.iter

a positive integer specifying the number of iterations for each chain (including warmup). The default is 5000.

burnin.perc

the percentage of iterations per chain to discard.

n.chain

a positive integer specifying the number of Markov chains. The default is 1.

thin

a positive integer specifying the period for saving samples. The default is 1.

verbose

TRUE (default) or FALSE: flag indicating whether to print intermediate output.

...

additional arguments for rstan::sampling.

Details

Let \(\mu\) be the mean of a random variable Y whose distribution can be specified in the type argument. Then the flexreg function links the parameter \(\mu\) to a linear predictor through a function \(g(\cdot)\) specified in link.mu: $$g(\mu_i) = x_i^t \bold{\beta},$$ where \(\bold{\beta}\) is the vector of regression coefficients for the mean model. By default, the precision parameter \(\phi\) is assumed to be constant. 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) = z_i^t \bold{\psi},$$ where \(\bold{\psi}\) is the vector of regression coefficients for the precision model. 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 \sim x_1 + x_2 | z_1 + z_2\) 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 \sim x_1 + x_2\), the precision is assumed constant for each observation.

References

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

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., and Cribari-Neto, F. (2004). Beta Regression for Modeling Rates and Proportions. Journal of Applied Statistics, 31(7), 799--815. doi:10.1080/0266476042000214501

Examples

Run this code
if (FALSE) {
data("Reading")
FB <- flexreg(accuracy ~ iq, Reading, type="FB", n.iter=1000)
}

Run the code above in your browser using DataLab