Publications by Simon Barthelme

Why an inverse-Wishart prior may not be such a good idea

07.03.2012

While playing around with Bayesian methods for random effects models, it occured to me that inverse-Wishart priors can really bite you in the bum. Inverse Wishart-priors are popular priors over covariance functions. People like them priors because they are conjugate to a Gaussian likelihood, i.e, if you have data with each : so that the ‘s ar...

4511 sym 72 img

Functional regression, INLA, and how to build the World’s Slowest Fourier Transform

29.03.2012

[This was originally going to be about multilevel modelling using INLA, but to do that flexibly you need INLA’s observation matrix mechanism, and this one deserves an explanation in its own right, so I’m introducing it by way of an easier example (for which you don’t actually need the observation matrix mechanism, but it’s clearer that wa...

6300 sym R (1947 sym/3 pcs) 130 img

What you get and what you should be getting: checking numerical code

22.08.2012

[Update 24.08.12: added missing alias following comment by brobar] Whenever I write numerical code I spend half my time debugging my algebra, painstakingly uncovering one sign mistake after another in my calculations. Usually I have computed by hand the gradient or the integral of some nasty function, and I have to check it against a numerical es...

2520 sym R (2451 sym/10 pcs) 10 img

New book: “Modeling Psychophysical Data in R”

14.09.2012

Ken Knoblauch wrote to inform me that Springer has just released a book he coauthored with Larry Maloney on statistical methods in psychophysics. The book is called “Modeling Psychophysical Data in R” and covers both classical psychophysical analyses (Signal Detection Theory) and more recent methods (e.g. Mixed Models). Ken was one of the fir...

1387 sym 4 img

edply: combining plyr and expand.grid

30.11.2012

Here’s a code snippet I thought I’d share. Very often I find myself checking the output of a function f(a,b) for a lot of different values of a and b, which I then need to plot somehow. An example: here’s a function that computes the value of a sinusoidal function on a grid of points, and returns a data.frame. fun <- function(freq,phase) { ...

1523 sym R (1235 sym/5 pcs) 8 img

French R Conference in Lyon – call for contributions

12.12.2012

[of interest mostly to French and R bilinguals] La prochaine édition des Rencontres R aura lieu à Lyon en Juillet prochain. Ci-dessous, l’appel officiel à contributions. ————————————————– Appel à communication des 2èmes Rencontres R : Dans la lignée de la conférence internationale Use’R et suite à la ...

2424 sym 4 img

Interactive MDS visualisation using D3

08.01.2013

Here’s a sneak peak into upcoming visualisation work. I’ve been working a bit on MDS (Multi-dimensional scaling), a classical technique for visualising distance data. Classical MDS is useful, but interactive MDS is *much* more useful. Using D3, a Javascript visualisation framework, it’s relatively easy to make interactive MDS plots. This ex...

1317 sym 6 img

Slightly silly D3 example: shift one datapoint to get a significant result

07.02.2013

Have you ever seen these scatterplots that report a significant correlation between X and Y, and look like it’s just the one point to the upper-right driving the correlation? Thanks to this interactive tool, you too can do this at home. Related To leave a comment for the author, please follow the link and comment on their blog: dahtah » R. ...

632 sym 4 img

Barycentric interpolation: fast interpolation on arbitrary grids

06.03.2013

Barycentric interpolation generalises linear interpolation to arbitrary dimensions. It is very fast although suboptimal if the function is smooth. You might now it as algorithm 21.7.1 in Numerical Recipes (Two-dimensional Interpolation on an Irregular Grid). Using package geometry it can be implemented in a few lines of code in R. Here’s a qui...

2418 sym R (801 sym/3 pcs) 38 img

Finding patterns in time series using regular expressions

17.05.2013

Regular expressions are a fantastic tool when you’re looking for patterns in time series. I wish I’d realised that sooner. Here’s a timely example: traditionally, when you have two successive quarters of negative GDP growth, you’re in recession. We have a quarterly GDP time series for Australia, and we want to know how many recessions the...

3000 sym R (941 sym/11 pcs) 8 img