[R] how to find "p" in binomial(n,p)

(Ted Harding) Ted.Harding at manchester.ac.uk
Thu Sep 20 01:34:27 CEST 2007


On 19-Sep-07 23:04:57, Mike Meredith wrote:
> 
> 
> I think the function you need is 'help.search'; try:
> 
> help.search("binomial")
> 
> and look for something obvious in the 'stats' package.
> A good deal quicker and easier than posting to an internet forum!
> 
> Cheers, Mike.

Well ...

  help.search("root")
  ?uniroot
  ?pbinom

n<-10; k<-4; alpha<-0.95;
f<-function(p){ pbinom(k,n,p)-alpha }
uniroot(f,c(0,1))

## $root
## [1] 0.2224413
## $f.root
## [1] -1.588189e-07
## $iter
## [1] 10
## $estim.prec
## [1] 6.103516e-05

#Check:
pbinom(k,n, 0.2224413)
## [1] 0.9499998


> 
> 
> cathelf wrote:
>> 
>> Dear all,
>> 
>> I am trying a find the value "p" in binomial.
>> 
>> X ~ Bin(n,p)
>> 
>> I want to find the value "p", so that Pr(X <= k) <= alpha 
>> 
>> Here, n, k and alpha are known. n, k are integers. alpha is between
>> (0,1).
>> 
>> Thanks a lot!
>> 
>> Catherine
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/how-to-find-%22p%22-in-binomial%28n%2Cp%29-tf44842
> 27.html#a12787900
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 20-Sep-07                                       Time: 00:34:22
------------------------------ XFMail ------------------------------



More information about the R-help mailing list