The name logistic originally comes from the logistic growth equation:
$$ \frac{d N}{d t} = r N (1 - N) $$
which is a simple differential equation model for the growth of a population. The logistic function is its solution:
$$ N(t) = \frac{e^{rt}}{1 + e^{rt}} $$
Which has the attractive property that it is increasing, $lim_{x \rightarrow \infty} = 1$ and $lim_{x \rightarrow -\infty} = 0$. Because of these properties (and more) it is used as the (inverse) link function in logistic regression to model the probability of a binary outcome:
$$ Pr(y \mid x) = \frac{e^{\beta \cdot x}}{1 + e^{\beta \cdot x}} $$
The population model came first (1845), so the regression inherited the name (1958).
Clarification question: so in my case, I want to find an equation in R that models a population of rabbits. For example, the values start at 600 and multiply until the carrying capacity of 1400. It looks like a logistic curve, but it's not binary. If I want to model it in R, what category/package does it fall under? (Sorry, resources are conflicting).
That's actually an underspecified problem, because the rabbits could multiply to their carrying capacity quickly or slowly. In any case, once the rate $r$ of growth has been pre-specified (or left as a free parameter), you don't need R to solve the problem. Just take the general solution to the logistic growth model:
$$ N(t) = a \frac{e^{r(t - t_0)}}{1 + e^{r(t - t_0)}} $$
And solve the two equations $N(0) = 600$ and $lim_{t \rightarrow \infty} N(t) = 1400$ for $a$ and $t_0$.
If the idea for using R is that you have some data, and you want to determine the growth parameter $r$ by fitting a curve to the data, you could do what is advised in this answer.
Have you tried using SSLogis
in your nls call? Right now, you're just fitting a line, and the reason you're getting that error is because nls requires a symbolic variable in the passed formula.
data <- 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)
)
model = nls(y ~ SSlogis(x, a, b, c), data = data)
plot(data$x, data$y)
lines(data$x, predict(model))
This results in the following fit
Best Answer
See the
nls()
function. It has a self starting logistic curve model function viaSSlogis()
. E.g. from the?nls
help pageI suggest you read the help pages for these functions and probably the linked references if possible to find out more.