ttest: t-test

ttestR Documentation

t-test

Description

Performs a t-test on each row/column of the input matrix.

Usage

row_t_equalvar(x, y, null = 0, alternative = "two.sided", conf.level = 0.95)

col_t_equalvar(x, y, null = 0, alternative = "two.sided", conf.level = 0.95)

row_t_welch(x, y, null = 0, alternative = "two.sided", conf.level = 0.95)

col_t_welch(x, y, null = 0, alternative = "two.sided", conf.level = 0.95)

row_t_onesample(x, null = 0, alternative = "two.sided", conf.level = 0.95)

col_t_onesample(x, null = 0, alternative = "two.sided", conf.level = 0.95)

row_t_paired(x, y, null = 0, alternative = "two.sided", conf.level = 0.95)

col_t_paired(x, y, null = 0, alternative = "two.sided", conf.level = 0.95)

Arguments

x

numeric matrix.

y

numeric matrix for the second group of observations.

null

true values of the means for the null hypothesis. A single number or numeric vector with values for each observation.

alternative

alternative hypothesis to use for each row/column of x. A single string or a vector with values for each observation. Values must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence levels used for the confidence intervals. A single number or a numeric vector with values for each observation. All values must be in the range of [0:1] or NA.

Details

Functions to perform one sample and two sample t-tests for rows/columns of matrices. Main arguments and results were intentionally matched to the t.test() function from default stats package. Other arguments were split into separate functions:

row_t_onesample(x) - one sample t-test on rows. col_t_onesample(x) - one sample t-test on columns.

Results should be the same as running t.test(x) on every row (or column) of x.

row_t_equalvar(x, y) - two sample equal variance t-test on rows. col_t_equalvar(x, y) - two sample equal variance t-test on columns.

Results should be the same as running t.test(x, y, var.equal=TRUE) on every row (or column) of x and y.

row_t_welch(x, y) - two sample t-test with Welch correction on rows. col_t_welch(x, y) - two sample t-test with Welch correction on columns.

Results should be the same as running t.test(x, y) on every row (or column) of x and y.

row_t_paired(x, y) - two sample paired t-test on rows. col_t_paired(x, y) - two sample paired t-test on columns.

Results should be the same as running t.test(x, y, paired=TRUE) on every row (or column) of x and y.

Value

a data.frame where each row contains the results of a t.test performed on the corresponding row/column of x. The columns will vary depending on the type of test performed.

They will contain a subset of the following information:
1. obs.x - number of x observations
2. obs.y - number of y observations
3. obs.tot - total number of observations
4. obs.paired - number of paired observations (present in x and y)
5. mean.x - mean estiamte of x
6. mean.y - mean estiamte of y
7. mean.diff - mean estiamte of x-y difference
8. var.x - variance estiamte of x
9. var.y - variance estiamte of y
10. var.diff - variance estiamte of x-y difference
11. var.pooled - pooled variance estimate of x and y
12. stderr - standard error
13. df - degrees of freedom
14. statistic - t statistic
15. pvalue - p-value
16. conf.low - lower bound of the confidence interval
17. conf.high - higher bound of the confidence interval
18. mean.null - mean of the null hypothesis
19. alternative - chosen alternative hypothesis
20. conf.level - chosen confidence level

Note

For a marked increase in computation speed turn off the calculation of confidence interval by setting conf.level to NA.

Author(s)

Karolis Koncevičius

See Also

t.test()

Examples

X <- iris[iris$Species=="setosa",1:4]
Y <- iris[iris$Species=="virginica",1:4]
col_t_welch(X, Y)

# same row using different confidence levels
col_t_equalvar(X[,c(1,1,1)], Y[,c(1,1,1)], conf.level=c(0.9, 0.95, 0.99))


matrixTests documentation built on Oct. 6, 2023, 1:07 a.m.