powPar: Constructing an object of class 'powPar'.

Description Usage Arguments Details Value Examples

View source: R/power.R

Description

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 (e.g. a pilot data set) should be provided by making use of the ... argument.

Usage

1
powPar(n, theta = NA, xi = NA, ...)

Arguments

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 theta can be used within the power function to extract the elements of this vector one by one.

xi

A numeric vector that will be used for evaluating the power function. Since for every element ofxi an individuall sensitivity plot has to be constructed, the length of the xi vector is usually short.

...

This arguemt is used to provide additional parameters needed by the power function for calculating the power. This parameters can be extracted using the function pp.

Details

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 functions n, theta, xi and pp.

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 = 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.

Value

An object of the class powPar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## 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")

sse documentation built on May 19, 2021, 5:08 p.m.

Related to powPar in sse...