Advanced tables and statistics > Z, T and F tests > T-tests and F-tests > One-sample and paired T-test
 
One-sample and paired T-test
Quick reference
To request a one-sample or paired T-test, type:
stat=t1[, element_text] [;options]
as an element in the axis.
More information
The one-sample T statistic is an axis-level statistic. It may be used to test whether the mean of a numeric variable or factor (fac=) is significantly different from zero or some other specified value. It may also be used to test for differences between means measured on matched samples (the paired T-test) — for example, between the means of two variables both obtained from the same sample of respondents (see the Notes below).
For example, you might want to test whether respondents spent the same length of time per day, on average, watching broadcast television before and after purchasing a video recorder. To request a one-sample or paired T-test you should include stat=t1 element in the axis at the point at which you want the statistic displayed. To define the variable or factor to be tested and perform the necessary statistical summations, you will need either a fac= option on each basic count element in the axis, or an n25 element in the axis with the inc= option.
Notes
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.
It is not necessary to use n12 (mean), n17 (standard deviation) or n19 (standard error) elements in the axis as these are automatically calculated by the stat=t1 element. However, you will probably want to print at least the mean using n12 so that you can see the values which are being tested by the T statistics.
In a weighted run, the compiler inserts an unweighted n15 with the option nontot in the axis so that the T-test can be calculated using unweighted figures.
The simplest use of the one-sample T-test is when testing whether the mean of a variable already coded in columns of the data is zero. In this case you need only specify the required columns on the inc= option of the n25 statement. For example:
n25;inc=c(120,122);c=c119'1'
stat=t1,One-Sample T-test
There may be occasions when you want to use a one-sample T-test on values which are not the same as those in the data. You can create these values using fac= on n01 or col elements. For more information about fac=, see Statistical functions and totals.
To test whether a mean may be different from some non-zero value, subtract that value from each data value. In other words, to test whether the mean number of visits to a supermarket is equal to 2, you actually test whether the mean of (number of visits to supermarket – 2) is equal to 0. For example:
n25;inc=c(120,122)–2;c=c119'1'
stat=t1,One-Sample T-test
To make a paired test between two data values, test whether the difference between them is zero. For example, to make a test of the difference between the data values in columns 120–122 and in columns 123–125 you would write:
n25;inc=c(123,125)–c(120,122);c=c119'1'
stat=t1,Paired T-test
If the calculation of the values to be used by the T-test is more complicated than this, you might need to write an edit to calculate the values. An example which has the same effect as that shown above is:
/*Named variable to store mean difference
int mdiff 1s
ed
mdiff = c(123,125) – c(120,122)
end
         .
         .
n25;inc=mdiff;c=c119'1'
stat=t1,Paired T-test
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: One-sample T-test
Respondents have rated a particular brand of washing powder on a scale of 1 (Excellent) to 5 (Very poor) and you want to test whether the rating was, on average, satisfactory. The Quantum program:
tab rating age
ttlQ4Rating for Washo Soap Powder
ttlBase: All Respondents
l rating
col 45;Base;Excellent;%fac=2–1;Very Good;Satisfactory;Poor;Very poor
n03
n12Mean Rating;dec=3
n19Std. Error;dec=3
stat=t1,T-Values
l age
col 9;Base;18–30;31–44;45–54;55+
produces:
Q4 Rating for Washo Soap Powder
Base: All Respondents
                   Base     18-30     31-44     45-54       55+
Base                340        65        93        76        70
Excellent            95        21        20        28        16
Very Good            21         4         5         7         5
Satisfactory         70        15        21        15        19
Poor                 69        14        21        17        17
Very poor            49        11        21         9        13
Mean Rating       0.145     0.154     0.129     0.368    -0.086
Std. Error        0.085     0.186     0.156     0.168     0.169
T-Values           1.71      0.83      0.83      2.19     -0.51
                  0.087     0.409     0.408     0.029     0.611
These results show that, at the 90% confidence level, there is some evidence that the overall mean rating differs from zero (the exact significance level is 8.7%). The most highly significant result is among the 45-54 age group, in which the mean score differs from zero at the significance level of 2.9%.
Example: Paired T-test
For a comparison of the differences between means of two ratings, both by the same respondents, use a paired T-test:
tab ratdif age
ttlComparison of Ratings for Suds
ttlBase: All Respondents
l rating
col 46;Base;hd=Rating Having Seen Advertising;
+Excellent;Very Good;Satisfactory;Poor;Very poor
n03
col 56;Base;hd=Rating Having Tried Product;
+Excellent;Very Good;Satisfactory;Poor;Very poor
n03
n25;inc=c46–c56
n12Mean Difference;dec=3
n19Std. Error;dec=3
stat=t1,T-Values;dec=3
l age
col 9;Base;18–30;31–44;45–54;55+
produces:
Comparison of Ratings for Suds
Base: All Respondents
                   Base     18-30     31-44     45-54       55+
Base                340        65        93        76        70
Rating Having Seen Advertising
Excellent            95        21        20        28        16
Very Good            21         4         5         7         5
Satisfactory         70        15        21        15        19
Poor                 69        14        21        17        17
Very poor            49        11        21         9        13
Rating Having Tried Product
Excellent            85        20        24        24        17
Very Good            55        11        15        12        17
Satisfactory         65        10        23        19        13
Poor                 68        17        19        16        16
Very poor            31         7        12         5         7
Mean Difference   0.168     0.154     0.086     0.079    -0.386
Std. Error        0.102     0.221     0.181     0.208     0.218
T-Values          1.641     0.697     0.474     0.380     1.773
                  0.101     0.486     0.635     0.704     0.076
The highest significant result is in the 55+ age group. You can have confidence at the 92.4% level that for this age group the mean product ratings differ after trying the product.
See also
T-tests and F-tests