# fit a model to data

I want to fit a model to a data set, however each point is actually a distribution (i.e. I have the samples for each distribution). In an ideal world, I would assume that the distributions are Gaussian-like, estimate the median and 1-sigma interval, and then fit a model through the data points using the median and 1-sigma values. Unfortunately, this is not the case. I first took a simple approach (no error bars on the x axis, work pretty fine) and then included uncertainties on the x-axis (doesn’t work). I describe below my implementation.

Simple approach — data on x-axis is known precisely, i.e. no error bars. Here’s what I did:

• apply KDE to the samples for each point on the y-axis

• at each step in the MCMC for each point:

• evaluate ymodel = f(x, theta)

• calculate the likelihood of ymodel using its previously calculated KDE functions.

• sum likelihood for all data points

The chains converge nicely and the model looks decent. The next step is to implement a similar approach with uncertainties on the x-axis.

Including uncertainties on the x-axis

• apply KDE to the samples for each point on the x- and y-axis.

• at each step in the MCMC for each point:

• draw one sample from the distribution, let’s call this xsample

• evaluate ymodel = f(xsample, theta)

• calculate the likelihood of ymodel using its previously calculated KDE function

• calculate likelihood of xsample also using the previously calculated KDE functions

• sum likelihood of ymodel and xsample for all the data points

Unfortunately, when I include the uncertainties on the x-axis the chains do not converge. Most of the walkers are stuck and the acceptance ratio is ~ 0.02. I would appreciate any suggestions/recommendations.