## wrong algebra for slice sampler

Once more, and thrice alas!, I became aware of a typo in our “Use R!” book through a question on X validated from a reader unable to reproduce the slice of a basic 2D slice sampler for a logistic regression with coefficients (a,b). Indeed, our slice reads as the incorrect set (missing the i=1,…,n)

$\left\{ (a,b): y_i(a+bx_i) > \log \frac{u_i}{1-u_i} \right\}$

when it should have been

$\bigcap_{i=1} \left\{ (a,b)\,:\ (-1)^{y_i}(a+bx_i) > \log\frac{u_i}{1-u_i} \right\}$

which is the version I found in my LaTeX file. So I do not know what happened (unless I corrected the LaTeX file at a later date and cannot remember it, but the latest chance on the file reads October 2011…). Fortunately, the resulting slices in a and b and the following R code remain correct. Unfortunately, both French and Japanese translations reproduce the mistake…

### 5 Responses to “wrong algebra for slice sampler”

1. Isn’t it odd how sometimes mistakes in maths presentation when translated to code still result in the same behavior? At a Wikipedia page on Metropolis-Hastings I thought the presentation of the algorithm was so opaque there was a danger of it being wrong at a corner case. However, after working through it, it gives a correct algorithm, although I recommended that perhaps it should be changed to make it more transparently correct and in the spirit of the Hastings amendment.

• Is the current version the new one?

• It isn’t what I proposed, and the original can be seen in my “Talk” comment there. It has been changed.

2. […] article was first published on R – Xi'an's Og, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here) […]