Algorithms (Pair-Sample T-Test)

This function is used to test whether or not the difference of the two paired sample means equals to \mu_d\,\!(i.e. to test whether or not their means are equal, you can just test whether or not their difference is 0, \mu_1-\mu_2=\mu_d=0\,\! ). And the hypotheses take the form:

H_0:\mu_1-\mu_2=\mu_d\,\! vs H_1:\mu_1-\mu_2 \ne \mu_d Two Tailed

H_0:\mu_1-\mu_2 \le \mu_d vs H_1:\mu_1-\mu_2 > \mu_d Upper Tailed

H_0:\mu_1-\mu_2 \ge \mu_d vs H_1:\mu_1-\mu_2 < \mu_d Lower Tailed

Test Statistics

Consider two samples x_1\,\!andx_2\,\! which assumed to be drawn from normal populations are equal size, we can define the paired difference as:


And we have the mean paired difference is:

\bar{d}=\frac{1}{n}\sum_{i=1}^n d_i

Then we can compute the standard deviation for the difference between paired data points s_d\,\!, with v = n-1 degrees of freedom as:


And then we can calculate the test statistic by:


Compare the t value with the critical value and we will reject H_0\,\! if:

Two tailed test: |t| > t_{\sigma/2}\,\!;

Upper tailed test: t > t_\sigma\,\!;

Lower tailed test: t < -t_\sigma\,\!;

The p-value will also be compared with a user-defined significance level,,\sigma\,\!, which commonly 0.05 is used. And the null hypothesisH_0\,\! will be rejected if p < \sigma\,\!.

Confidence Intervals

The confidence interval for paired sample mean difference (\mu_1 - \mu_2)\,\! is:

Null Hypothesis Confidence Interval
H_0:\mu_1-\mu_2=\mu_d\,\! \left[\bar{d} - t_{\alpha/2}\frac{s_d}{\sqrt{n}}, \bar{d} + t_{\alpha/2}\frac{s_d}{\sqrt{n}}\right]
H_0:\mu_1-\mu_2 \le \mu_d \left[\bar{d} - t_{\alpha}\frac{s_d}{\sqrt{n}}, \infty\right]
H_0:\mu_1-\mu_2 \ge \mu_d \left[-\infty, \bar{d} + t_{\alpha}\frac{s_d}{\sqrt{n}}\right]

Power Analysis

The power of a two sample t-test is a measurement of its sensitivity. Detail algorithm about calculating power please read the help of Power and Sample Size.