# Finding the slope at different points in a sigmoid curve

This is my data.

x <- c(0.5,3.0,22.2,46.0,77.3,97.0,98.9,100.0)
plot(x, pch = 19)


I want to fit a curve through these points and then calculate the slope at different points. Could anyone tell me how to do this in R

EDIT

Previously I had fitted a Gompertz that gave me a 'maximum' slope. I want to know what are the slopes for other points.

Your question is very broad. There are many ways to do this, even without assuming a specific function. For the following I assume that you have a good reason to use the Gompertz model.

First let's fit the model:

y <- c(0.5,3.0,22.2,46.0,77.3,97.0,98.9,100.0)
x <- seq_along(y)
plot(x, y)

fit <- nls(y ~ SSgompertz(x, Asym, b2, b3), data = data.frame(x, y))
curve(predict(fit, newdata = data.frame(x)), add = TRUE)


Now, in order to get the desired slopes, you'll need to calculate the first derivative of the fitted function. That is simple highschool maths. In fact, it's so simple that even R can do it although it is not a computer algebra system.

#assign coefficients into global environment
list2env(as.list(coef(fit)), .GlobalEnv)
#create function that returns the gradient
dGomp <- deriv((y ~ Asym*exp(-b2*b3^x)), "x", func = TRUE)

#the model slopes: