power.t.test {ctest} | R Documentation

## Power calculations for one and two sample t tests

### Description

Compute power of test, or determine parameters to obtain target power.

### Usage

    power.t.test(n=NULL, delta=NULL, sd=1, sig.level=0.05, power=NULL,
                 type=c("two.sample", "one.sample", "paired"),
                 alternative=c("two.sided", "one.sided"))

### Arguments

`n` | Number of observations (per group)
`delta` | True difference in means
`sd` | Standard deviation
`sig.level` | Significance level (Type I error probability)
`power` | Power of test (1 minus Type II error probability)
`type` | Type of t test
`alternative` | One- or two-sided test

### Details

Exactly one of the parameters `n`, `delta`, `power`, `sd`, and `sig.level` must be passed as NULL, and that parameter is determined from the others. Notice that the last two have non-NULL defaults so NULL must be explicitly passed if you want to compute them.

### Value

Object of class `"power.htest"`, a list of the arguments (including the computed one) augmented with `method` and `note` elements.

### Note

`uniroot` is used to solve power equation for unknowns, so you may see errors from it, notably about inability to bracket the root when invalid arguments are given.

### Author(s)

Peter Dalgaard. Based on previous work by Claus Ekstrøm

### See Also

`t.test`, `uniroot`

### Examples

     power.t.test(n=20, delta=1)
     power.t.test(power=.90, delta=1)
     power.t.test(power=.90, delta=1, alt="one.sided")