Description Usage Arguments Details Value Note Author(s) References See Also Examples

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

1 2 3 |

`n` |
number of observations (per group) |

`delta` |
(expected) true difference in means |

`sd1` |
(expected) standard deviation of group 1 |

`sd2` |
(expected) standard deviation of group 2 |

`sig.level` |
significance level (Type I error probability) |

`power` |
power of test (1 minus Type II error probability) |

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

,
`sd1`

, `sd2`

and `sig.level`

must be passed as `NULL`

,
and that parameter is determined from the others. Notice that the last three
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.

The function and its documentation was adapted from `power.t.test`

implemented by Peter Dalgaard and based on previous work by Claus Ekstroem.

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

Matthias Kohl Matthias.Kohl@stamats.de

S.L. Jan and G. Shieh (2011). Optimal sample sizes for Welch's test under
various allocation and cost considerations. *Behav Res Methods*, 43,
4:1014-22.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ```
## identical results as power.t.test, since sd = sd1 = sd2 = 1
power.welch.t.test(n = 20, delta = 1)
power.welch.t.test(power = .90, delta = 1)
power.welch.t.test(power = .90, delta = 1, alternative = "one.sided")
## sd1 = 0.5, sd2 = 1
power.welch.t.test(delta = 1, sd1 = 0.5, sd2 = 1, power = 0.9)
## empirical check
M <- 10000
ps <- numeric(M)
for(i in seq_len(M)){
x <- rnorm(15, mean = 0, sd = 0.5)
y <- rnorm(15, mean = 1, sd = 1.0)
ps[i] <- t.test(x, y)$p.value
}
## empirical power
sum(ps < 0.05)/M
``` |

```
Two-sample Welch t test power calculation
n = 20
delta = 1
sd1 = 1
sd2 = 1
sig.level = 0.05
power = 0.8689528
alternative = two.sided
NOTE: n is number in *each* group
Two-sample Welch t test power calculation
n = 22.0211
delta = 1
sd1 = 1
sd2 = 1
sig.level = 0.05
power = 0.9
alternative = two.sided
NOTE: n is number in *each* group
Two-sample Welch t test power calculation
n = 17.84713
delta = 1
sd1 = 1
sd2 = 1
sig.level = 0.05
power = 0.9
alternative = one.sided
NOTE: n is number in *each* group
Two-sample Welch t test power calculation
n = 14.53583
delta = 1
sd1 = 0.5
sd2 = 1
sig.level = 0.05
power = 0.9
alternative = two.sided
NOTE: n is number in *each* group
[1] 0.9068
```

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.