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. 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-tf4484227.html#a12787900 Sent from the R help mailing list archive at Nabble.com.
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 ------------------------------
On 20/09/2007, at 11:04 AM, 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! >I don't think so. I couldn't find anything useful under help.search ("binomial"), and I'm fairly comfortable with R. It seems to me that what is required here is to roll your own. I defined a function foo(): foo <- function(p,n,k,alpha){pbinom(k,n,p)-alpha} Then I used uniroot to solve foo(p,n,k,alpha) = 0. E.g. xxx <- uniroot(foo,c(0,1),n=20,k=15,alpha=0.05) Then xxx$root is 0.895913. Check this out graphically: p <- seq(0,1,length=301) y <- foo(p,20,15,0.05) plot(p,y,type="l") abline(h=0) abline(v=xxx$root) It looks good. cheers, Rolf Turner> Cheers, Mike. > > > 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 >>###################################################################### Attention:\ This e-mail message is privileged and confidenti...{{dropped}}