Learn R Programming

sse (version 0.7-17)

update: Updating a powCalc or a power object.

Description

A function for updating an existing object of class '>powCalc or '>power.

Usage

update(object, ...)

Arguments

object

An object of class '>powCalc or '>power.

...

The following elements (slots) of the object can be updated:

n.iter

A number indicating the number of iterations used to dertermine the power if the calcualation is based on resampling. The existing iterations will be kept. n.iter indicates the number of iterations after evaluation, therefore n.iter has to be equal or larger than the existing number of iterations.

n

A vector with numbers for evaluating the power. New elements will be evaluated and existing elements reused. If some elements of the original are not part of n they will be ommitted.

theta

see n for details.

xi

see n for details.

statistic

A function of an object of class psi. If a new statistic is provided all elements will be evaluated again.

Value

An object of class '>powCalc.

See Also

powCalc for geneating new objcets of class '>powCalc.

Examples

Run this code
# NOT RUN {
## 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)

## updating by using additional elements for "n"
calc2 <- update(calc, n = seq(from = 20, to = 90, by = 2))

## adding example at theta of 1 and power of 0.9
pow <- powEx(calc2, theta = 1, power = 0.9)

## drawing the power plot with 3 contour lines
plot(pow,
     xlab = "Standard Deviation",
     ylab = "Total Sample Size",
     at = c(0.85, 0.9, 0.95))
# }

Run the code above in your browser using DataLab