Thank you to all who have made great suggestions. Both Gabor and David's methods work well for me. I see now where I was going wrong with this, I wasn't loading it to a function. I also did not know expression could be used in that way.
Thank you very much for your help! Katrina On Fri, Nov 18, 2011 at 6:02 AM, Gabor Grothendieck <ggrothendi...@gmail.com > wrote: > On Thu, Nov 17, 2011 at 4:40 PM, Katrina Bennett <kebenn...@alaska.edu> > wrote: > > 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? > > > > You can do that with plain R: > > > e <- quote(asym/((1+exp((xmid-x.seq)/scal)))) > > for(v in all.vars(e)) cat("deriv wrt", v, "is", format(D(e, v)), "\n") > deriv wrt asym is 1/((1 + exp((xmid - x.seq)/scal))) > deriv wrt xmid is -(asym * (exp((xmid - x.seq)/scal) * (1/scal))/((1 + > exp((xmid - x.seq)/scal)))^2) > deriv wrt x.seq is asym * (exp((xmid - x.seq)/scal) * (1/scal))/((1 + > exp((xmid - x.seq)/scal)))^2 > deriv wrt scal is asym * (exp((xmid - x.seq)/scal) * ((xmid - > x.seq)/scal^2))/((1 + exp((xmid - x.seq)/scal)))^2 > > > -- > Statistics & Software Consulting > GKX Group, GKX Associates Inc. > tel: 1-877-GKX-GROUP > email: ggrothendieck at gmail.com > -- Katrina E. Bennett PhD Student University of Alaska Fairbanks International Arctic Research Center 930 Koyukuk Drive, PO Box 757340 Fairbanks, Alaska 99775-7340 907-474-1939 office 907-385-7657 cell kebenn...@alaska.edu Personal Address: UAF, PO Box 752525 Fairbanks, Alaska 99775-2525 bennett.katr...@gmail.com [[alternative HTML version deleted]] ______________________________________________ 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.