gblr {bsamGP} | R Documentation |
Generalized Bayesian Linear Models
Description
This function fits a Bayesian generalized linear regression model.
Usage
gblr(formula, data = NULL, family, link, mcmc = list(), prior = list(),
marginal.likelihood = TRUE, algorithm = c('AM', 'KS'), verbose = FALSE)
Arguments
formula |
an object of class “ |
data |
an optional data frame. |
family |
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”). |
link |
a description of the link function to be used in the model. |
mcmc |
a list giving the MCMC parameters.
The list includes the following integers (with default values in parentheses):
|
prior |
a list giving the prior information. The list includes the following parameters
(default values specify the non-informative prior):
|
marginal.likelihood |
a logical variable indicating whether the log marginal likelihood is calculated. The methods of Gelfand and Dey (1994) is used. |
algorithm |
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 ( |
verbose |
a logical variable. If |
Details
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)
Value
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:
post.est |
posterior estimates for all parameters in the model. |
lmarg |
log marginal likelihood using Gelfand-Dey method. |
family |
the family object used. |
link |
the link object used. |
methods |
the method object used in the logit model. |
call |
the matched call. |
mcmctime |
running time of Markov chain from |
References
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
Examples
############################
# Poisson Regression Model #
############################
# Simulate data
set.seed(1)
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
plot(fout)
# fitted values
fitf <- fitted(fout)