Good Evening,
I fitted a four parameter logistic curve using R nls function with the following equation:
y = alpha lambda/(1 exp(-beta(x-mu))
I would like to determine the maximum slope of this curve and for this I would like to compute the derivative of the function. Do you know how I can find the derivative of this function and use it to determine the maximum slope or the maximum derivative value?
Thank you in advance,
Rohan
I find the regular sigmoid equation y = 1/1 e-x and its derivative but not with the parameters. I am expecting some help with the derivative of my equation and a piece of script that can help me to find the maximum value.
CodePudding user response:
Let us say that the parameters you have calculated are alpha = 1, lambda = 2, beta = 3 and mu = 4. Then create the derivative function fder
and use optimize
to find its maximum. Evidently the maximum slope occurs at mu and equals 1.5 or substituting x = mu into the derivative fder we have that the derivative at the maximum equals lambda * beta / 4.
fder <- function(x, alpha = 1, lambda = 2, beta = 3, mu = 4) {}
body(fder) <- D(expression(alpha lambda/(1 exp(-beta*(x-mu)))), "x")
optimize(fder, c(-10, 10), maximum = TRUE)
## $maximum
## [1] 3.99999
##
## $objective
## [1] 1.5
CodePudding user response:
Starting from @G.Grothendieck's answer, here's a logical explanation of why the maximum derivative is lambda*beta/4
.
- The maximum derivative of the unscaled logistic function is 1/4, at
x=0
- The maximum derivative of
1/(1 exp(-beta*x))
isbeta/4
atx=0
(you can look this up on Wikipedia - adjusting the midpoint (e.g.
1/(1 exp(-beta*(x-mu)))
) shifts the location of the maximum derivative tox=mu
but doesn't change its value - shifting the curve up by adding
alpha
(alpha 1/(1 exp(-beta*(x-mu)))
) doesn't change the max slope or its location - scaling the curve by
lambda
(alpha lambda/(1 exp(-beta*(x-mu)))
) scales the max derivative bylambda
(beta/4 → lambda*beta/4
)