A set of functions related to the reparameterized gamma regression model based on different measures of central tendency: mean, median, mode, geometric mean or harmonic mean.
fit.RGA(formula = formula(data), sigma.formula=~1, data, param="AM")
dRGA(x, mu=1, sigma=1, param="AM", log=FALSE)
pRGA(q, mu=1, sigma=1, param="AM", lower.tail = TRUE, log.p = FALSE)
qRGA(p, mu=1, sigma=1, param="AM", lower.tail = TRUE, log.p = FALSE)
rRGA(n, mu=1, sigma=1, param="AM")an object of class "rregm" is returned. The object returned for this functions is a list containing the following components:
A matrix containing the estimates and standard errors.
the log-likelihood function evaluated at the corresponding estimators.
the Akaike information criterion.
the Bayesian information criterion.
values for tau1 and tau2, depending on the considered parameterization.
Pearson's residuals.
modified Pearson's residuals.
quantile residuals.
logical. If convergence was attained.
GA (the gamma distribution).
The specified parameterization.
design matrix for mu.
design matrix for sigma.
vector of parameter values
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specification are given under ‘Details’.
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which lm is called.
a formula object for fitting a model to the sigma parameter, as in the formula above, e.g. sigma.formula=~x1+x2.
parameterization used for the model. "AM" for mean, "MD" for median, "MO" for mode, "GM" for geometric mean, and "HM" for harmonic mean.
vector of quantiles
vector of probabilities
number of observations. If \(\mbox{length}(n) > 1\), the length is taken to be the number required.
logical; if TRUE, probabilities p are given as log(p).
logical; if TRUE, probabilities are \(P(X \leq x)\) otherwise, \(P(X>x)\).
Diego Gallardo and Marcelo Bourguignon.
The parameterization for the reparameterized beta distribution is given by $$ f(x; \mu, \sigma) = \frac{(\delta/\mu)^{\delta + \tau}}{\Gamma(\delta + \tau)}x^{\delta+\tau-1}\textrm{e}^{-\delta x/\mu}, \quad y > 0, $$ where \(\delta=\delta(\sigma)=(\sqrt{\sigma(\sigma+4)}+\sigma)/2\), \(0 < \mu < 1\), \(\sigma > 0\) and \(\tau\) is a constant. The following cases are highlighted:
- param="AM": \(\tau=0\) and \(\mu\) represents the mean of the distribution.
- param="GM": \(\tau=1/2\) and \(\mu\) represents the geometric mean of the distribution.
- param="MD": \(\tau=1/3\) and \(\mu\) represents the median of the distribution.
- param="MO" or ="HM": \(\tau=1\) and \(\mu\) represents the mode or the harmonic mean of the distribution.
Suppose the central tendency and the concentration parameter of \(Y_i\) satisfies the following functional relations $$ \log(\mu_i) = \mathbf{x}^\top_i\bm{\xi} \quad \textrm{and} \quad \log(\sigma_i) = \eta_{2i} = \mathbf{z}^\top_i\bm{\nu}, $$ where \(\bm{\xi} = (\xi_1, \ldots, \xi_p)^\top\) and \(\bm{\nu} = (\nu_1, \ldots, \nu_q)^\top\) are vectors of unknown regression coefficients which are assumed to be functionally independent, \(\bm{\xi} \in \mathbb{R}^p\) and \(\bm{\nu} \in \mathbb{R}^q\), with \(p + q < n\), and \(\mathbf{x}_i = (x_{i1}, \ldots, x_{ip})^\top\) and \(\mathbf{z}_i = (z_{i1}, \ldots, z_{iq})^\top\) are observations on \(p\) and \(q\) known regressors, for \(i = 1, \ldots, n\). Furthermore, we assume that the covariate matrices \(\mathbf{X} = (\mathbf{x}_1, \ldots, \mathbf{x}_n)^\top\) and \(\mathbf{Z} = (\mathbf{z}_1, \ldots, \mathbf{z}_n)^\top\) have rank \(p\) and \(q\), respectively.
For this model, the Pearson's residuals are given by $$ r_i=\frac{y_i-m_i}{s_i}, \quad i=1,\ldots,n, $$ where $$ m_i=\mu_i\left(1+\frac{\tau}{\xi(\sigma_i,\tau)}\right) \quad \mbox{and} \quad s_i=\frac{\mu}{\xi(\sigma_i,\tau)}\sqrt{\tau+\xi(\sigma_i,\tau)}, $$ where \(\xi(\sigma_i,\tau)=(\sqrt{\sigma_i(\sigma_i+4\tau)}+\sigma_i)/2\). On the other hand, the modified Pearson's residuals are given by $$ r_i^*=\frac{\log(y_i)-m_i^*}{s_i^*}, \quad i=1,\ldots,n, $$ where $$ m_i^*=\psi(\tau+\xi(\sigma_i,\tau))+\log \mu_i-\log \xi(\sigma_i,\tau)) \quad \mbox{and} \quad s_i^*=\sqrt{\psi'(\tau+\xi(\sigma_i,\tau))}, $$ with \(\psi(\cdot)\) and \(\psi'(\cdot)\) denoting the digamma and trigamma functions, respectively. Finally, the quantile residuals are given by $$ r_i^q=\Phi^{-1}\left(\frac{\gamma(\tau+\xi(\sigma_i,\tau),\xi(\sigma_i,\tau) y_i/ \mu_i}{\Gamma(\tau+\xi(\sigma_i,\tau))}\right), \quad i=1,\ldots,n, $$ where \(\Phi^{-1}(\cdot)\) denotes the inverse of the cumulative distribution function for the standard normal model and \(\gamma(a,z) = \int_{0}^{z}t^{a-1}\textrm{e}^{-t}\textrm{d}t\) is the lower incomplete gamma function and \(\Gamma(\alpha) = \int_{0}^{\infty}\omega^{\alpha-1}\textrm{e}^{-\omega}\textrm{d} \omega\) is the gamma function. dRGA gives the density, pRGA gives the distribution function, qRGA gives the quantile function, and rRGA generates random deviates from the beta distribution with the specified parameterization.
Bourguignon, M., Gallardo, D.I. (2025) A general and unified class of gamma regression models. Chemometrics and Intelligent Laboratory Systems, 261, 105382.
set.seed(2100)
n=100; x1=rnorm(max(n)) ##drawing covariates, the same for mu and sigma
mu=exp(0.5-0.4*x1); sigma=exp(-0.1+0.05*x1)
y=rRGA(n, mu, sigma, param="MD") ## model parameterized in the median
data=list(y=y, x1=x1)
aux.RGA=fit.RGA(y~x1, sigma.formula=~x1, data=data, param="MD")
summary(aux.RGA)
qqnorm(res(aux.RGA, type="mod.pearson"))
Run the code above in your browser using DataLab