Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. designBer <- Vectorize( function(p, q) {
  2. Q <- q*(1-q)/(p*(1-p))
  3. x <- 1/(sqrt(Q)+1) # ideal proportion in trial 1, that is n/N
  4. x} )
  5. p <- q <- seq(from=0.05, to=0.95, by=0.05)
  6. pq <- expand.grid(p, q)
  7. z <- outer(p, q, FUN=designBer)
  8. image(p, q, z, main="Proportions of runs for trial 1")
  9. contour(p, q, z, nlevels=19, xlab="p", ylab="q", add=TRUE)
  10.  
  11. designRelEff <- Vectorize( function(p, q) {
  12. Q <- q*(1-q)/(p*(1-p))
  13. x <- 1/(sqrt(Q)+1) # ideal proportion in trial 1, that is n/N
  14. eff <- (2 * (p*(1-p) + q*(1-q) ) ) / ( ((p*(1-p))/x) + (q*(1-q))/(1-x) )
  15. 1/eff
  16. }
  17. )
  18. image(p, q, zz <- outer(p, q, FUN=designRelEff), main="Relative efficyency for equal apportionment" )
  19. contour(p, q, zz, nlevels=19, xlab="p", ylab="q", add=TRUE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement