Type: | Package |
Title: | Estimation and Additional Tools for Quantile Generalized Beta Regression Model |
Version: | 1.1 |
Date: | 2023-12-20 |
Author: | Diego Gallardo [aut, cre], Marcelo Bourguignon [aut] |
Maintainer: | Diego Gallardo <dgallardo@ubiobio.cl> |
Description: | Provide estimation and data generation tools for the quantile generalized beta regression model. For details, see Bourguignon, Gallardo and Saulo <doi:10.48550/arXiv.2110.04428> The package also provides tools to perform covariates selection. |
Depends: | R (≥ 4.0.0), stats |
Imports: | pracma, gtools |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
NeedsCompilation: | no |
Packaged: | 2023-12-19 23:53:36 UTC; Diego |
Repository: | CRAN |
Date/Publication: | 2023-12-20 09:40:15 UTC |
The Generalized Beta Distribution
Description
Density, distribution function, quantile function and random generation for the generalized beta distribution.
Usage
dBE3(x, mu = 0.5, alpha = 1, beta = 1, tau = 0.5, log = FALSE)
pBE3(q, mu = 0.5, alpha = 1, beta = 1, tau = 0.5, lower.tail = TRUE, log.p = FALSE)
qBE3(p, mu = 0.5, alpha = 1, beta = 1, tau = 0.5)
rBE3(n, mu = 0.5, alpha = 1, beta = 1, tau = 0.5)
Arguments
x , q |
vector of quantiles. |
p |
vector of probabilities. |
n |
number of observations. |
mu |
vector of |
alpha , beta |
shape parameters of the distribution |
tau |
corresponding quantile of the distribution ( |
log , log.p |
logical; if TRUE, probabilities |
lower.tail |
logical; if TRUE (default), probabilities are |
Details
The probability density function for the generalized beta distribution is
f(y;\lambda,\alpha,\beta)=\frac{\lambda^\alpha y^{\alpha-1}(1-y)^{\beta-1}}{B(\alpha, \beta)[1-(1-\lambda)y]^{\alpha+\beta}}, \quad 0<y<1,
where \alpha, \beta>0
and \lambda>0
.
We consider the reparameterization in terms of the \tau
-quantile of the distribution, say 0<\mu<1
, taking
\lambda=\frac{(1-\mu)}{\mu}\frac{z_{\alpha,\beta}(\tau)}{[1-z_{\alpha,\beta}(\tau)]},
with z_{\alpha,\beta}(\tau)
denoting the \tau
-quantile of the usual beta distribution with shape parameters \alpha
and \beta
.
The cumulative distribution function is given by
F(y;\lambda,\alpha,\beta)=I_{\lambda x/(1+\lambda x -x)}(\alpha, \beta), \quad 0<y<1,
where I_x(\alpha,\beta)=B_x(\alpha,\beta)/B(\alpha,\beta)
is the incomplete beta funcion ratio, B_x(\alpha,\beta)=\int_0^x w^{\alpha-1}(1-w)^{\beta-1}dw
is the incomplete beta function and B(\alpha,\beta)=\Gamma(\alpha)\Gamma(\beta)/\Gamma(\alpha+\beta)
is the ordinary beta function.
The quantile of the distribution can be represented as
q(\tau;\lambda,\alpha,\beta)=\frac{z_{\alpha,\beta}(\tau)}{\lambda[1-z_{\alpha,\beta}(\tau)]+z_{\alpha,\beta}(\tau)}, \quad 0<\tau<1.
Random generation can be performed using the stochastic representation of the model. If X_1 \sim \mbox{Gamma}(\alpha,\theta_1)
and
X_2 \sim \mbox{Gamma}(\beta,\theta_2)
, then
\frac{X_1}{X_1+X_2}\sim GB3(\alpha,\beta,\lambda),
where \lambda=\theta_1/\theta_2.
Value
dBE3 gives the density, pBE3 gives the distribution function, qBE3 gives the quantile function, and rBE3 generates random deviates.
The length of the result is determined by n for rBE3, and is the maximum of the lengths of the numerical arguments for the other functions.
The numerical arguments other than n are recycled to the length of the result. Only the first elements of the logical arguments are used.
Author(s)
Diego Gallardo and Marcelo Bourguignon
References
Libby, D. L. and Novick, M. R. (1982). Multivariate generalized beta-distributions with applications to utility assessment. Journal of Educational Statistics, 7.
Examples
rBE3(20, mu=0.5, alpha=2, beta=1)
dBE3(c(0.4,0.7), mu=0.5, alpha=2, beta=1)
pBE3(c(0.4,0.7), mu=0.5, alpha=2, beta=1)
backward stepwise regression for RBE3 model based on the AIC criterion or significance.
Description
BE3.backward.crit implements the covariates selection based on backward and the Akaike's information criteria (AIC). BE3.backward.sign implements the covariates selection based on backward and significance of the covariates.
Usage
BE3.backward.crit(data, tau = 0.5, link.mu = "logit")
Arguments
data |
a list containing the response vector ( |
tau |
the quantile of the distribution to be modelled ( |
link.mu |
link function to be used for |
Value
A list containg the covariates to be included for modelling \mu
, \alpha
and \beta
, respectively.
Author(s)
Diego Gallardo and Marcelo Bourguignon.
Examples
##Simulating two covariates
set.seed(2100)
x1<-rnorm(200); x2<-rbinom(200, size=1, prob=0.5)
##Desing matrices: Z1 includes x1 and x2,
##Z2 includes only x1 and Z3 includes only x2
Z1=model.matrix(~x1+x2);Z2=model.matrix(~x1);Z3=model.matrix(~x2)
##Fixing parameters
theta=c(1, 0.2, -0.5); nu=c(0.5,-0.2); eta=c(-0.5, 0.3); tau=0.4
mu=plogis(Z1%*%theta); alpha=exp(Z2%*%nu); beta=exp(Z3%*%eta)
y=rBE3(200, mu, alpha, beta, tau=tau)
data=list(y=y, Z1=Z1, Z2=Z2, Z3=Z3)
BE3.backward.crit(data, tau = tau)
Perform the parameter estimation for the Generalized beta distribution
Description
ML.BE3 computes the maximum likelihood estimates based on the maximum likelihood method.
Usage
ML.BE3(data, tau = 0.5, link.mu = "logit")
Arguments
data |
a list containing the response vector ( |
tau |
the quantile of the distribution to be modelled ( |
link.mu |
link function to be used for |
Details
Covariates are included as g_1(\mu_i(\tau))=\mathbf{Z}_{1i}^\top {\bm \theta}(\tau)
, g_2(\alpha_i(\tau))=\mathbf{Z}_{2i}^\top {\bm \nu}(\tau)
and g_3(\beta_i(\tau))=\mathbf{Z}_{3i}^\top {\bm \eta}(\tau)
, where {\bm \theta}(\tau)=(\theta_1(\tau),\ldots,\theta_{r_1}(\tau))
,
{\bm \nu}(\tau)=(\nu_1(\tau),\ldots,\nu_{r_2}(\tau))
and {\bm \eta}(\tau)=(\eta_1(\tau),\ldots,\eta_{r_3}(\tau))
, where r_1, r_2
and r_3
are the dimensions of Z_1, Z_2
and Z_3
, respectively.
Initial values for {\bm \theta}(\tau)
are used as the coefficients for the linear regresion in \mbox{logit}(y_i)
using the elements of
\mathbf{Z}_{1i}^\top
as regressors. Initial values for the other coefficients are considered as zeros.
Value
a list containing the following elements
estimate |
A matrix with the estimates |
logLik |
The maximum likelihood values attached by the estimates parameters |
Author(s)
Diego Gallardo and Marcelo Bourguignon.
References
Bourguignon, M., Gallardo, D.I., Saulo, H. (2023) A parametric quantile beta regression for modeling case fatality rates of COVID-19. Submitted.
Examples
##Simulating two covariates
set.seed(2100)
x1<-rnorm(200); x2<-rbinom(200, size=1, prob=0.5)
##Desing matrices: Z1 includes x1 and x2,
##Z2 includes only x1 and Z3 includes only x2
Z1=model.matrix(~x1+x2);Z2=model.matrix(~x1);Z3=model.matrix(~x2)
##Fixing parameters
theta=c(1, 0.2, -0.5); nu=c(0.5,-0.2); eta=c(-0.5, 0.3); tau=0.4
mu=plogis(Z1%*%theta); alpha=exp(Z2%*%nu); beta=exp(Z3%*%eta)
y=rBE3(200, mu, alpha, beta, tau=tau)
data=list(y=y, Z1=Z1, Z2=Z2, Z3=Z3)
ML.BE3(data, tau=tau)
The Gumbel2 distribution
Description
Density, distribution function and quantile function for the Gumbel2 distribution.
Usage
dgumbel2(x, log=FALSE)
pgumbel2(q)
qgumbel2(p)
Arguments
x , q |
Vector of quantiles. |
p |
Vector of probabilities. |
log |
logical; if TRUE, probabilities p are given as log(p). |
Details
The cumulative distribution function for the Gumbel2 distribution is given by F(x)=1-exp(-exp(x)).
Value
dgumbel2 gives the density, pgumbel2 gives the distribution function and qgumbel2 gives the quantile function.
The length of the result is determined by the maximum of the lengths of the numerical arguments.
Author(s)
Diego Gallardo and Marcelo Bourguignon.
Examples
dgumbel2(c(4,10))
pgumbel2(c(4,10))
qgumbel2(c(0.1, 0.5))