Hi,

I got given some code that uses the R function pbionom:

p <- mut * t
sumprobs <- pbinom( N, B, p ) * 1000

Which gives the output of a probability as a percentage like 5, 50, 95.

What the code currently does is find me the values of t I need, by using the 
above two code lines in a loop, each iteration it increaces t by one and runs 
the two lines. When sumprobs equals 5, it records the value t, then again when 
sumprobs is equal to 50, and again when sumprobs is equal to 95 - giving me 
three t values. This is not an efficient way of doing this if t is large. Is it 
possible to rearrange pbinom so it gives me the small p (made of mut*t) as the 
result of plugging in the sumprobs instead, and is there an R function that 
already does this?

Since pbinom is the binomial probability equation I suppose the question is - 
in more mathematical terminology - can I change this code so that instead of 
calculating the Probability of N successes given the number of trials and the 
probability of a single success, can I instead calculate the probability of a 
single success using the probability of N successes and number of trials, and 
the number of successes? Can R do this for me. So instead I plug in 5, 50, and 
95, and then get the small p out?

Thanks,
Ben W.





        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to