How can I plot relationship between two variables with the constraint of initiating the S-shaped curve from (0,0) as depicted in the example below? I don't want to run logistic regression or any such regression model. I have 8 to 10 pairs of data points and want to analyze the logistic growth model by fitting any function-generating S-shaped curve like tanh() or so on. I am using R for the assigned task.
The blue points in the graph represent the data points and I want to fit the curve as depicted in the graph.
 A: Using the data sent to me:
dd <- structure(list(x=c(18.6,13.13,14.3,5.72,9.1,11.7,7.15 ,4.55, 1.17),
                     y =c( 26.4, 15.28,12.27,10.34,7.7,7.24,6.83,3.47,0.99),
                     class = "data.frame")
)

The Hill function of order 2 (i.e. $y=ax^2/(1+(bx)^2)$) has a sigmoidal shape but goes through $y=0$ when $x=0$. In this parameterization, $a$ is the initial slope and $b$ is the reciprocal of the half-maximum point. Eyeballing the graph for reasonable starting points (an essential step in non-linear fitting), we get $a \approx 0.5$, $b \approx 1/15$.
Fit with nls():
fit1 <- nls(y~a*x^2/(1+(b*x)^2), 
             start=list(a=0.5,b=1/15), data=dd)

In order to do this without eyeballing every time you either have to (1) trust that the scales are reasonably similar for all of your different data sets or (2) set up a self-starting function for the nls fit.
For this parameterization, the initial slope is $a$, the half-maximum is $1/b$, and the asymptote is $a/b^2$:
cc_nls <- as.list(coef(fit1))
res <- with(cc_nls,c(init_slope=a,half_max=1/b,asymptote=a/b^2))
##   init_slope     half_max    asymptote 
##   0.08813282  39.18785991 135.34455071 

Generate predicted values:
xmax <- 100; ymax <- 150     
pframe <- data.frame(x=seq(0,xmax,length=51))
pframe$y <- predict(fit1, newdata=pframe) 

Construct confidence intervals by the delta method (could also use bootstrapping):
vv <- suppressWarnings(emdbook::deltavar(a*pframe$x^2/(1+(b*pframe$x)^2),
                        meanval=coef(fit1),
                        Sigma=vcov(fit1)))
pframe$lwr <- pframe$y-2*sqrt(vv)
pframe$upr <- pframe$y+2*sqrt(vv)

Find points where the tangent to the curve is parallel to the linear regression slope (I initially tried to do this analytically, but it gets very ugly ...)
cc_lm <- coef(lm(y~x, dd))["x"] ## slope of linear model
dfun <- deriv(expression(a*x^2/(1+(b*x)^2)),"x",
              function.arg=c("x","a","b"))
dfun2 <- function(x) with(cc_nls, 
                       attr(dfun(x,a,b),"gradient")-cc_lm)
u1 <- uniroot(dfun2,c(0,1/cc_nls$b))$root
u2 <- uniroot(dfun2,c(1/cc_nls$b,xmax))$root

Plot everything:
png("hillfun.png")
par(las=1,bty="l")
plot(dd,xlim=c(0,xmax),ylim=c(0,ymax),pch=16,
     xlab="x",ylab="y")
with(pframe,polygon(x=c(x,rev(x)),y=c(lwr,rev(upr)),
                    col=adjustcolor("black",alpha=0.3)))
abline(lm(y~x, data=dd), lty=2)
abline(v=c(u1,u2),lty=3,col="blue")
abline(h=res["asymptote"],lty=3,col="purple")
with(pframe,lines(x,y,col="red"))
dev.off()


