# Which adaptive Metropolis Hastings algorithm is implemented in R package MHadaptive?

There are multiple versions of adaptive Metropolis Hastings algorithms. One is implemented in the function Metro_Hastings of R package MHadaptive, see here. The reference listed there, Spiegelhalter et al. (2002), unfortunately does not contain a description of any adaptive algorithm, as far as I can see. However, the Metro_Hastings algorithm performs very well in sampling from the posterior distribution of the model I consider, which is why I want to understand its details.

I have reverse engineered the algorithm a bit. Does anybody recognize this adaptive MH algorithm? This is what it does:

Let $q$ be the target density. Initialize $\theta_{0,i=0},\Sigma$.

For $n$ iterations $\{i = 1,...,n\}$ do:

1. Propose $\theta_1 \sim N(\theta_1|\theta_{0,i-1}, \Sigma)$.
2. Accept $\theta_1$ with probability $A=\min\{1,q(\theta_1)/q(\theta_{0,i})\}$. If accept, set $\theta_{0,i}:=\theta_1$. If reject: $\theta_{0,i}:=\theta_{0,i-1}$.

If $i=j$, where $j$ a vector defined so that any element of $j>x$ (default $x=100$), there is a spacing of $y$ iterations between the elements (default $y=20$), and no element $j>z$ (default $z=0.75n$), do:

1. Select $\tilde{\theta}=\{\theta_{0k},...,\theta_{0,i} \}$ (default $k=0.5i$).
2. Update: $\Sigma:=S(\tilde{\theta})$ where $S$ the maximum likelihood estimator of the variance covariance matrix of $\tilde{\theta}$ assuming multivariate normality.

Steps 1 and 2 are standard MH. Steps 3 and 4 are the adaptations which occur at steps $j$ and use the past $j-k$ iterations for updating $\Sigma$ to the covariance matrix of the past iterations.

• sorry for the silly question, but did you try to contact the package owner (first) and David Spiegelhalter (second)? The package owner left McGill a few years ago, so its' entirely possible the email address in the package isn't monitored anymore. However, with just a little Google-fu you can easily find out his current contacts (of course I'm not sharing here because I don't know if he would like it). If you can't get in touch with him, David Spiegelhalter is a really nice guy, and I think he would answer you if you sent him a mail. – DeltaIV Oct 30 '17 at 11:30
• @DeltaIV I did contact him but did not receive a reply. I have not considered writing to Spiegelhalter instead as he is merely quoted (incorrectly imho) and I am not sure whether he knows about the package at all. I contacted the author on the email address indicated in the package. It is still active apparently and therefore I have not considered finding him elsewhere. I will try this. – tomka Oct 30 '17 at 11:34
• I agree it's unlikely Spiegelhalter knows about the packages: that's why I suggested to contact the package owner first. However, he may know about the algorithm you describe (or maybe not, if he was incorrectly quoted as you suspect). If you manage to get an answer to your question let us know, I'm curious. – DeltaIV Oct 30 '17 at 12:40
• @DeltaIV I cannot identify an email address at his current institution. I will probably need to leave it at this unless you can point me to it. – tomka Oct 30 '17 at 13:55
• sure, let's discuss this in chat. I hope it's clear I want to help, I was just concerned about the privacy of the package owner. – DeltaIV Oct 30 '17 at 15:03