## copy code at your own peril

**I** have come several times upon cases of scientists [I mean, real, recognised, publishing, senior scientists!] from other fields blindly copying MCMC code from a paper or website, and expecting the program to operate on their own problem… One illustration is from last week, when I read a X Validated question [from 2013] about an attempt of that kind, on a rather standard Normal posterior, but using an R code where the posterior function was not even defined. (I foolishly replied, despite having no expectation of a reply from the person asking the question.)

November 14, 2016 at 10:02 am

With reference to your X validated reply. Suppose we have a positive parameter, say s, and corresponding prior p(s). I guess it is kosher to propose a draw log(s)* from a Gaussian random walk, then take the exponential of said draw *before* this is submitted to the prior, so that we evaluate p(s*). This should be ok, without having to resort to the transformation Jacobian, right?

November 14, 2016 at 10:38 am

I know this is confusing to many but this is incorrect: you simulate a log-Normal in the end, not a Normal, and hence need the Jacobian!

November 14, 2016 at 5:30 am

[…] leave a comment for the author, please follow the link and comment on their blog: R – Xi’an’s Og.R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data […]

November 14, 2016 at 4:48 am

[…] article was first published on R – Xi'an's Og, and kindly contributed to […]