[R] Small p from binomial probability function.

Rolf Turner r.turner at auckland.ac.nz
Thu Oct 17 00:15:58 CEST 2013


On 10/16/13 23:56, Benjamin Ward (ENV) wrote:
> Hi,
>
> Thanks again for your answers, just so as I can get clear what is happening, with the uniroot method, I'm defining a function in which the binomial probability function pbinom is present but in addition p0 is subtracted from the result - in this case p0 is the large P I want to plug in so 0.05, 0.50 and 0.95, or even just 0.05 and 0.95? Then uniroot finds the root of this function and doing so find me the small p I need?

I believe that you have a correct understanding.  To beat it to death:

     * you want/need to solve an equation of the form

         f(p) = p0

        for p.

     * the uniroot() function solves equations of the form

         g(p) = 0

        for p

     * therefore define g(p) = f(p) - p0 and apply uniroot() to the 
function g(.).

HTH.

     cheers,

     Rolf Turner



More information about the R-help mailing list