Numerical Derivative / Numerical Differentiation of unkno wn funct ion
"Uzuner, Tolga" <tolga.uzuner at 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 at gene.com] Sent: 05 May 2005 23:34 To: 'Uzuner, Tolga'; r-help at 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 at biostat.ku.dk) FAX: (+45) 35327907