Skip to content
Back to formatted view

Raw Message

Message-ID: <x2psw5gosj.fsf@turmalin.kubism.ku.dk>
Date: 2005-05-06T00:51:08Z
From: Peter Dalgaard
Subject: Numerical Derivative / Numerical Differentiation of unkno wn funct ion
In-Reply-To: <BDF571786CAD224F966FEB86BEDED52F1433DABD@elon12p32001.csfp.co.uk>

"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