Re: [R] D(dnorm...)?

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu 26 Jan 2006 - 10:25:27 EST

On Wed, 25 Jan 2006, Spencer Graves wrote:

> Hi, Bert:
>
> I think I was too terse: Why didn't I get an error message? When I
> tried the same thing with "dpois", I got an error message:
>
> > D(expression(dpois(x, prob)), "mean")
> Error in D(expression(dpois(x, prob)), "mean") :
> Function 'dpois' is not in the derivatives table
>
> With "dnorm", I got "0"!. Whe didn't I get an error message?

Because dnorm _is_ in the derivatives table, as a function of x. (So is pnorm.) These are functions we write as \phi and \Phi in Statistics 101.

This is not particularly well documented in R, but it is in MASS4 pp. 437-8.

It would be worth enhancing the help page with the list of known functions. Long ago we talked about making it extensible, but nothing happened.

>
> Thanks for the reply.
> Spencer Graves
>
> Berton Gunter wrote:
>
>> dnorm() is an internal function, so I don't see how D (or deriv) can do
>> anything with it symbolically. Am I missing something?
>>
>> -- Bert
>>
>>
>>
>>
>>> -----Original Message-----
>>> From: r-help-bounces@stat.math.ethz.ch
>>> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Spencer Graves
>>> Sent: Wednesday, January 25, 2006 2:43 PM
>>> To: r-help@stat.math.ethz.ch
>>> Subject: [R] D(dnorm...)?
>>>
>>> Can someone help me understand the following:
>>>
>>>> D(expression(dnorm(x, mean)), "mean")
>>> [1] 0
>>>> sessionInfo()
>>>
>>> R version 2.2.1, 2005-12-20, i386-pc-mingw32
>>>
>>> attached base packages:
>>> [1] "methods" "stats" "graphics" "grDevices" "utils"
>>> "datasets"
>>> [7] "base"
>>>
>>> By my computations, this should be something like
>>> ((mean-x)/sd^2)*dnorm(...).
>>>
>>> Thanks for your help.
>>> Spencer Graves
>>>
>>> ______________________________________________
>>> 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
>>>
>>
>>
>
> ______________________________________________
> 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
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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 Thu Jan 26 10:33:40 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:10 EST