# R fit a logistic regression of the form $y=\frac{c}{1+ae^{-bx}}$ [duplicate]

I'm working through some textbook exercises on fitting models to data, including exponential, logarithmic and now logistic regression.

About a 3rd of the way down this page is the section on logistic regression. Using a model of the form $$y=\frac{c}{1+ae^{-bx}}$$ we have to fit a logistic model.

I'm using R and any searching for logistic regression in r returns results about binary classification whereas here I'm seeking a numerical result based on a logistic curve.

For the 'try it' exercise #3 on the page I linked to above, a data frame is provided:

ti3_df <- data.frame(
x = 0:15,
y = c(3.493, 5.282, 6.357, 9.201, 11.224, 12.964, 16.226, 18.137,
19.590, 21.955, 22.862, 23.869, 24.243, 24.344, 24.919, 25.108)
)


Along with the question:

Let x represent time in years starting with x=0 for the year 1997. Let  y  represent the number of seals in thousands. Use logistic regression to fit a model to these data.

How can I do this in R?

(Incase someone asks, 'why not just write a custom function based on the model definition above?', I would like to and that's what I'm building to because I don't fully understand how to do that 'by hand' at this stage. My initial goal is to get a result with an out of the box function in r before trying to recreate it myself with a custom function)

• This is not a logistic regression, it is a nonlinear regression with a logistic/logit response. See for instance stats.stackexchange.com/questions/47802/…, stats.stackexchange.com/questions/67049/…. Please edit title & tags, and explain beter your applied context! Mar 18, 2021 at 11:45
• I find it really interesting that both the links you shared refer to Google issues finding a solution here "This isn't as easy to Google as some other things as" and "Surprisingly, I was unable to find an answer to the following question using Google". Then, in my own post "... any searching for logistic regression in r returns results about binary classification ". All 3 of us had search engine issues with this one! Stack Exchange Google indexing is pretty strong, maybe there's merit in leaving these tags and title as is for anyone struggling with this search term@kjetilbhalvorsen Mar 18, 2021 at 12:20
• You have many good points. I was also surprised that I needed longer than usual to find those linked posts ... Probably the use of logistic regression in the binary generalized linear model sense so overshadows the use as a logistic growth curve*. That is a good search term: stored search. For R examples add R to that search. Another search term is sigmoid and the tags sigmoid-curve, logistic-curve, growth-model . Do you find answer to your Q in this links? Mar 18, 2021 at 13:03
• I am with @kjetilbhalvorsen that the authors are using poor terminology. Perhaps that could have been called "logistic regression" when the term first got assigned to a method (that could be defended), but now, "logistic regression" means a binomial response variable.
– Dave
Mar 18, 2021 at 13:28
• I do not know what you mean by v4 of R but when I fire up R 4.0.3 and type ?nls it opens the help page for nls for me. Mar 18, 2021 at 14:13