Guest User

Untitled

a guest
Dec 11th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. hyperprob <- function(y, nd, nt, p, lower.tail=T, offset=0) {
  2. phyper(y, nt*p, nt*(1-p), nd)/2 + #dhyper does not deal with fractional gamma well
  3. phyper(y-lower.tail, nt*p, nt*(1-p), nd, lower.tail=lower.tail)/2 +
  4. offset
  5. }
  6.  
  7. uniroot(hyperprob, c(0,1), y=y, nd=nd, nt=nt, lower.tail=F, offset=-0.5)
  8. uniroot(hyperprob, c(0,1), y=y, nd=nd, nt=nt, lower.tail=F, offset=-0.025)
  9. # estimate and lower are 0 if every sample is 0
  10. upper <- uniroot(hyperprob, c(0,1), y=y, nd=nd, nt=nt, lower.tail=T, offset=-0.025)
Add Comment
Please, Sign In to add comment