Two Sample T-Test

The t-test assesses whether the means of two groups are statistically different from each other.

Requirements:

Theoretically, the t-test can be used even if the sample sizes are very small, as long as the variables are normally distributed within each group and the variation in the two groups is not reliably different (equal variance).

The normality assumption can be evaluated by looking at the distribution of the data (via histograms, QQ plot) or by performing a normality test.

The equality of variances assumption can be verified with the F test.

If these conditions are not met, then you can evaluate the differences in means between two groups using one of the nonparametric alternatives to the t- test (see nonparametrics two sample t-test).

If equal variance does not meet, Welch's t test, an adaptation of Student's t-test intended for use with two samples having possibly unequal variances can be applied.

Two sides or one side:

The p-level reported with a t-test represents the probability of error associated with rejecting the hypothesis of no difference between the two group when, in fact, the hypothesis is true.

Some researchers suggest that if the difference is in the predicted direction, you can consider only one half (one "tail") of the probability distribution and thus divide the standard p-level reported with a t-test (a "two-tailed" probability) by two. Others, however, suggest that you should always report the standard, two-tailed t-test probability.

Paired data

For paired data, we use paired t-test, which focuses on the difference between the paired data and reports the probability that the actual mean difference is consistent with zero. This comparison is aided by the reduction in variance achieved by taking the differences.

According to the data structure, if data for each pair was represented by two variables in one observation (eg, x1, x2), we can use Empower “create new variables” function to create a new variable which is the difference of these two variables (eg. x=x1-x2); if data for each pair was represented by one variable in two observation, and a pair ID variables was used for identifying the pairs, we can use Empower “Transpose multiple observations to multiple variables” function and then use “create new variables” function to calculate the difference for each pair.  Once the difference for each pair was calculated, we can use “One sample t-test” function to compare the mean difference to zero.

 

Below is the sample input window

 

 

 

Below is the sample output and explanation of the above model:

 

t test comparing means from two samples

 

        Two Sample t-test

 

(1)    T test for SBP comparison smoker (SMOKE.NEW=1) versus non-smoker  (SMOKE.NEW=0)

 

data:  SBP by SMOKE.NEW

t = -4.7558, df = 651, p-value = 2.435e-06

alternative hypothesis: true difference in means is not equal to 0

 

(2)    95% confidence interval of the mean difference

 

95 percent confidence interval:

 -4.919987 -2.044465

 

(3)    Means in each group

 

sample estimates:

mean in group 0 mean in group 1

126.4062    129.8885

 

 

Empower also output following bar plot and box plot to show the means and distribution for each group.