Description Usage Arguments Value References Examples
A t-test is a statistical hypothesis test in which the test statistic follows a Student's t distribution if the null hypothesis is true and follows a non-central t distribution if the alternative hypothesis is true. The t test can assess the statistical significance of (1) the difference between population mean and a specific value, (2) the difference between two independent populaion means, and (3) difference between means of matched paires.
1 2 3 4 |
n1 |
Sample size of the first group. |
n2 |
Sample size of the second group if applicable. |
d |
Effect size. See the book by Cohen (1988) for details. |
alpha |
Significance level chosed for the test. It equals 0.05 by default. |
power |
Statistical power. |
type |
Type of comparison ( |
alternative |
Direction of the alternative hypothesis ( |
tol |
tolerance in root solver. |
An object of the power analysis.
Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd Ed). Hillsdale, NJ: Lawrence Erlbaum Associates.
Zhang, Z., & Yuan, K.-H. (2018). Practical Statistical Power Analysis Using Webpower and R (Eds). Granger, IN: ISDSA Press.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #To calculate the power for one sample t-test given sample size and effect size:
wp.t(n1=150, d=0.2, type="one.sample")
# One-sample t-test
#
# n d alpha power
# 150 0.2 0.05 0.682153
#
# URL: http://psychstat.org/ttest
#To calculate the power for paired t-test given sample size and effect size:
wp.t(n1=40, d=-0.4, type="paired", alternative="less")
# Paired t-test
#
# n d alpha power
# 40 -0.4 0.05 0.7997378
#
# NOTE: n is number of *pairs*
# URL: http://psychstat.org/ttest
#To estimate the required sample size given power and effect size for paired t-test :
wp.t(d=0.4, power=0.8, type="paired", alternative="greater")
# Paired t-test
#
# n d alpha power
# 40.02908 0.4 0.05 0.8
#
# NOTE: n is number of *pairs*
# URL: http://psychstat.org/ttest
#To estimate the power for balanced two-sample t-test given sample size and effect size:
wp.t(n1=70, d=0.3, type="two.sample", alternative="greater")
# Two-sample t-test
#
# n d alpha power
# 70 0.3 0.05 0.5482577
#
# NOTE: n is number in *each* group
# URL: http://psychstat.org/ttest
#To estimate the power for unbalanced two-sample t-test given sample size and effect size:
wp.t(n1=30, n2=40, d=0.356, type="two.sample.2n", alternative="two.sided")
# Unbalanced two-sample t-test
#
# n1 n2 d alpha power
# 30 40 0.356 0.05 0.3064767
#
# NOTE: n1 and n2 are number in *each* group
# URL: http://psychstat.org/ttest2n
#To estimate the power curve for unbalanced two-sample t-test given a sequence of effect sizes:
res <- wp.t(n1=30, n2=40, d=seq(0.2,0.8,0.05), type="two.sample.2n",
alternative="two.sided")
res
# Unbalanced two-sample t-test
#
# n1 n2 d alpha power
# 30 40 0.20 0.05 0.1291567
# 30 40 0.25 0.05 0.1751916
# 30 40 0.30 0.05 0.2317880
# 30 40 0.35 0.05 0.2979681
# 30 40 0.40 0.05 0.3719259
# 30 40 0.45 0.05 0.4510800
# 30 40 0.50 0.05 0.5322896
# 30 40 0.55 0.05 0.6121937
# 30 40 0.60 0.05 0.6876059
# 30 40 0.65 0.05 0.7558815
# 30 40 0.70 0.05 0.8151817
# 30 40 0.75 0.05 0.8645929
# 30 40 0.80 0.05 0.9040910
#
# NOTE: n1 and n2 are number in *each* group
# URL: http://psychstat.org/ttest2n
#To plot a power curve:
plot(res, xvar='d', yvar='power')
|
Loading required package: MASS
Loading required package: lme4
Loading required package: Matrix
Loading required package: lavaan
This is lavaan 0.6-7
lavaan is BETA software! Please report any bugs.
Loading required package: parallel
Loading required package: PearsonDS
One-sample t-test
n d alpha power
150 0.2 0.05 0.682153
URL: http://psychstat.org/ttest
Paired t-test
n d alpha power
40 -0.4 0.05 0.7997378
NOTE: n is number of *pairs*
URL: http://psychstat.org/ttest
Paired t-test
n d alpha power
40.02908 0.4 0.05 0.8
NOTE: n is number of *pairs*
URL: http://psychstat.org/ttest
Two-sample t-test
n d alpha power
70 0.3 0.05 0.5482577
NOTE: n is number in *each* group
URL: http://psychstat.org/ttest
Unbalanced two-sample t-test
n1 n2 d alpha power
30 40 0.356 0.05 0.3064767
NOTE: n1 and n2 are number in *each* group
URL: http://psychstat.org/ttest2n
Unbalanced two-sample t-test
n1 n2 d alpha power
30 40 0.20 0.05 0.1291567
30 40 0.25 0.05 0.1751916
30 40 0.30 0.05 0.2317880
30 40 0.35 0.05 0.2979681
30 40 0.40 0.05 0.3719259
30 40 0.45 0.05 0.4510800
30 40 0.50 0.05 0.5322896
30 40 0.55 0.05 0.6121937
30 40 0.60 0.05 0.6876059
30 40 0.65 0.05 0.7558815
30 40 0.70 0.05 0.8151817
30 40 0.75 0.05 0.8645929
30 40 0.80 0.05 0.9040910
NOTE: n1 and n2 are number in *each* group
URL: http://psychstat.org/ttest2n
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.