# Fitting a custom 3-parameter logistic function to data

I would like to fit a 3-parameter logistic function of the following form to my (pi, xi) data:

$p=\lambda&space;+(1-2\lambda)/(1+e^{-\beta(x-\alpha)})$

Example of data:

xi = np.array([-0.5 , -0.12, -0.06, 0., 0.06, 0.12, 0.5])
pi = np.array([0. , 0.05556, 0.27778, 0.5 , 0.77778, 0.91667, 0.97222])

As a starting point, I would like to fit this function using maximum likelihood. I understand I need to put flat priors on each parameter, but I am sure of the likelihood function and how to implement it within pymc3. I would grateful if somebody could help me.

Hi Mathieu,
I think you can just write your custom link function as on paper. Something like this:

p = lambda + (1 - 2 * lambda) / (1 + pm.math.exp(-beta * (x - alpha))


lambda, beta and alpha having their own priors.

I’m guessing the ps are probabilities, so a Binomial or Multinomial as likelihood could be appropriate. You can learn more about GLMs in PyMC3 with the port of Statistical Rethinking 2.
Hope this helps

1 Like