[R] Obtaining a derivative of nls() SSlogis function

John C Nash nashjc at uottawa.ca
Fri Nov 18 14:59:27 CET 2011


I think you need to make an expression. I tried

> nls.fn <- asym/((1+exp((xmid-x.seq)/scal)))
Error: object 'asym' not found
> nls.fn <- expression(asym/((1+exp((xmid-x.seq)/scal))))
> D(nls.fn,"asym")
1/((1 + exp((xmid - x.seq)/scal)))
>

Does that help? Maybe there are other approaches too.

JN


On 11/18/2011 06:00 AM, r-help-request at r-project.org wrote:
> Message: 88
> Date: Thu, 17 Nov 2011 12:40:59 -0900
> From: Katrina Bennett <kebennett at alaska.edu>
> To: r-help at r-project.org
> Subject: [R] Obtaining a derivative of nls() SSlogis function
> Message-ID:
> 	<CA+SNM83UtZMd1HDFGf2BioLPWGwhS-OWRMaHoV4yKQtvSwy4tQ at mail.gmail.com>
> Content-Type: text/plain
> 
> Hello, I am wondering if someone can help me. I have the following function
> that I derived using nls() SSlogis. I would like to find its derivative. I
> thought I had done this using deriv(), but for some reason this isn't
> working out for me.
> 
> Here is the function:
> asym <- 84.951
> xmid <- 66.90742
> scal <- -6.3
> 
> x.seq <- seq(1, 153,, 153)
> nls.fn <- asym/((1+exp((xmid-x.seq)/scal)))
> 
> try #1
> deriv(nls.fn)
> #get an Error in .Internal(deriv.default(expr, namevec, function.arg, tag,
> hessian)) : 'namevec' is missing
> 
> try #2
> deriv(nls.fn, namevec=c("asym", "xmid", "scal"))
> #this doesn't seem to give me the expression, and the gradients are zero.
> 
> I've tried to do this with Ryacas as well, but I'm lost.
> 
> Can anyone help?
> 
> Thank you,
> 
> Katrina



More information about the R-help mailing list