This function fits a Bayesian generalized linear regression model.
gblr(y, w, n, family, link, mcmc = list(), prior = list(), marginal.likelihood = TRUE)
a vector or matrix of response values: The multinomial model uses the categorical indicator responses (matrix).
a vector or matrix giving covariates of dimension n
times ndimw
excluding intercept for a parametric component.
an integer vector containing the number of trials for binomial data.
a description of the error distribution to be used in the model: The families 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.
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()
.
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)$$
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.
# NOT RUN {
############################
# 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 = y, w = x, family = 'poisson', link = 'log')
# Summary
print(fout)
# Plot
plot(fout)
# fitted values
fitf <- itted(fout)
# }
Run the code above in your browser using DataLab