| Title: | Double Generalized Gamma Regression Models |
|---|---|
| Description: | Fits double generalized Gamma regression models from a Bayesian perspective, where both the mean and shape parameters are modeled simultaneously using flexible link functions. The methodology is based on Cepeda-Cuervo and Urdinola (2012) <doi:10.1080/03610918.2011.600500> and extended in Cepeda-Cuervo (2026), 'Double Generalized Linear Models: Likelihood and Bayesian Methods' (ISBN: 9781041169970). The package provides parameter estimation, model fitting, and model comparison tools, including Akaike Information Criterion (AIC) and Bayesian Information Criterion (BIC). |
| Authors: | Arturo Camargo-Lozano [aut, cre], Edilberto Cepeda-Cuervo [aut] |
| Maintainer: | Arturo Camargo-Lozano <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.1.1 |
| Built: | 2026-05-22 11:38:02 UTC |
| Source: | https://github.com/cran/Bayesiangammareg |
Function to do Bayesian Gamma Regression: Joint Mean and Shape Modeling
Bayesiangammareg(Y, X, Z, nsim, bpri, Bpri, gpri, Gpri, burn, jump, graph1, graph2, meanlink = "log")Bayesiangammareg(Y, X, Z, nsim, bpri, Bpri, gpri, Gpri, burn, jump, graph1, graph2, meanlink = "log")
Y |
object of class matrix, with the dependent variable. |
X |
object of class matrix, with the variables for modeling the mean. |
Z |
object of class matrix, with the variables for modeling the shape. |
nsim |
a number that indicate the number of iterations. |
bpri |
a vector with the initial values of beta. |
Bpri |
a matrix with the initial values of the variance of beta. |
gpri |
a vector with the initial values of gamma. |
Gpri |
a matrix with the initial values of the variance of gamma. |
burn |
a proportion that indicate the number of iterations to be burn at the beginning of the chain. |
jump |
a number that indicate the distance between samples of the autocorrelated the chain, to be excluded from the final chain. |
graph1 |
if it is TRUE present the graph of the chains without jump and burn. |
graph2 |
if it is TRUE present the graph of the chains with jump and burn. |
meanlink |
represent the link function, logarithm or identity. |
The Bayesian Gamma regression allows the joint modeling of the mean and the shape of a gamma distributed variable, using a Bayesian estimation algorithm proposed by Cepeda-Cuervo (2001).
object of class bayesiangammareg with:
coefficients |
object of class matrix with the estimated coefficients of beta and gamma. |
desv |
object of class matrix with the estimated desviations of beta and gamma. |
interv |
object of class matrix with the estimated confidence intervals of beta and gamma. |
fitted.values |
object of class matrix with the fitted values of y. |
residuals |
object of class matrix with the residuals of the regression. |
beta.mcmc |
object of class matrix with the complete chains for beta. |
gamma.mcmc |
object of class matrix with the complete chains for gamma. |
beta.mcmc.short |
object of class matrix with the chains for beta after the burned process. |
gamma.mcmc.short |
object of class matrix with the chains for gamma after the burned process. |
call |
Call. |
Arturo Camargo Lozano [email protected], Edilberto Cepeda-Cuervo [email protected]
1. Cepeda-Cuervo E. (2001) Modelagem da variabilidade em modelos lineares generalizados. Ph.D. tesis. Instituto de Matematicas. Universidade Federal do Rio do Janeiro. 2. Cepeda-Cuervo E. and Gamerman D. (2005). Bayesian Methodology for modeling parameters in the two-parameter exponential family. Estadistica 57, 93 105. 3. Cepeda-Cuervo E. (2026). Double Generalized Linear Models: Likelihood and Bayesian Methods. 1st Edition. ISBN: 9781041169970.
X1 <- rep(1,100) X2 <- runif(100,0,30) X3 <- runif(100,0,20) X4 <- runif(100,10,20) mui <- 15 + 3*X2 + 2*X3 alphai <- exp(3 + 0.15*X2 + 0.15*X4) Y <- rgamma(100,shape=alphai,scale=mui/alphai) X <- cbind(X1,X2,X3) Z <- cbind(X1,X2,X4) bpri <- c(1,1,1) Bpri <- diag(10^(3),nrow=ncol(X),ncol=ncol(X)) gpri <- c(0,0,0) Gpri <- diag(10^(3),nrow=ncol(Z),ncol=ncol(Z)) burn <- 0 jump <- 1 nsim <- 500 graph1=FALSE graph2=FALSE Bayesiangammareg(Y,X,Z,nsim,bpri,Bpri,gpri,Gpri,burn,jump,graph1,graph2,"ide")X1 <- rep(1,100) X2 <- runif(100,0,30) X3 <- runif(100,0,20) X4 <- runif(100,10,20) mui <- 15 + 3*X2 + 2*X3 alphai <- exp(3 + 0.15*X2 + 0.15*X4) Y <- rgamma(100,shape=alphai,scale=mui/alphai) X <- cbind(X1,X2,X3) Z <- cbind(X1,X2,X4) bpri <- c(1,1,1) Bpri <- diag(10^(3),nrow=ncol(X),ncol=ncol(X)) gpri <- c(0,0,0) Gpri <- diag(10^(3),nrow=ncol(Z),ncol=ncol(Z)) burn <- 0 jump <- 1 nsim <- 500 graph1=FALSE graph2=FALSE Bayesiangammareg(Y,X,Z,nsim,bpri,Bpri,gpri,Gpri,burn,jump,graph1,graph2,"ide")
Performs the comparison criterias for the Bayesian Gamma regression
criteria(X,Z, model)criteria(X,Z, model)
X |
Matrix of explanatory variables for the mean model. |
Z |
Matrix of explanatory variables for the precision model. |
model |
Object returned by |
This function calculate the residuals of a Bayesian Gamma regression.
deviance |
the deviance criteria |
AIC |
the AIC criteria |
BIC |
the BIC criteria |
Arturo Camargo Lozano [email protected], Edilberto Cepeda-Cuervo [email protected]
1. Cepeda-Cuervo E. (2001) Modelagem da variabilidade em modelos lineares generalizados. Ph.D. tesis. Instituto de Matematicas. Universidade Federal do Rio do Janeiro. 2. Cepeda-Cuervo E. and Gamerman D. (2005). Bayesian Methodology for modeling parameters in the two-parameter exponential family. Estadistica 57, 93 105. 3. Espinheira, P. L., Ferrari, S. L., and Cribari-Neto, F. On beta regression residuals. Journal of Applied Statistics 4. Cepeda-Cuervo E., Corrales, M., Cifuentes, M. V., and Zarate, H. (2016). On Gamma Regression Residuals.
Function to do Bayesian Gamma Regression link Identity: Joint Mean and Shape modeling with Identity link for Mean.
GammaIdentity(Y, X, Z, nsim, bpri, Bpri, gpri, Gpri, burn, jump, graph1, graph2)GammaIdentity(Y, X, Z, nsim, bpri, Bpri, gpri, Gpri, burn, jump, graph1, graph2)
Y |
Object of class matrix, with the dependent variable. |
X |
Object of class matrix, with the variables for modeling the mean. |
Z |
Object of class matrix, with the variables for modeling the shape. |
nsim |
a number that indicate the number of iterations. |
bpri |
a vector with the initial values of beta. |
Bpri |
a matrix with the initial values of the variance of beta. |
gpri |
a vector with the initial values of gamma. |
Gpri |
a matrix with the initial values of the variance of gamma. |
burn |
a proportion that indicate the number of iterations to be burn at the beginning of the chain. |
jump |
a number that indicate the distance between samples of the autocorrelated the chain, to be excluded from the final chain. |
graph1 |
if it is TRUE present the graph of the chains without jump and burn. |
graph2 |
if it is TRUE present the graph of the chains with jump and burn. |
object of class bayesiangammareg with the following:
Bestimado |
object of class matrix with the estimated coefficients of beta |
Gammaest |
object of class matrix with the estimated coefficients of gamma |
X |
object of class matrix, with the variables for modelling the mean |
Z |
object of class matrix, with the variables for modelling the precision |
DesvBeta |
object of class matrix with the estimated desviations of beta |
DesvGamma |
object of class matrix with the estimated desviations of gamma |
B |
object of class matrix with the B values |
G |
object of class matrix with the G values |
yestimado |
object of class matrix with the fitted values of y |
residuals |
object of class matrix with the residuals of the regression |
phi |
object of class matrix with the precision terms of the regression |
variance |
object of class matrix with the variance terms of the regression |
beta.mcmc |
object of class matrix with the complete chains for beta |
gamma.mcmc |
object of class matrix with the complete chains for gamma |
beta.mcmc.auto |
object of class matrix with the chains for beta after the burned process |
gamma.mcmc.auto |
object of class matrix with the chains for gamma after the burned process |
Arturo Camargo Lozano [email protected], Edilberto Cepeda-Cuervo [email protected]
1. Cepeda-Cuervo E. (2001) Modelagem da variabilidade em modelos lineares generalizados. Ph.D. tesis. Instituto de Matematicas. Universidade Federal do Rio do Janeiro. 2. Cepeda-Cuervo E. and Gamerman D. (2005). Bayesian Methodology for modeling parameters in the two-parameter exponential family. Estadistica 57, 93 105. 3. Cepeda Cuervo E. and Gamerman D. (2001). Bayesian Modeling of Variance Heterogeneity in Normal Regression Models. Brazilian Journal of Probability and Statistics. 14, 207-221. 4. Cepeda-Cuervo E. (2026). Double Generalized Linear Models: Likelihood and Bayesian Methods. 1st Edition. ISBN: 9781041169970.
Function to do Bayesian Gamma Regression: Joint Mean and Shape modeling with Log link for Mean.
GammaLog(Y, X, Z, nsim, bpri, Bpri, gpri, Gpri, burn, jump, graph1, graph2)GammaLog(Y, X, Z, nsim, bpri, Bpri, gpri, Gpri, burn, jump, graph1, graph2)
Y |
object of class matrix, with the dependent variable. |
X |
object of class matrix, with the variables for modelling the mean. |
Z |
object of class matrix, with the variables for modelling the shape. |
nsim |
a number that indicate the number of iterations. |
bpri |
a vector with the initial values of beta. |
Bpri |
a matrix with the initial values of the variance of beta. |
gpri |
a vector with the initial values of gamma. |
Gpri |
a matrix with the initial values of the variance of gamma. |
burn |
a proportion that indicate the number of iterations to be burn at the beginning of the chain. |
jump |
a number that indicate the distance between samples of the autocorrelated the chain, to be excluded from the final chain. |
graph1 |
if it is TRUE present the graph of the chains without jump and burn. |
graph2 |
if it is TRUE present the graph of the chains with jump and burn. |
object of class bayesiangammareg with the following:
Bestimado |
object of class matrix with the estimated coefficients of beta |
Gammaest |
object of class matrix with the estimated coefficients of gamma |
X |
object of class matrix, with the variables for modelling the mean |
Z |
object of class matrix, with the variables for modelling the precision |
DesvBeta |
object of class matrix with the estimated desviations of beta |
DesvGamma |
object of class matrix with the estimated desviations of gamma |
B |
object of class matrix with the B values |
G |
object of class matrix with the G values |
yestimado |
object of class matrix with the fitted values of y |
residuals |
object of class matrix with the residuals of the regression |
phi |
object of class matrix with the precision terms of the regression |
variance |
object of class matrix with the variance terms of the regression |
beta.mcmc |
object of class matrix with the complete chains for beta |
gamma.mcmc |
object of class matrix with the complete chains for gamma |
beta.mcmc.auto |
object of class matrix with the chains for beta after the burned process |
gamma.mcmc.auto |
object of class matrix with the chains for gamma after the burned process |
Arturo Camargo-Lozano [email protected], Edilberto Cepeda-Cuervo [email protected]
1. Cepeda-Cuervo E. (2001) Modelagem da variabilidade em modelos lineares generalizados. Ph.D. tesis. Instituto de Matematicas. Universidade Federal do Rio do Janeiro. 2. Cepeda Cuervo E. and Gamerman D. (2005). Bayesian Methodology for modeling parameters in the two parameter exponential family. Estadistica 57, 93 105. 3. Cepeda Cuervo E. and Gamerman D. (2001). Bayesian Modeling of Variance Heterogeneity in Normal Regression Models. Brazilian Journal of Probability and Statistics. 14, 207-221. 4. Cepeda-Cuervo E. (2026). Double Generalized Linear Models: Likelihood and Bayesian Methods. 1st Edition. ISBN: 9781041169970.
X1 <- rep(1,100) X2 <- runif(100,0,30) X3 <- runif(100,0,20) X4 <- runif(100,10,20) mui<-exp(1 + 0.14*X2 + 0.05*X3) alphai<-exp(0.1 + 0.01*X2 + 0.03*X4) Y <- rgamma(100,shape=alphai,scale=mui/alphai) X <- cbind(X1,X2,X3) Z <- cbind(X1,X2,X4) bpri <- c(1,1,1) Bpri <- diag(10^(3),nrow=ncol(X),ncol=ncol(X)) gpri <- c(0,0,0) Gpri <- diag(10^(3),nrow=ncol(Z),ncol=ncol(Z)) burn <- 0 jump <- 1 nsim <- 500 graph1=FALSE graph2=FALSE Bayesiangammareg(Y,X,Z,nsim,bpri,Bpri,gpri,Gpri,burn,jump,graph1,graph2,"log")X1 <- rep(1,100) X2 <- runif(100,0,30) X3 <- runif(100,0,20) X4 <- runif(100,10,20) mui<-exp(1 + 0.14*X2 + 0.05*X3) alphai<-exp(0.1 + 0.01*X2 + 0.03*X4) Y <- rgamma(100,shape=alphai,scale=mui/alphai) X <- cbind(X1,X2,X3) Z <- cbind(X1,X2,X4) bpri <- c(1,1,1) Bpri <- diag(10^(3),nrow=ncol(X),ncol=ncol(X)) gpri <- c(0,0,0) Gpri <- diag(10^(3),nrow=ncol(Z),ncol=ncol(Z)) burn <- 0 jump <- 1 nsim <- 500 graph1=FALSE graph2=FALSE Bayesiangammareg(Y,X,Z,nsim,bpri,Bpri,gpri,Gpri,burn,jump,graph1,graph2,"log")
This function calculates the Gamma regression residuals
gammaresiduals(Y, X, model)gammaresiduals(Y, X, model)
Y |
object of class matrix, with the dependent variable. |
X |
object of class matrix, with the independent variable. |
model |
object of class Bayesiangammareg. |
rabs |
Pearson absolute residuals |
rp |
Pearson residuals |
rd |
deviance residuals |
rast |
Asteric residuals |
Arturo Camargo-Lozano [email protected], Edilberto Cepeda-Cuervo [email protected]
1. Cepeda-Cuervo E. (2001) Modelagem da variabilidade em modelos lineares generalizados. Ph.D. tesis. Instituto de Matematicas. Universidade Federal do Rio do Janeiro. 2. Cepeda-Cuervo E. and Gamerman D. (2005). Bayesian Methodology for modeling parameters in the two-parameter exponential family. Estadistica 57, 93 105. 3. Cepeda Cuervo E., Corrales, M., Cifuentes, M. V., and Zarate, H. (2016). On Gamma Regression Residuals.
Print the Bayesian Gamma Regression for Joint modeling of Mean and Shape
## S3 method for class 'Bayesiangammareg' print(x,...)## S3 method for class 'Bayesiangammareg' print(x,...)
x |
object of class Bayesiangammareg |
... |
not used. |
print the Bayesian Gamma regression
Arturo Camargo Lozano [email protected], Edilberto Cepeda Cuervo [email protected]
1. Cepeda-Cuervo E. (2001) Modelagem da variabilidade em modelos lineares generalizados. Ph.D. tesis. Instituto de Matematicas. Universidade Federal do Rio do Janeiro.
Print the summary Bayesian Gamma regression for Joint modeling of Mean and Shape parameters
## S3 method for class 'summary.Bayesiangammareg' print(x, ...)## S3 method for class 'summary.Bayesiangammareg' print(x, ...)
x |
object of class Bayesiangammareg |
... |
not used. |
Print the summary Bayesian Gamma Regression for Joint modeling of Mean and Shape parameters
Arturo Camargo [email protected], Edilberto Cepeda-Cuervo [email protected]
1. Cepeda-Cuervo E. (2001) Modelagem da variabilidade em modelos lineares generalizados. Ph.D. tesis. Instituto de Matematicas. Universidade Federal do Rio do Janeiro.
Summarized the Bayesian Gamma Regression for joint modeling of mean and variance
## S3 method for class 'Bayesiangammareg' summary(object, ...)## S3 method for class 'Bayesiangammareg' summary(object, ...)
object |
an object of class Bayesiangammareg |
... |
not used. |
call |
Call |
coefficients |
Coefficients |
deviance |
deviance |
AIC |
AIC |
BIC |
BIC |
Brayan Arturo Camargo [email protected], Edilberto Cepeda Cuervo [email protected]
1. Cepeda-Cuervo E. (2001) Modelagem da variabilidade em modelos lineares generalizados. Ph.D. tesis. Instituto de Matematicas. Universidade Federal do Rio do Janeiro. 2. Cepeda-Cuervo E. and Gamerman D. (2005). Bayesian Methodology for modeling parameters in the two-parameter exponential family. Estadistica 57, 93 105. 3. Cepeda Cuervo E. and Gamerman D. (2001). Bayesian Modeling of Variance Heterogeneity in Normal Regression Models. Brazilian Journal of Probability and Statistics. 14, 207-221.