powPar {sse} | R Documentation |
A function for constructing an object of class powPar
. Such an
object is used for evaluating the user defined “power function” for a parameter range.
All information that is needed for calculating the power should be
provided to this function by making use of the ...
argument.
powPar(n, theta = NA, xi = NA, ...)
n |
A numeric vector, indicating for which sample sizes to evaluate the power function. |
theta |
A numeric vector that will be used for evaluating the
power function. The method |
xi |
A numeric vector that will be used for evaluating the power function.
Since for every element of |
... |
This arguemt is used to provide all parameters needed by the power function for calculating the power. |
An object of class powPar
is used to evaluate the power function for a range of
n
and theta
and optionally for several xi
values.
The user can write a power function and extract the individual
elements using the methods n
, theta
, and xi
.
It is a good practice to include everything that is needed for the calculation, also data sets etc.
To extract the vector of theta, instead of individual values, you can
use the method pp
with the name theta.
For historical reasons: If the argument theta
is NA
the argument
theta.name
(a character) has to be used, to indicate the name of a numeric
vector that was passed to the argument (...
).
The same is true for the argument xi
.
An object of the class powPar
## defining the range of n and theta to be evaluated psi <- powPar(n = seq(from = 20, to = 60, by = 2), theta = seq(from = 0.5, to = 1.5, by = 0.05) ) ## defining a power-function powFun <- function(psi){ return(power.t.test(n = n(psi)/2, delta = theta(psi), sig.level = 0.05)$power) } ## evaluating the power-function for all combinations of n and theta calc <- powCalc(psi, statistic = powFun) ## adding example at theta of 1 and power of 0.9 pow <- powEx(calc, theta = 1) ## drawing the power plot plot(pow, xlab = "Difference", ylab = "Total Sample Size")