[R] Deriving formula with deriv

From: kitty <kitty.a1000_at_gmail.com>
Date: Mon, 04 Apr 2011 11:35:08 +0100


Dear list,

Hi,

I am trying to get the second derivative of a logistic formula, in R summary the model is given as :

###
>$nls
>Nonlinear regression model

  >model: data ~ logistic(time, A, mu, lambda, addpar)    >data: parent.frame()
     > A mu lambda
>0.53243 0.03741 6.94296

###

but I know the formula used is

# y~'A'/(1+exp((4*'mu'/'A')*('lambda'-'time'))+2)) # from the grofit ( package I am using to fit the model) documentation.

I have attempted to use the R function 'deriv' to get the first derivative from which I can then reuse the deriv function to get the second derivative.... unfortunately this does not seem to work

###
>express<-expression(y~'A'/(1+exp((4*'mu'/'A')*('lambda'-'time'))+2))
> express

expression(y ~ "A"/(1 + exp((4 * "mu"/"A") * ("lambda" - "time")) +

    2))
>

> d1<-deriv(express)

Error in deriv.default(express) : element 2 is empty;

   the part of the args list of '.Internal' being evaluated was:    (expr, namevec, function.arg, tag, hessian)  ####

Why is this not working and how do I get the second derivative?

Thank you for reading my post, all help is appreciated, Kitty

        [[alternative HTML version deleted]]



R-help_at_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. Received on Mon 04 Apr 2011 - 10:44:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 04 Apr 2011 - 15:40:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive