views:

912

answers:

6

Hierarchical Bayes models are commonly used in Marketing, Political Science, and Econometrics. Yet, the only package I know of is bayesm, which is really a companion to a book (Bayesian Statistics and Marketing, by Rossi, et al.) Am I missing something? Is there a software package for R or Python doing the job out there, and/or a worked-out example in the associated language?

+8  A: 

There's OpenBUGS and R helper packages. Check out Gelman's site for his book, which has most of the relevant links:

On the Python side, I only know of PyMC:

EDIT: Added a link to the appropriate appendix from Gelman's book, available online, for an example using R and BUGS.

ars
+4  A: 

Here are four books on hierarchical modeling and bayesian analysis written with R code throughout the books.

Hierarchical Modeling and Analysis for Spatial Data (Monographs on Statistics and Applied Probability) (Hardcover) http://www.amazon.com/gp/product/158488410X

Data Analysis Using Regression and Multilevel/Hierarchical Models (Paperback) http://www.amazon.com/Analysis-Regression-Multilevel-Hierarchical-Models/dp/052168689X/ref=pd_sim_b_1

Bayesian Computation with R (Use R) (Paperback) http://www.amazon.com/Bayesian-Computation-R-Use/dp/0387922970/ref=pd_bxgy_b_img_c

Hierarchical Modelling for the Environmental Sciences: Statistical Methods and Applications (Oxford Biology) (Paperback) (I'm assuming this one has R code as both authors use R extensively)

I know some python books dabble in multivariate analysis (Collective Intelligence, for example) but I haven't seen any that really delve into bayesian or hierarchical modeling.

kpierce8
+2  A: 

There are a few hierarchical models in MCMCpack for R, which to my knowledge is the fastest sampler for many common model types. (I wrote the [hierarchical item response][2] model in it.)

[RJAGS][3] does what its name sounds like. Code up a jags-flavored .bug model, provide data in R, and call Jags from R.

mjm
A: 

The lme4 package, which estimates hierarchical models using frequentist methods, has a function called mcmcsamp that allows you to sample from the posterior distribution of the model using MCMC. This currently works only for linear models, quite unfortunately.

Eduardo Leoni
A: 

in python, try PyMC. There is an example of multilevel modeling with it here: http://groups.google.com/group/pymc/browse%5Fthread/thread/c6ce37a80edf7f85/1bfd9138c8db891d

Abraham Flaxman
+1  A: 

I apply hierarchical Bayes models in R in combination with JAGS (Linux) or sometimes WinBUGS (Windows, or Wine). Check out the book of Andrew Gelman, as referred to above.

johan