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-requ...@r-project.org wrote: > Message: 88 > Date: Thu, 17 Nov 2011 12:40:59 -0900 > From: Katrina Bennett <kebenn...@alaska.edu> > To: r-help@r-project.org > Subject: [R] Obtaining a derivative of nls() SSlogis function > Message-ID: > <ca+snm83utzmd1hdfgf2biolpwgwhs-owrmahov4ykqtvswy...@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 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.