Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- designBer <- Vectorize( function(p, q) {
- Q <- q*(1-q)/(p*(1-p))
- x <- 1/(sqrt(Q)+1) # ideal proportion in trial 1, that is n/N
- x} )
- p <- q <- seq(from=0.05, to=0.95, by=0.05)
- pq <- expand.grid(p, q)
- z <- outer(p, q, FUN=designBer)
- image(p, q, z, main="Proportions of runs for trial 1")
- contour(p, q, z, nlevels=19, xlab="p", ylab="q", add=TRUE)
- designRelEff <- Vectorize( function(p, q) {
- Q <- q*(1-q)/(p*(1-p))
- x <- 1/(sqrt(Q)+1) # ideal proportion in trial 1, that is n/N
- eff <- (2 * (p*(1-p) + q*(1-q) ) ) / ( ((p*(1-p))/x) + (q*(1-q))/(1-x) )
- 1/eff
- }
- )
- image(p, q, zz <- outer(p, q, FUN=designRelEff), main="Relative efficyency for equal apportionment" )
- contour(p, q, zz, nlevels=19, xlab="p", ylab="q", add=TRUE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement