Advanced tables and statistics > Z, T and F tests > T-tests and F-tests > Two-sample T-test
 
Two-sample T-test
Quick reference
To request a two-sample T-test, type:
stat=t2
on the tab statement.
More information
The two-sample T statistic is a table-level statistic. It may be used to test whether the means of a numeric variable or factor are the same in two separate samples or sub-samples, or to make a number of such comparisons, pair-wise, between more than two samples. For example, you might want to compare the length of time per day, on average, spent watching broadcast television by owners of video recorders, with the same figure for non-owners.
This test is produced by a stat=t2 option on the tab statement. The column axis defines the groups to be compared. These must be mutually exclusive. The row axis must include a base element, a mean (n12) and a standard deviation (n17) — these require fac= options on the axis elements or an n25 element with the inc= option. For more information about these elements, see Statistical functions and totals.
Notes
This statistic calculates T values using rows of means and standard deviations. Each mean in the n12 row is compared against every other mean value in that row. A triangular matrix of T values and significance levels is produced with values for each pair of means. It is labeled with the text ‘T TEST – TYPE 2’.
The column axis must define groups of respondents which are mutually exclusive: for example, age groups or sex. If there is more than one set of mutually exclusive elements in the axis the test will still be printed, but the comparisons between elements which are not mutually exclusive are meaningless and should be ignored. For example, if the column axis contains both sex and age breakdowns, the comparison between, say, ‘Female’ and ‘Age 18–25’ should be ignored since some respondents may be women and aged 18–25.
The value of T is zero if there is no difference in the data, otherwise the sign of T will reflect the sign (direction) of the difference.
The calculation for T subtracts the first mean from the second rather than usual method of subtracting the second mean from the first.
Elements whose cells are all zero are excluded from this test. You can suppress them with the nz option if you want.
This test uses the sum of totalizable rows and the input to the means and standard deviation in its calculations.
If the axis being tested contains fac= and inc=, Quantum scans backwards through the axis from the stat=t1 element and uses whichever of the two it finds first; that is, whichever of fac= or inc= occurs closest to, but still before, the statistical element.
Example
Take this Quantum program:
tab hours vcr;stat=t2
ttlQ15 Hours per week spent watching TV
ttlBase: All Respondents
l hours
col 156;Base;Under 5 hours;%fac=1+1;5–6 hours;
+7–10 hours;11–15 hours;16+ hours
n03
n12Mean;dec=3 n17Std. Deviation;dec=3
l vcr

col 155;Base;Has no video;Owns a video
g Base Does not own a Owns a video
g video recorder recorder
p x x
This produces:
015 Hours per week spent watching TV
Base: All Respondents
                   Base      Does not own a        Owns a video
                             video recorder            recorder
Base                305               181                 124
Under 5 hours        45                24                  21
5-6 hours            93                50                  43
7-10 hours           62                40                  22
11-15 hours          51                31                  20
16+ hours            54                36                  18

Mean              2.921             3.028               2.766
Std. Deviation    1.330             1.335               1.314

T TEST - TYPE 2

                           Owns a video
Has no video               -1.691
                            0.091
This example shows a significant result at the 9.1% significance level.
In this example, the column headings at the top of the main table are different from those in the statistical table. Those at the top of the main table are defined by the g statements in the axis, whereas those in the statistical table are taken from the col statement. The reason for this is that the full element text, as shown on the g statements is too long to fit into the 15 characters allocated to the statistical columns.
For general information on the size and layout of statistical output, see Axis-level statistics.
See also
T-tests and F-tests