Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for an R package (or a combination of packages) that would allow me to perform MCMC estimation of a GMM model, with a user-specified moments function.

I've looked at the CRAN Bayesian task-view, but I can't seem to find what I'm looking for, packages being either too general (eg. mcmc) or too specific (MCMCpack)... Ideally I would like to be able to implement Stochastic GMM or to use package R-INLA to do iterative nested Laplace approximation, again with a user-specified moments function.

Any help greatly appreciated!

share|improve this question
up vote 5 down vote accepted

I've implemented Bayesian GMM estimators in STAN before and it is pretty straight-forward. The way STAN works is that one simply defines how to calculate he log-likelihood and then a very efficient sampler (NUTS) based on Hybrid Monte Carlo is created automatically, and for the GMM likelihood one just creates the $U_i$ and $\Sigma$ by hand (which will depend on $\beta$) and increment the log-likelihood by doing something like

lp__ <- lp__ - 0.5 * U[i]' * Sigma * U[i]

(make sure to double check that this is correct though). It may even be possible to trick JAGS/BUGS into doing it with the "zeros trick" but STAN seems like a fantastic option for this (although I suppose it may also depend on the amount of data you have). I'm taking for granted that your pseudo-likelihood defines a valid posterior, of course!

EDIT: should definitely be a Sigma inverse rather than Sigma in the formula above!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.