Professional Documents
Culture Documents
T-Tests in SAS: 1. One-Sample T-Test 2. Matched Pairs T-Test 3. Two-Sample T-Test
T-Tests in SAS: 1. One-Sample T-Test 2. Matched Pairs T-Test 3. Two-Sample T-Test
1. One-sample T-Test
2. Matched Pairs T-Test
3. 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?
• Does a weekend training session have an effect
on performance on an exam?
• Does a new headache medicine differ in time to
relief from a standard headache treatment?
T-tests can be used to answer all of these
questions. There are three main types of
t-tests:
1. One-sample
2. Matched Pairs
3. Two-sample
One-Sample T-test
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.
Matched Pairs T-test
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.
Two-Sample T-test
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.
One-sample T-test in SAS
We want to test whether a new headache
medicine provides a relief time equal to or
different from the standard of 100 minutes.
Ho: µ=100
Ha: µ≠100
We have 10 observations of time to relief.
Before we can test our hypothesis,
however, we have to test the data for
normality.
Type the following code in SAS:
DATA relieftime;
INPUT relief;
DATALINES;
90
93
93
99
98
100
103
104
99
102
;
PROC UNIVARIATE DATA = relieftime normal plot;
VAR relief;
histogram relief / midpoints = 80 to 120 by 5 normal;
RUN;
Tests for Normality
• The histogram shows most observations
falling at the peak of the normal curve.
• The box-plot shows that the mean falls on
the median (*--+--*), indicating no skewed
data.
• The formal tests of normality in the output
are non-significant, indicating these data
come from a normal distribution.
• We can assume the data are normally
distributed and proceed with the one-
sample t-test.
SAS Code for a One-Sample T-test
PROC TTEST DATA = relieftime h0=100;
TITLE 'One-sample T-test example‘ ;
VAR relief;
RUN;
P
80
e
r
60
c c
e
40
n
t
20
0
100
P
80
e
r
60
t c
e
40
n
t
20
t i me
SAS Code for Two-Sample T-test
PROC TTEST DATA = response;
TITLE 'Two-sample T-test example';
class group;
var time;
RUN;