powCalc: Power calculation

Description Usage Arguments Details Value Examples

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

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

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

Examples

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

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

Related to powCalc in sse...