Find the midpoint of S-curves with R I have a bunch of curves that look like S-curves (stored in a db with Point format) and I am interested in finding this midpoint between both horizontal asymptotes for each of them. So, if X-axis represents time and Y-axis number of occurrences of a phenomenon, how can I project this midpoint over X-axis to know the date it happened?
I would like to do this operation in R software, please, can you help me with some guidelines about how to do it?
Thanks!
 A: I'm pretty sure this is not a statistics question, so it will probably get moved. Also, it is quite vague, and I have no idea what 'stored in a db with Point format' means. I'll try to help you out though:
In theory you have a function $\pi(x)$ that is monotone increasing with range 0 to 1 and you want to find $x$ such that $\pi(x) = 0.5$. If you can compute the inverse of $\pi(x)$ analyticall then that $x$ would be $x= \pi^{-1}(0.5)$. 
If you can't do it analytically you can always use a computer. 
For example if $\pi(x) = \dfrac{e^{0.5+2x}}{1+e^{0.5+2x}}$ you can do this in R:
> x<- seq(-20,20,by=0.1)
> plot( exp(0.5+2*x)/(1+exp(0.5+2*x))~x)


> uniroot( function(x){exp(0.5+2*x)/(1+exp(0.5+2*x))}-0.5, c(-20,20))$root
[1] -0.2500002


A: This is what I did in the end, because it might be useful to others:
I used nls function to find a fit:
fit <- nls(Y ~ theta1/(1+exp(-(theta2 + theta3*X))), start=list(theta1=1, theta2=0.02, theta3=0.03), trace=TRUE)
p=predict(fit)

Theta1/2/3 correspond to the "upper limit" of the function, the "growth rate" and the "maximum growth rate". I guessed them taking a look to the data in the chart and trying. If you get an error such as "singular gradient" it is because your parameters are not correct for the function growing or maybe because your x/y values are too big for them and do not converge after several iterations. I think, not fully sure about what is going on.
To calculate the inverse of a function to be able to know the X value when Y is 0.5, I checked this post Solving for the inverse of a function in R. Like this I can do something like:
my_inverse = inverse(function(x) 0.74/(1+exp(4.14-0.47*x)))
res <- my_inverse(0.5)
res
$root
[1] 38.306

Where the coefficients are obtained from "fit" parameter. 
So, when Y=0.5, X=38.306. Maybe there is a easier method for the same, but I just could come up with this solution.
