Package 'RBE3'

Title: Estimation and Additional Tools for Quantile Generalized Beta Regression Model
Description: Provide estimation and data generation tools for the quantile generalized beta regression model. For details, see Bourguignon, Gallardo and Saulo <arXiv:2110.04428> The package also provides tools to perform covariates selection.
Authors: Diego Gallardo [aut, cre], Marcelo Bourguignon [aut]
Maintainer: Diego Gallardo <[email protected]>
License: GPL (>= 2)
Version: 1.1
Built: 2024-12-15 07:18:52 UTC
Source: CRAN

Help Index


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 τ\tau-quantiles of the distribution.

alpha, beta

shape parameters of the distribution

tau

corresponding quantile of the distribution (0<τ<10<\tau<1)

log, log.p

logical; if TRUE, probabilities pp are given as logp\log p.

lower.tail

logical; if TRUE (default), probabilities are P[Xx]P[X\leq x] otherwise, P[X>x]P[X>x].

Details

The probability density function for the generalized beta distribution is

f(y;λ,α,β)=λαyα1(1y)β1B(α,β)[1(1λ)y]α+β,0<y<1,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 α,β>0\alpha, \beta>0 and λ>0\lambda>0. We consider the reparameterization in terms of the τ\tau-quantile of the distribution, say 0<μ<10<\mu<1, taking

λ=(1μ)μzα,β(τ)[1zα,β(τ)],\lambda=\frac{(1-\mu)}{\mu}\frac{z_{\alpha,\beta}(\tau)}{[1-z_{\alpha,\beta}(\tau)]},

with zα,β(τ)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;λ,α,β)=Iλx/(1+λxx)(α,β),0<y<1,F(y;\lambda,\alpha,\beta)=I_{\lambda x/(1+\lambda x -x)}(\alpha, \beta), \quad 0<y<1,

where Ix(α,β)=Bx(α,β)/B(α,β)I_x(\alpha,\beta)=B_x(\alpha,\beta)/B(\alpha,\beta) is the incomplete beta funcion ratio, Bx(α,β)=0xwα1(1w)β1dwB_x(\alpha,\beta)=\int_0^x w^{\alpha-1}(1-w)^{\beta-1}dw is the incomplete beta function and B(α,β)=Γ(α)Γ(β)/Γ(α+β)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(τ;λ,α,β)=zα,β(τ)λ[1zα,β(τ)]+zα,β(τ),0<τ<1.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 X1Gamma(α,θ1)X_1 \sim \mbox{Gamma}(\alpha,\theta_1) and X2Gamma(β,θ2)X_2 \sim \mbox{Gamma}(\beta,\theta_2), then

X1X1+X2GB3(α,β,λ),\frac{X_1}{X_1+X_2}\sim GB3(\alpha,\beta,\lambda),

where λ=θ1/θ2.\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 (yy), and the matrices to model μ\mu, the τ\tau-quantile of distribution, and the shape parameters α\alpha and β\beta, labeled as Z1,Z2Z_1, Z_2 and Z3Z_3, respectively.

tau

the quantile of the distribution to be modelled (0<τ<10<\tau<1).

link.mu

link function to be used for μ\mu: logit (default), probit, loglog or cloglog.

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)

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)=1exp(exp(x)).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))

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 (yy), and the matrices to model μ\mu, the τ\tau-quantile of distribution, and the shape parameters α\alpha and β\beta, labeled as Z1,Z2Z_1, Z_2 and Z3Z_3, respectively.

tau

the quantile of the distribution to be modelled (0<τ<10<\tau<1).

link.mu

link function to be used for μ\mu: logit (default), probit, loglog or cloglog.

Details

Covariates are included as g1(μi(τ))=Z1iθ(τ)g_1(\mu_i(\tau))=\mathbf{Z}_{1i}^\top {\bm \theta}(\tau), g2(αi(τ))=Z2iν(τ)g_2(\alpha_i(\tau))=\mathbf{Z}_{2i}^\top {\bm \nu}(\tau) and g3(βi(τ))=Z3iη(τ)g_3(\beta_i(\tau))=\mathbf{Z}_{3i}^\top {\bm \eta}(\tau), where θ(τ)=(θ1(τ),,θr1(τ)){\bm \theta}(\tau)=(\theta_1(\tau),\ldots,\theta_{r_1}(\tau)), ν(τ)=(ν1(τ),,νr2(τ)){\bm \nu}(\tau)=(\nu_1(\tau),\ldots,\nu_{r_2}(\tau)) and η(τ)=(η1(τ),,ηr3(τ)){\bm \eta}(\tau)=(\eta_1(\tau),\ldots,\eta_{r_3}(\tau)), where r1,r2r_1, r_2 and r3r_3 are the dimensions of Z1,Z2Z_1, Z_2 and Z3Z_3, respectively. Initial values for θ(τ){\bm \theta}(\tau) are used as the coefficients for the linear regresion in logit(yi)\mbox{logit}(y_i) using the elements of Z1i\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)