power.plot {biology} | R Documentation |
~~ A concise (1-5 lines) description of what the function does. ~~
power.plot(delta, sd, n)
delta |
~~Describe delta here~~ |
sd |
~~Describe sd here~~ |
n |
~~Describe n here~~ |
~~ If necessary, more details than the description above ~~
~Describe the value returned If it is a LIST, use
comp1 |
Description of 'comp1' |
comp2 |
Description of 'comp2' |
~~further notes~~
~Make other sections like Warning with Warning .... ~
~~who you are~~
~put references to the literature/web site here ~
~~objects to See Also as help
, ~~~
##---- Should be DIRECTLY executable !! ---- ##-- ==> Define data, use random, ##-- or do help(data=index) for the standard data sets. ## The function is currently defined as function (delta, sd, n) { library(R.utils) power <- numeric(length(n)) j <- 0 if (length(delta) == 1) constant <- "delta" else constant <- "sd" if (constant == "sd") for (i in n) { j <- j + 1 power[j] <- power.t.test(n = i, sd = sd, delta = delta[1])$power } else for (i in n) { j <- j + 1 power[j] <- power.t.test(n = i, sd = sd[1], delta = delta)$power } if (getBuiltinOs.GString() == "windows") windows(height = 4, width = 4) else X11(height = 4, width = 4) old_par <- par(mar = c(4, 4, 2, 1)) if (constant == "sd") plot(n, power, axes = F, xlab = "", ylab = "", lwd = 2, type = "n", main = substitute(paste("sd = ", sd), list(sd = sd))) else plot(n, power, axes = F, xlab = "", ylab = "", lwd = 2, type = "n", main = substitute(paste("delta = ", delta), list(delta = delta))) axis(1, tick = T, tcl = -0.2, lab = T, cex.axis = 1, lwd = 2) mtext("n", 1, font = 2, cex = 1.5, line = 3) axis(2, tick = T, tcl = -0.2, lab = T, cex.axis = 1, lwd = 2, las = 1) mtext("power", 2, font = 2, cex = 1.5, line = 3) lines(c(0, max(n)), c(0.8, 0.8), lty = 2) box(bty = "l", lwd = 2) if (constant == "sd") { if (length(delta) > 0) { kk <- 0 for (k in delta) { kk <- kk + 1 power <- numeric(length(n)) j <- 0 for (i in n) { j <- j + 1 power[j] <- power.t.test(n = i, sd = sd, delta = delta[kk])$power } points(n, power, col = "black", pch = 16, lwd = 2, type = "l", lty = kk) } } legend("bottomright", title = "Delta", legend = delta, lty = seq(1, length(delta), by = 1)) } else { if (length(sd) > 0) { kk <- 0 for (k in sd) { kk <- kk + 1 power <- numeric(length(n)) j <- 0 for (i in n) { j <- j + 1 power[j] <- power.t.test(n = i, sd = sd[kk], delta = delta)$power } points(n, power, col = "black", pch = 16, lwd = 2, type = "l", lty = kk) } } legend("bottomright", title = "sd", legend = sd, lty = seq(1, length(sd), by = 1)) } }