View source: R/x_from_power_for_x_plot.R
plot.x_from_power | R Documentation |
It plots the results of 'x_from_power', such as the estimated power against sample size.
## S3 method for class 'x_from_power'
plot(
x,
what = c("ci", "power_curve", "final_x", "final_power", "target_power", switch(x$x, n =
"sig_area", es = NULL)),
text_what = c("final_x", "final_power", switch(x$x, n = "sig_area", es = NULL)),
digits = 3,
main = paste0("Power Curve ", "(Target Power: ", formatC(x$target_power, digits =
digits, format = "f"), ")"),
xlab = NULL,
ylab = "Estimated Power",
ci_level = 0.95,
pars_ci = list(),
pars_power_curve = list(),
pars_ci_final_x = list(lwd = 2, length = 0.2, col = "blue"),
pars_target_power = list(lty = "dashed", lwd = 2, col = "black"),
pars_final_x = list(lty = "dotted"),
pars_final_power = list(lty = "dotted", col = "blue"),
pars_text_final_x = list(y = 0, pos = 3, cex = 1),
pars_text_final_power = list(pos = 3, cex = 1),
pars_sig_area = list(col = adjustcolor("lightblue", alpha.f = 0.1)),
pars_text_sig_area = list(cex = 1),
...
)
## S3 method for class 'n_region_from_power'
plot(
x,
what = c("ci", "power_curve", "final_x", "final_power", "target_power", "sig_area"),
text_what = c("final_x", "final_power", "sig_area"),
digits = 3,
main = paste0("Power Curve ", "(Target Power: ", formatC(x$below$target_power, digits =
digits, format = "f"), ")"),
xlab = NULL,
ylab = "Estimated Power",
ci_level = 0.95,
pars_ci = list(),
pars_power_curve = list(),
pars_ci_final_x = list(lwd = 2, length = 0.2, col = "blue"),
pars_target_power = list(lty = "dashed", lwd = 2, col = "black"),
pars_final_x = list(lty = "dotted"),
pars_final_power = list(lty = "dotted", col = "blue"),
pars_text_final_x = list(y = 0, pos = 3, cex = 1),
pars_text_final_power = list(cex = 1),
pars_sig_area = list(col = adjustcolor("lightblue", alpha.f = 0.1)),
pars_text_sig_area = list(cex = 1),
...
)
x |
An |
what |
A character vector of
what to include in the
plot. Possible values are
|
text_what |
A character vector
of what numbers to be added as
labels. Possible values are
|
digits |
The number of digits after the decimal that will be used when adding numbers. |
main |
The title of the plot. |
xlab , ylab |
The labels for the horizontal and vertical axes, respectively. |
ci_level |
The level of
confidence of the confidence intervals,
if requested. Default is |
pars_ci |
A named list of
arguments to be passed to |
pars_power_curve |
A named list of
arguments to be passed to |
pars_ci_final_x |
A named list of
arguments to be passed to |
pars_target_power |
A named list
of arguments to be passed to |
pars_final_x |
A
named list of arguments to be passed
to |
pars_final_power |
A
named list of arguments to be passed
to |
pars_text_final_x |
A
named list of arguments to be passed
to |
pars_text_final_power |
A
named list of arguments to be passed
to |
pars_sig_area |
A named list
of arguments to be passed to
|
pars_text_sig_area |
A named list
of arguments to be passed to
|
... |
Optional arguments.
Passed to |
The plot
method of x_from_power
objects currently plots the relation
between estimated power and
the values examined by x_from_power()
.
Other elements
can be requested (see the argument
what
), and they can be customized
individually.
The plot
-method for
n_region_from_power
objects is
a modified version of the plot
-method
for x_from_power
. It plots the
results of two runs of n_from_power()
in one plot. It is otherwise similar
to the plot
-method for x_from_power
.
The plot
-method of x_from_power
returns x
invisibly.
It is called for its side effect.
The plot
-method of n_region_from_power
returns x
invisibly.
It is called for its side effect.
x_from_power()
# Specify the population model
mod <-
"
m ~ x
y ~ m + x
"
# Specify the population values
mod_es <-
"
m ~ x: m
y ~ m: l
y ~ x: n
"
# Generate the datasets
sim_only <- power4test(nrep = 10,
model = mod,
pop_es = mod_es,
n = 100,
do_the_test = FALSE,
iseed = 1234)
# Do a test
test_out <- power4test(object = sim_only,
test_fun = test_parameters,
test_args = list(pars = "m~x"))
# Determine the sample size with a power of .80 (default)
power_vs_n <- x_from_power(test_out,
x = "n",
progress = TRUE,
target_power = .80,
final_nrep = 10,
max_trials = 1,
seed = 2345)
plot(power_vs_n)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.