plot.depower | R Documentation |
An automatic plot method for objects returned by power()
.
## S3 method for class 'depower'
plot(
x,
x_axis = NULL,
y_axis = NULL,
color = NULL,
facet_row = NULL,
facet_col = NULL,
hline = NULL,
caption = TRUE,
caption_width = 70L,
...
)
x |
(depower) |
x_axis |
(string: |
y_axis |
(string: |
color |
(string: |
facet_row |
(string: |
facet_col |
(string: |
hline |
(numeric: |
caption |
(Scalar logical: |
caption_width |
(Scalar integer: |
... |
Unused additional arguments. |
If you are limited by the output from plot.depower()
, keep in mind that the
object returned by power()
is a standard data frame. This allows
you to easily plot all results with standard plotting functions. In addition,
because plot.depower()
uses ggplot2, you can modify the plot as you
normally would. For example:
set.seed(1234) sim_log_lognormal( n1 = c(10, 15), n2 = c(10, 15), ratio = c(1.3, 1.5), cv1 = c(0.3), cv2 = c(0.3, 0.5), nsims = 1000 ) |> power(alpha = 0.05) |> plot(hline = 0.8, caption_width = 60) + ggplot2::theme_bw() + ggplot2::theme(plot.caption = ggplot2::element_text(hjust = 0)) + ggplot2::labs(title = "Power for the ratio of geometric means")
A ggplot2::ggplot()
object.
power()
#----------------------------------------------------------------------------
# plot() examples
#----------------------------------------------------------------------------
library(depower)
# Power for independent two-sample t-test
set.seed(1234)
sim_log_lognormal(
n1 = c(10, 15),
n2 = c(10, 15),
ratio = c(1.3, 1.5),
cv1 = c(0.3),
cv2 = c(0.3, 0.5),
nsims = 500
) |>
power(alpha = 0.05) |>
plot()
# Power for dependent two-sample t-test
set.seed(1234)
sim_log_lognormal(
n1 = c(10, 15),
n2 = c(10, 15),
ratio = c(1.3, 1.5),
cv1 = c(0.3, 0.5),
cv2 = c(0.3, 0.5),
cor = c(0.3),
nsims = 500
) |>
power(alpha = 0.01) |>
plot()
# Power for two-sample independent AND two-sample dependent t-test
set.seed(1234)
sim_log_lognormal(
n1 = c(10, 15),
n2 = c(10, 15),
ratio = c(1.3, 1.5),
cv1 = c(0.3),
cv2 = c(0.3),
cor = c(0, 0.3, 0.6),
nsims = 500
) |>
power(alpha = c(0.05, 0.01)) |>
plot(facet_row = "cor", color = "test")
# Power for one-sample t-test
set.seed(1234)
sim_log_lognormal(
n1 = c(10, 15),
ratio = c(1.2, 1.4),
cv1 = c(0.3, 0.5),
nsims = 500
) |>
power(alpha = c(0.05, 0.01)) |>
plot()
# Power for independent two-sample NB test
set.seed(1234)
sim_nb(
n1 = c(10, 15),
mean1 = 10,
ratio = c(1.8, 2),
dispersion1 = 10,
dispersion2 = 3,
nsims = 100
) |>
power(alpha = 0.01) |>
plot()
# Power for BNB test
set.seed(1234)
sim_bnb(
n = c(10, 12),
mean1 = 10,
ratio = c(1.3, 1.5),
dispersion = 5,
nsims = 100
) |>
power(alpha = 0.01) |>
plot()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.