## Tuesday, 29 October 2013

### Fellow me

Last summer I have applied for a NIHR Research Methods fellowship. Earlier this week the results have come out and they have liked my proposal, which is of course great news.

The idea of this project is to critically evaluate the stepped wedge design (SWD) in clinical trials. This is a relatively new design, effectively an extension of cross-over design, in which a given intervention is rolled out in clusters that unilaterally switch treatment at different time points. The first time point usually coincides with a baseline measurement where all the clusters are assigned to the control arm. Subsequently, clusters begin to receive the active treatment, but, unlike in a standard cross-over trial, once the intervention is given, it is not removed. The time at which the intervention is started is randomly determined.

This on the one hand typically increases the duration of the study (because several time points are usually needed to reach a fixed level of statistical power); however, on the other hand, the SWD has shown the potential to be more efficient than standard cluster randomised (CR) designs.

But of course, much as for standard cross-over designs, the actual gains depend on specific settings and parameters specifications (eg in terms of the the number of clusters and time points; the clusters size; the level of correlation between measurements in the same cluster and across time). So we'll try and investigate these issues and see under which conditions the SWD works better than other strategies. As part of the proposed outputs of this research, we have indicated that we'll produce a toolbox (in R) to perform sample size calculations and guide the analysis of the actual data.

## Monday, 21 October 2013

### The Big Bayes theorem theory

While we were eating a forkful of what was supposed to be a frittata, but turned out to be very fluffy mushroom scrambled eggs earlier, we were half watching an episode of The Big Bang Theory

Long story short, my eye was caught by Sheldon explaining how he is estimating his life expectancy, clearly using Bayes's theorem (although he didn't refer to it in his speech to Leonard).

Good stuff, Shelly!

This morning there has been some frenzy on the UK media (eg here or here) after the publication of a pamphlet by David Willetts, a junior minister for University and Science under the infamous coalition government.

The minister's point is that, comparatively to what used to be case in the past (notably in 1963 before changes in policy that led to increase in the number of university students), the proportion of time spent teaching by university lecturers is decreased in favour of the time that they spend otherwise.

Now, of course, this is not necessarily bad or good per se, but the minister says in his paper that "Looking back we will wonder how the higher education system was ever allowed to become so lopsided away from teaching.

Well, one easy answer is of course to point out that apart from the huge increase in the number of students $-$ it would actually be interesting to have reasonable figures on the time spent teaching per-student, in comparison with pre-1963! $-$ the government(s) have switched the emphasis to research by decreasing the amount of funding available for universities and rewarding private initiative to obtain research money, eg from industry, or simply making the process of funding increasingly competitive!

Again, not necessarily a bad thing, but certainly not something to coolly swipe under the rug...

## Saturday, 19 October 2013

### R2jags & BCEA (& the examples from BMHE)

Recently, Yu-Sung Su and Masanao Yajima, the developers of the R2jags package, have released a new version (the current one is 0.03-11). As far as I understand it, one of the main changes is that since the update, R2jags no longer depends on the R2WinBUGS package (although it "imports" it).

The consequence of this is that you can no longer use the
R2WinBUGS functions, such as for example bugs or attach.bugs(), by just loading R2jags. In fact, there's a new function attach.jags() that allows you to attach the object you obtain as a result of the call to the jags function and containing, among other things, the MCMC simulations.

More importantly, if you also use BCEA and try to replicate the examples I describe in BMHE (for example see here, here, here and here) you are in trouble. All the code I have produced was running OK under the previous version of R2jags, but now you do get an error message when you try to attach the JAGS object using the attach.bugs() command.

Fortunately, this is not a huge problem and you actually have two options to solve it: the first one is to add to all those scripts a formal call to R2WinBUGS, eg library(R2WinBUGS). This will make the attach.bugs() command available again and so the rest of the code will run OK.

The second way is to actually use the attach.jags() command directly. In this, you don't need to load R2WinBUGS; however (because, as Sheldon Cooper would say: "what's life without whimsy?"), in this case you have to change the argument to this function, since attach.jags() takes a rjags object, while  attach.bugs() wants a bugs object.

So, for example, assume you have the following code.
library(R2jags)
model <- jags(data,inits,parameters.to.save,
model.file="some_file.txt", n.chains=2,
n.iter, n.burnin, n.thin, DIC=TRUE,
working.directory=working.dir, progress.bar="text")
and you want to make the object model (and all the elements contained in it) available to your R session, you can either do
library(R2WinBUGS)