## Monday, 3 March 2014

### Issue with thinning in R2OpenBUGS vs R2jags

While preparing the practicals for our course at the University of Alberta, I've discovered something kind of interesting. I'm sure this is nothing new and actually people who normally use both OpenBUGS and JAGS have already figured this out.

But since I normally just use JAGS, it took me a bit to see this, so I thought I should post about it...

So: the issue is that when running a Bayesian model based on MCMC (eg Gibbs sampling), often it helps to improve convergence if the chains are "thinned" $-$ basically, instead of saving all the successive iterations of the process, only 1 on $s$ are stored and this generally reduces autocorrelation.

R2jags (which is the R library to interface R and JAGS) lets you select the total number of iterations you want to run, the number of "burn-in" iterations (which will be discarded) and the thinning factor. So a command
m <- jags(..., n.iter=20000, n.burnin=9500, n.thin=21, n.chains=2)
will generate two chains, each with 20000 iterations, discard the first 9500, which of course leaves 10500 iterations, and then save only one every 21 of these $-$ a total of 500 iterations per chain.

Conversely, R2OpenBUGS thinks in slightly different terms: as the help (which to be fair I've never bothered reading...) says "The thinning is implemented in the OpenBUGS update phase, so thinned samples are never stored, and they are not counted in n.burnin or n.iter. Setting n.thin=2, doubles the number of iterations OpenBUGS performs, but does not change n.iter or n.burnin".

So the command

m <- bugs(...,  n.iter=20000, n.burnin=9500, n.thin=21, n.chains=2)
will actually save 21000 iterations altogether (10500 per chain).

I realised this because the same relatively simple model was taking for ever when run using OpenBUGS and was really quick in JAGS $-$ no kidding!...

## Sunday, 2 March 2014

### Fun with flags

The Scotland independence referendum is approaching (relatively fast), and so are all sorts of related, very important issues, like what would the new UK flag be, if Scotland decide to leave?

The Guardian has taken a poll and apparently these two are the preferred options:

I like the comment that option no. 2 looks like the UK had annexed Italy, except that we would never tolerate such a hideous flag $-$ I would like to be insulted at the suggestion that Italians are so vain and only care about looks. But the flag really is ugly, I think...

## Saturday, 15 February 2014

### More statins for everybody!

The National Institute for Health and Care Excellence (NICE) says in draft guidance which now goes out to consultation that the threshold for GPs to prescribe statins to their patients should halved from the current value of a 20% risk of cardiovascular disease.
The current guideline has been in place for a few years now, but data from clinical practice seems to suggest that it is not strictly adhered to by GPs. For example, we've seen this in our Regression Discontinuity Design project (here's some preliminary analysis $-$ I believe we'll arxive a couple of papers on this shortly)
The selection of the value of 20% 10-year risk as cut-off has been kind of controversial for some clinicians, since it was driven (also) by cost-effectiveness considerations. But at the time that the previous guideline was set, the prices of statins was much higher (it has since decreased due to the introduction of generics).
If after consultation, the guideline will be confirmed, this will probably imply a huge increase in the number of prescriptions filled in for statins.

## Thursday, 13 February 2014

### Sure thing principle

I've been a bit busy lately $-$ teaching, plus other more or less interesting things (well: some really interesting, some much less so) $-$ and thus I haven't really written many posts recently. But I still try to check my own blog roll to see whether somebody has had a bit more time to write.

While I was just doing this, I glanced over the list of the top posts from this blog and, after a long time, the post about the US election is no longer the top one from my blog. It has (by now massively!) overtaken by this

Clearly, the title has quite a lot to do with the attraction of a post and evidently the double use of the word "porn" has really been a "sure-thing" (in the sense that the post has had over 1500 visits...) for this one.

But I'm not sure that Jimmie Savage would endorse the way I've used his sure-thing principle here, though...

## Saturday, 8 February 2014

### Mugged

Rasmus posted a couple of comments on my Christmas-present mug and apparently has started a collection of his own. But, then again, I think the mug galore has hit hard on many (eg here)... I'm going to have to get another one soon, then!

## Tuesday, 4 February 2014

### BMHE @ University of Alberta (reds vs blues)

When I was a kid, we use to play Subbuteo all the time (in fact, my brother and I had this exact box, featuring Sampdoria on the cover $-$ I thought I just mentioned this, since last night we won the Genova derby...).

You may think this is totally irrelevant to the title of this post, but you would be mistaken; first of all, Sampdoria do feature also in BMHE (pages 31-32, when explaining subjective probabilities and Bayes theorem).

Second, the main point of the post is that Richard Nixon, Chris Jackson and I will give a short course on Bayesian methods in health economics at the University of Alberta in Canada this coming March $-$ the actual dates are 12th-14th March, here is a flyer with some info
, in case you're interested...).

Richard and Chris have done a course on WinBUGS in Health Economic Evaluations (kind of similar, but not quite the same as we're now doing) in the past. So when we talked, we thought it would be nice to combine BMHE, their version of the course and the BUGS book (which Chris co-authored), which is basically what this new course is about.

Just like your classic Subbuteo box which would come with two teams, the reds and the blues!

## Thursday, 30 January 2014

### LaTeX can be arsey, but boy is it good?!

I have been using LaTeX since I wrote my BSc thesis (that was way back in the last century $-$ although I'm saying this just for dramatic effect, but I'm not THAT old!) and have loved it since. Of course, I do use WYSIWYG typesetting software now and then, but, of course, I try to avoid those as much as possible when doing serious work, involving maths formatting.

But, amazing as it is, LaTeX has sometimes its quirks and some cost (= time invested in looking the solution up) to solving them. In the past few days, I've had a couple of spats.

The first one has to do with the fact that I typically use the old latex $\Rightarrow$ dvi $\Rightarrow$ ps $\Rightarrow$ pdf routine to produce my documents/presentations (eg I use ps files for graphics and so I can use things like pstricks $-$ which I have now learned to use quite well, and so find relatively easy to deal with). But now I'm working on a joint presentation [I'll post about this thing later $-$ that's good stuff!] and my collaborators had already started working using the newer pdflatex routing, which prevents you from (straightforwardly) using ps files. So I had to struggle a bit to use all my pstricks-created graphs. In the end, I decided to save each as a separate .pdf file (using my old routine) and then import those in the beamer presentation.

The second one was slightly more complex (and in fact I had to ask for external help to solve this). I'm writing something where we want to show some "normal" text and then some sort of "example boxes", which we want to typeset in a different, sans serif font (hence the clever image above: sans serif, Arial, Helvetica, Switzerland... pretty font-nerdy stuff!). [This is even better stuff and again I'll post about it later]

The problem is that Helvetica is actually somewhat larger than other typefaces of the same nominal size. As a result, mixing Times and Helvetica within running text may look bad, which is exactly what was happening: the text in the example boxes (typeset in Helvetica) would look slightly bigger than the maths (eg equations), which was freaking me out. But this can be easily fixed by loading the package helvet with the option [scaled=(scale)], for instance: \usepackage[scaled=.92]{helvet}. As a result, the font family phv (Helvetica) will be scaled down to 92% of its "natural" size, which is suitable for use with Adobe Times.

## Wednesday, 15 January 2014

### BMHE & BCEA get a shout in published paper

Panagiotis Petrou has posted a link to a recent paper of his, which develops a cost-effectiveness analysis of a drug used as a second-line treatment of renal carcinoma. The analysis is based on a Bayesian Markov model.

But (from an incredibly self-involved point of view, I realise!), more importantly, they say on page 132:
"The model was synthesized in WinBUGS software package (Bayesian inference Using Gibbs Sampling) suitable for analyzing complex statistical models [18], and the R package Bayesian Cost Effectiveness Analysis [19] to do all the economic evaluation process after the Bayesian model has been run."
The R package is actually BCEA and it was also very nice to see that ref [19] is in fact BMHE, which they refer to as "An excellent book in health economics".

This is clearly the sound track to this post...