Blog posts

2022

2020

Analying multiple datasets with a joint likelihood

less than 1 minute read

Published:

Suppose you have multiple datasets that share one/two or more parameters, you want to combine the data and analyse them together to make the best possible measurement for the parameters shared by the multiple different data sets. A joint likelihood is the natural way to do such an analysis. One massive benefit of such a method is that not only this allows one to do model selection, it also gives a better measurement of the parameters than multiplying the individual posteriors would. This can also help constrain the other non-common parameters too, particularly if the additional data set can break a degeneracy. In this example, I show how you can use a joint likelihood for a simple system involving two data sets; noisy observations of a linear model. I show how such data can be fit in a joint likelihood with bilby. Specifically, in this example the gradient is a joint parameter while the intercept is unique to each data set.

2018

Using PyStan to fit a model with X and Y errors

less than 1 minute read

Published:

After writing my first post. I was recommended Stan to fit more complicated models to data with X and Y uncertainties. Stan and Hamiltonian Monte Carlo (HMC) is naturally suited to problems like this as the simplest way to treat X errors is to sample over the true x values and then marginalise. This adds a dimension for each data point which breaks most samplers, except HMC. This example is for a simple problem like in the first post, but instead using Stan to sample. Shoutout to Andy Casey for help with Stan.

Fitting a line to data with X and Y errors

less than 1 minute read

Published:

I wrote this post as a reference for myself and anyone else looking to determine how to fit a model to data with both x and y uncertainties. Commonly, in Astrophysics even when fitting data with Bayesian inference, x errors are commonly ignored and only y errors are included leading to a significant underestimation of model uncertainty. In this tutorial, I explore this problem with Bilby.