Re: [R] Numerical Derivative / Numerical Differentiation of unkno wn funct ion

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Fri 06 May 2005 - 10:51:08 EST

"Uzuner, Tolga" <tolga.uzuner@csfb.com> writes:

> Ah... I searched for half an hour for this function... you know, the
> help function in R could really be a lot better...
>
> But wait a minute... looking at this, it appears you have to pass in
> an expression. What if it is an unknown function, where you only
> have a handle to the function, but you cannot see it's
> implementation ? Will this work then ?
>
> -----Original Message-----
> From: Berton Gunter [mailto:gunter.berton@gene.com]
> Sent: 05 May 2005 23:34
> To: 'Uzuner, Tolga'; r-help@stat.math.ethz.ch
> Subject: RE: [R] Numerical Derivative / Numerical Differentiation of
> unknown funct ion
>
>
> But...
>
> See ?numericDeriv which already does it via a C call and hence is much
> faster (and probably more accurate,too).
>

The expression passed to numericDeriv can easily be a call to .C or similar.

Actually, numericDeriv can get you in trouble if the function is not smooth enough. It basically just calculates (f(a+d)-f(a))/d where d is on the order of 1e-7 * a for each parameter. Sometimes a larger d and a higher order approximation is need to avoid getting stuck in the rough.

(Yes, Bill, I do remember that you wanted an R News Programmer's Niche item from me on this...)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri May 06 11:01:32 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:37 EST