Need help with simple asymptote model using toy data


I’m trying to get accustomed to pymc3 and bayesian models in general. In particular right now I’m trying to fit a michaelis-menten-type model to my data, with a normal variance around the deterministic model for the mean with a standard deviation of ϵ:

y \sim N(\mu = \frac{x}{x+k}, \epsilon )

My own data is pretty big, ~2000 points, so here is a toy example that seems to repeat the error (I assigned k = 100 for the moment):

xx = pd.Series(range(0,3500,100))
yy_real = xx/(xx + 100)
εε = np.random.normal(0, 0.05, size=len(xx))
yy = yy_real + εε

(Image of data attached)

with pm.Model() as model_g:
    ε = pm.Normal('ε', mu=0, sd = 0.05)
    y_pred = pm.Normal('y_pred', mu= xx/(xx+100), sd=ε, observed=yy)
    trace_g = pm.sample(2000, tune=1000)

This returns a long error that boils down to the following error early while running the NUTS sampler:

RuntimeWarning: Mean of empty slice.

And finally with:

Bad initial energy, check any log probabilities that are inf or -inf, nan or very small:
y_pred -inf

So I guess I am generating negative infinity values somehow in my posterior? Picture of toy data and the curve I’d like to fit: toyboxFig

Thanks in advance.

The problem might be coming from your noise prior, since it can give invalid negative numbers for the standard deviation of you likelihood. Try to replace it with a positive distribution like the HalfNormal or even better a Gamma and see if your problems go away.

Perfect, thanks! Makes sense now that I think about, standard deviations can’t be negative. What is a “noise” prior?

The standard deviation parameter (epsilon). These are sometimes called noise parameters as well (not to be confused with nuisance parameters) :slight_smile:

I am glad that fixed your problems