T-Tests in SAS. One-sample T-Test Matched Pairs T-Test Two-sample T-Test. Introduction. Suppose you want to answer the following questions: Does a new headache medicine provide the typical time to relief of 100 minutes, or is it different?
Matched Pairs T-Test
Suppose you want to answer the following questions:
A one-sample t-test is used to compare a sample to an average or general population. You may know the average height of men in the U.S., and you could test whether a sample of professional basketball players differ significantly in height from the general U.S. population. A significant difference would indicate that basketball players belong to a different distribution of heights than the general U.S. population.
A matched pairs t-test usually involves the same subjects being measured on some factor at two points in time. For example, subjects could be tested on short-term memory, receive a brief tutorial on memory aids, then have their short-term memory re-tested. A significant difference in score (after-before) would indicate that the tutorial had an effect.
A two-sample t-test compares two groups on some factor. For example, one group could receive an experimental treatment and the second group could receive a standard of care treatment or placebo.
Notice that in a two-sample t-test, two distinct groups are being compared, as opposed to the one-sample, where one group is compared to a general average, or a matched-pairs, where only one group is being measured twice.
We want to test whether a new headache medicine provides a relief time equal to or different from the standard of 100 minutes.
We have 10 observations of time to relief. Before we can test our hypothesis, however, we have to test the data for normality.
PROCTTEST DATA = relieftime h0=100;
TITLE'One-sample T-test example‘ ;
The code is telling SAS to run a t-test procedure on the variable relief, and the mean value of relief should be compared to a null value of 100.
After running this program, check your log for errors, then look at the output.
From the SAS output, you can see that the mean relief time of the 10 subjects is 98.1 minutes. The calculated t* value = -1.28, and this test statistic has a p-value of 0.23 (this value is found under the label “Pr > |t|” which stands for the probability of getting a value greater than the absolute value of t*). This is a two-sided test. If this were a one-sided test, you would simply divide the p-value by 2.
If alpha = 0.05, then our p-value is greater than alpha. Therefore, we fail to reject the null hypothesis. The new headache medicine does not provide a different time to relief from 100 minutes.
We want to determine whether a weekend study session improves students’ test scores. Six students are given a math test before the session, then they are re-tested after the weekend training. This is a matched pairs t-test, because the same subjects are being measured before and after some intervention.
Ho: µbefore = µafter
Ha: µbefore ≠ µafter
Again, before we can analyze the data, we have to determine whether we can assume the data come from a normal distribution.
PROCTTESTDATA = study;
TITLE“Example of Program for a Paired T-test” ;
PAIRED before * after;
The code tells SAS to do a paired t-test on the data set study, and it will compare the difference of the means between before and after.
The difference of the mean score (d-bar: before-after) is -7.33; on average the scores before the weekend were lower than the scores after the training session. (If in your paired statement you had typed “after*before” the average difference would be 7.33.)
Is this difference statistically significant? To answer that question, look at the p-value. The t* for the test is -4.35, and the p-value is 0.0074.
If alpha = 0.05, then the p-value < alpha, and we reject the null hypothesis. Therefore, we can conclude that average scores are different before and after the weekend session, and the training does improve test scores.
We want to determine whether a new headache medicine provides a different time to relief than a control medicine. Two groups of five subjects each are either given the treatment or control.
Ho: µ1 = µ2
Ha: µ1≠ µ2
Before we can conduct the two-sample t-test, however, we must determine whether the data come from a normal distribution.
Before you can interpret your test statistic and reach a conclusion, you must determine whether to use the pooled or unpooled variances test statistic. If we can assume the two samples have equal variances, then we use the pooled t*. If, on the other hand, we determine that the two samples have unequal variances, then we must use the unpooled t*.
Ho: σ12 = σ22 vs. Ha: σ12≠σ22
If the p-value > 0.05, we fail to reject the null and can conclude the variances of the two groups are equal; thus we use the pooled variances t*.
If the p-value < 0.05, we reject the null and conclude the variances of the two groups are unequal; thus we use the unpooled variances t*.
You find the F-test under the heading “Equality of Variances” in your SAS output. In our case, the p-value (Pr > F) is 0.03, which is less than 0.05; we cannot assume σ12 = σ22 . We need to use the “t Value” from the “Unpooled” Method.