Compute the power of the one- or two- sample t test, or determine parameters to obtain a target power.

1 2 3 4 5 |

`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` |
string specifying the type of t test. Can be abbreviated. |

`alternative` |
one- or two-sided test. Can be abbreviated. |

`strict` |
use strict interpretation in two-sided case |

`tol` |
numerical tolerance used in root finding, the default providing (at least) four significant digits. |

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.

If `strict = TRUE`

is used, the power will include the probability of
rejection in the opposite direction of the true effect, in the two-sided
case. Without this the power will be half the significance level if the
true difference is zero.

Object of class `"power.htest"`

, a list of the arguments
(including the computed one) augmented with `method`

and
`note`

elements.

`uniroot`

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

Peter Dalgaard. Based on previous work by Claus EkstrĂ¸m

`t.test`

, `uniroot`

1 2 3 | ```
power.t.test(n = 20, delta = 1)
power.t.test(power = .90, delta = 1)
power.t.test(power = .90, delta = 1, alternative = "one.sided")
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.

Close