powCalc {sse}R Documentation

Power calculation

Description

The user-defined power-function provided as statistic will be evaluated for the whole range of n, theta, and xi as specified in the powPar-object.

Usage

powCalc(object, statistic, n.iter = NA, cluster = FALSE)

Arguments

object

An object of class powPar.

statistic

A function that takes an object of class powPar as argument. Ideally this is also the only argument. The function should return a vector of numeric values or a vector of logicals, depending on the type. See Details.

n.iter

A number specifying how often the power-function is evaluated.

cluster

Still experimental! This argument can be logical, indicating if the library parallel should be used or not, or numeric. In the latter case the number is passed as integer to the function makeCluster from library parallel. The default is FALSE.

...

Not used so far.

Details

If the statistic does not return the power (a numeric value between 0 and 1) but returns a logical (TRUE or FALSE) the argument n.iter is expected to be an integer. The statitic will then be evaluated n.iter-times and the proportion of successes will be interpreted as the power.

Value

An object of class powCalc.

See Also

The function merge will, together with an object of class powEx form an object of class power

Examples

## defining the range of n and theta to be evaluated
psi <- powPar(theta = seq(from = 0.5, to = 1.5, by = 0.1),
              n = seq(from = 20, to = 60, by = 2),
              muA = 0,
              muB = 1)

## defining a power-function     
powFun <- function(psi){
  power.t.test(n = n(psi)/2,
               delta = pp(psi, "muA") - pp(psi, "muB"),
               sd = theta(psi)
               )$power
}

## evaluating the power-function for all combinations of n and theta
calc <- powCalc(psi, powFun)

[Package sse version 0.7-11 Index]