gblr {bsamGP}R Documentation

Generalized Bayesian Linear Models


This function fits a Bayesian generalized linear regression model.


gblr(formula, data = NULL, family, link, mcmc = list(), prior = list(),
marginal.likelihood = TRUE, algorithm = c('AM', 'KS'), verbose = FALSE)



an object of class “formula


an optional data frame.


a description of the error distribution to be used in the model: The family contains bernoulli (“bernoulli”), poisson (“poisson”), negative-binomial (“negative.binomial”), poisson-gamma mixture (“poisson.gamma”).


a description of the link function to be used in the model.


a list giving the MCMC parameters. The list includes the following integers (with default values in parentheses): nblow (10000) giving the number of MCMC in transition period, nskip (10) giving the thinning interval, smcmc (1000) giving the number of MCMC for analysis, and ndisp (1000) giving the number of saved draws to be displayed on screen (the function reports on the screen when every ndisp iterations have been carried out).


a list giving the prior information. The list includes the following parameters (default values specify the non-informative prior): beta_m0 and beta_v0 giving the hyperparameters of the multivariate normal distribution for parametric part including intercept, kappa_m0 and kappa_v0 giving the prior mean and variance of the gammal prior distribution for dispersion parameter (negative-binomial).


a logical variable indicating whether the log marginal likelihood is calculated. The methods of Gelfand and Dey (1994) is used.


a description of the algorithm to be used in the fitting of the logistic model: The algorithm contains the Gibbs sampler based on the Kolmogorov-Smirnov distribution (KS) and an adaptive Metropolis algorithm (AM).


a logical variable. If TRUE, the iteration number and the Metropolis acceptance rate are printed to the screen.


This generic function fits a Bayesian generalized linear regression models.

Let y_i and w_i be the response and the vector of parametric predictors, respectively. The model is as follows.

y_i | \mu_i \sim F(\mu_i),

g(\mu_i) = w_i^T\beta, ~ i=1,\ldots,n,

where g(\cdot) is a link function and F(\cdot) is a distribution of an exponential family.

For unknown coefficients, the following prior is assumed for \beta:

\beta \sim N(m_{0,\beta}, V_{0,\beta})

The prior for the dispersion parameter of negative-binomial regression is

\kappa \sim Ga(r_0, s_0)


An object of class blm representing the generalized Bayesian linear model fit. Generic functions such as print, fitted and plot have methods to show the results of the fit.

The MCMC samples of the parameters in the model are stored in the list mcmc.draws, the posterior samples of the fitted values are stored in the list fit.draws, and the MCMC samples for the log marginal likelihood are saved in the list loglik.draws. The output list also includes the following objects:


posterior estimates for all parameters in the model.


log marginal likelihood using Gelfand-Dey method.


the family object used.


the link object used.


the method object used in the logit model.


the matched call.


running time of Markov chain from system.time().


Albert, J. H. and Chib, S. (1993) Bayesian Analysis of Binary and Polychotomous Response Data. Journal of the American Statistical Association, 88, 669-679.

Holmes, C. C. and Held, L. (2006) Bayesian Auxiliary Variables Models for Binary and Multinomial Regression. Bayesian Analysis, 1, 145-168.

Gelfand, A. E. and Dey, K. K. (1994) Bayesian Model Choice: Asymptotics and Exact Calculations. Journal of the Royal Statistical Society. Series B - Statistical Methodology, 56, 501-514.

Roberts, G. O. and Rosenthal, J. S. (2009) Examples of Adaptive MCMC. Journal of Computational and Graphical Statistics, 18, 349-367.

See Also

blr, blq


# Poisson Regression Model #

# Simulate data

n <- 100
x <- runif(n)
y <- rpois(n, exp(0.5 + x*0.4))

# Fit the model with default priors and mcmc parameters
fout <- gblr(y ~ x, family = 'poisson', link = 'log')

# Summary
print(fout); summary(fout)

# Plot

# fitted values
fitf <- fitted(fout)

[Package bsamGP version 1.2.4 Index]