A rather long posting this week for which I apologise. I would have split this posting over two weeks but I am about to go on my summer holiday and I wanted to avoid a long gap between the two halves. I have spent the last few weeks discussing how Stan can be called from Stata and now the […]

# Bayesian Analysis with Stata

## Stan with Stata, Part VI: More about HMC

Last time I discussed the HMC (Hamiltonian Monte Carlo or Hybrid Monte Carlo) algorithm that forms the basis of Stan and I likened the algorithm to kicking a marble around in a bucket. The multi-dimensional shape of the bucket is defined by minus the log-posterior and the marble represents the current value of the estimator. We give […]

## Stan with Stata, Part V: Kicking a marble around in a bucket

In the last few postings I have described how the Bayesian analysis program, Stan, can be called from within Stata. Before we can go any further we have to understand how Stan works, which is to say we need to understand the basics of Hamiltonian Monte Carlo, as this is Stan’s way of sampling from the posterior. I’ll start […]

## wbslist update

Thanks to Ole-Petter Moe Hansen for pointing out a small bug in wbslist. The version released with my book would sometimes lose track of the format when listing a set of matrices. I managed to track down the source of the error. It seems that I had two counters, one tracking the matrices and the other […]

## Stan with Stata, Part IV: Automation

Last time I presented a very basic do file for running Stan from within Stata and although the program worked, there were places where we had to find work-arounds that meant that the process was not fully automatic. In particular, we had to write the script manually, we used Stata’s shell command to run the compiled code and we had to copy […]

## Stan with Stata, Part III: A first attempt

This week I am going to present a program that runs Stan from within Stata, but in this version, there will be a minimum of automation. Next time, I will modify the wbs programs, designed for running WinBUGS, so that they will also work with Stan and at that stage the process will be simpler to use but less transparent. We […]

## Stan with Stata, Part II: installing and testing Stan

This week I want to install Stan on a Windows computer and check the installation independently of Stata, so that next week we can move on to controlling Stan from within Stata. Stan has several flavours, for instance, there is an R package that controls Stan, but for us the important version is the stand alone […]

## Stan with Stata (Part 1): A plan of action

In the book ‘Bayesian Analysis with Stata’ I described how we can fit a Bayesian model using Stata to control WinBUGS and OpenBUGS and last year, in this blog, I showed how the same approach could be used to control another BUGS-like program called JAGS. So, currently, we have a choice of three programs for […]

## MCMCglmm in Stata (Part 2)

Last time, I showed how we can write R code for fitting a Bayesian Generalized Linear Mixed Model and insert it into a Stata do file, so that the computation is performed by the R program, MCMCglmm, while the results are available in Stata. The drawback of that approach is that it requires the user […]

## Software Updates

Over time my programs for Bayesian analysis with Stata evolve and, I hope, improve. Periodically, I update my webpage at https://www2.le.ac.uk/Members/trj to reflect these changes. There are three recent updates that might be of interest. Philip Besuner contacted me to report an error in the logdensity.ado file when calculating the log-density for the lognormal distribution. […]

## Recent Comments