Learn R Programming

bglm (version 1.0)

bglm-package: Bayesian estimation in glm is implemented via Metropolis Hastings algorithm following the proposal kernel defined by Gamerman (1997).

Description

The package provides functions which perform Bayesian estimation via Metropolis-Hastings algorithm in generalized linear models.

Arguments

Details

Package:
bglm
Type:
Package
Version:
1.0
Date:
2014-10-29
License:
GPL-2
Depends:
mvtnorm

References

Gamerman, D. 1997. Sampling from the posterior distribution in generalized linear mixed models. Statistics and Computing, 7, 57-68.

Examples

Run this code
library(faraway)
data(babyfood)
summary(babyfood)
g2<- glm(cbind(disease, nondisease) ~ sex+food,family=binomial,babyfood)
#####use N > 8000 for more accurate results
bmen<-binommh(disease~ sex+food,babyfood$disease+babyfood$nondisease,N=1000,
data=babyfood)
data.frame(R.coef=coef(g2),R.sd=sqrt(diag(summary(g2)$cov.unscaled)),
           mh.mean=apply(bmen$chain,2,mean),mh.sd=apply(bmen$chain,2,sd))

Run the code above in your browser using DataLab