[R] Integrate(dnorm) with different mean and standard deviation help

Rolf Turner rolf.turner at xtra.co.nz
Sat Jul 28 00:37:42 CEST 2012


On 27/07/12 20:55, David Winsemius wrote:
>
> On Jul 26, 2012, at 10:06 AM, FJ M wrote:
>
>>
>> It would be a useful additon to the help page to add
>>
>> integrate(dnorm, lower = -1.96, upper = 1.96, mean = 2, sd = 1)
>
> Wouldn't most statisticians instead use the more accurate and 
> undoubtedly faster:
>
>     pnorm(1.96, mean=2, sd=1) - pnorm(-1.96, mean=2, sd=1)
>
> ... or p_xxx where _xxx is distribution of interest?

     I conjecture that the OP was just using "dnorm" as an easily 
reproducible example,
     and was really interested in a function or functions for which no 
built-in "indefinite
     integral" exists.
>
> (And I do not see that every help page needs a worked example of the 
> proper use of the 'dots' argument. That is a basic R lesson and it is 
> only by chance that you have needed to learn it in the context of 
> integrate(). A large fraction of other functions offer that facility. 
> You might review the material you used when learning R to see at what 
> point you skimmed over that crucial topic too quickly. )
>

     Well, yes, but ................. the use of the "..." argument to 
pass arguments to another
     function (which itself is an argument) is a bit subtle.  At least 
initially, to those of us
     who are Bears of Very Little Brain.  A wee example would be 
redundant, as your discussion
     implies, but a little redundancy rarely hurts and tends to add 
robustness.

     We can't expect the documentation to explain "..." every time it 
appears as a function
     argument, but giving an example in "important" instances (with 
important being defined
     as when someone requests an example) seems to me to be a good idea.

         cheers,

             Rolf

P. S.  My Thunderbird mailer does not recognise the word "Winsemius" as 
a word and
suggests "inseminates" as a possible alternative. :-)

             R.

P^2. S.  Strangely enough, Thunderbird does not recognise 
***Thunderbird*** as a word!!!

             R.



More information about the R-help mailing list