What is t-test an why we do it?

A t-test is an analysis of two populations means through the use of statistical examination; a t-test with two samples is commonly used with small sample sizes, testing the difference between the samples when the variances of two normal distributions are not known.

A t-test looks at the t-statistic, the t-distribution and degrees of freedom to determine the probability of difference between populations; the test statistic in the test is known as the t-statistic. To conduct a test with three or more variables, an analysis of variance (ANOVA) must be used. [1]

## Statistical Analysis of the T-Test

The formula used to calculate the test is a ratio: The top portion of the ratio is the easiest portion to calculate and understand, as it is simply the difference between the means or averages of the two samples. The lower half of the ratio is a measurement of the dispersion, or variability, of the scores. The bottom part of this ratio is known as the standard error of the difference. To compute this part of the ratio, the variance for each sample is determined and is then divided by the number of individuals the compose the sample, or group. These two values are then added together, and a square root is taken of the result.

Read more: T-Test http://www.investopedia.com/terms/t/t-test.asp#ixzz4TY1g1WT2

### Two-Sample *t*-test

The two-sample *t*-test is a parametric test that compares the location parameter of two independent data samples.

The test statistic is

t=¯x−¯yGs2xn+s2ym,

where ¯x and ¯y are the sample means, *s _{x}* and

*s*are the sample standard deviations, and

_{y}*n*and

*m*are the sample sizes.

In the case where it is assumed that the two data samples are from populations with equal variances, the test statistic under the null hypothesis has Student’s *t* distribution with *n* + *m* – 2 degrees of freedom, and the sample standard deviations are replaced by the pooled standard deviation

s=G(n−1)s2x+(m−1)s2yn+m−2.

In the case where it is not assumed that the two data samples are from populations with equal variances, the test statistic under the null hypothesis has an approximate Student’s *t* distribution with a number of degrees of freedom given by Satterthwaite’s approximation. This test is sometimes called Welch’s *t*-test.

In Matlab how you can calculate with example:

## Syntax

**t-Test for Equal Means Without Assuming Equal Variances**

Test the null hypothesis that the two data vectors are from populations with equal means, without assuming that the populations also have equal variances.

**[h,p] = ttest2(x,y,'Vartype','unequal')
**

h = 0 p = 0.9867

The returned value of `h = 0`

indicates that `ttest2`

does not reject the null hypothesis at the default 5% significance level even if equal variances are not assumed.

Continue reading “Statistical analysis : Two-sample t-test”