Bayesian inference with stan & avoiding code duplication with dupree

This is a past event

28 people went

Location image of event venue


Hi everyone,

Our meeting is open for all to attend, and newcomers / beginners are very welcome! Our first speaker is Ian White, from the Institute of Evolutionary Biology, University of Edinburgh. He will be discussing:

# The stan MCMC package for R
Stan is open-source software for statistical modelling and high-performance statistical computation. It provides, among other things, full Bayesian statistical inference with MCMC sampling, approximate Bayesian variational inference, and penalized maximum likelihood estimation with optimization. For an overview, see Carpenter et al’s 2017 paper on Stan: A probabilistic programming language. I will give some simple examples using the R interface to Stan (package RStan).

Our second speaker will be Russell Hyde, Research Associate at the Institute of Cancer Sciences within Glasgow University. Russell will be sharing his work on a new R package:

# Fixing duplicated code with dupree
When writing analysis scripts I frequently slip into two modes of working: the ‘rush-rush-rush-isn’t-everything-exciting’ exploratory phase where I write code too fast, and the ‘wow-this-script-is-way-too-complicated’ (and haven’t I written that somewhere else? and why’s that variable called that? and where did those tabs come from?) maintenance phase, where I have to edit down the rushed code before I can do anything new. To find a happy midpoint between these two extremes I started using styler and lintr (to catch formatting inconsistencies early) and I started developing a tool called dupree ( to help detect when code duplication starts entering my projects. By finding duplicated code, I can more quickly decide what bits of code to generalise.
dupree() can be run on sets of “.R” and “.Rmd” files, or across all files in an R package. But, to my knowledge, only two people have ever used it (myself included)… So in this talk I’m going to give some examples of how dupree works and how it might help your R workflow. I’m also going to give an introduction to lintr, because dupree uses some code from lintr (and I really like lintr).
I would be delighted if a few of you could try running dupree on one of your projects / packages before the talk. Feel free to ping me via the dupree github-issues page or on twitter (@haematobot) with any feedback, in particular if any (or all) of the documentation is difficult to follow.