Learn R Programming

matrixTests (version 0.2.2)

ttest: 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)

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

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.

Author

Karolis Koncevičius

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.

See Also

Examples

Run this code
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))

Run the code above in your browser using DataLab