Procedure demonstrated with an example

  1. The example and data
  2. Setting up the data
  3. Analyzing the date with two paired sample t test
  4. Checking assumption for the method
  5. Reading the output
  6. Interpreting the results

The example and data

A common experiment design is to have a test and control conditions. But comparing with two-sample t test, subjects assigned to each condition are dependent. For example, in an experiment where the response time is measured with or without taking a drug. Each subject could have been measured twice, once in the absence of the drug (control value) and the other after taking the drug (treatment value).

The question is whether the response time differs between the two conditions? The regular t-test cannot be used here since the groups are no longer independent. In stead, a paried t-test is more appropiate.

The data is "response.csv".

Setting up the data

Open the data set from SAS. Or import with the following command.

 
   data response;
	infile "H:\sas\data\response.csv" dlm=',' firstobs=2;
	input control treatment;
    run;

Analyzing the data, syntax

 
   proc ttest data=response;
	title "Paired sample t-test example";
	paired Control * Treatment;
   run;

If there are more than one set of paired values, one can enter several pairs on one "paired" statment. For example, if there are "before1", "after1", "before2" and "after2" and want to compare each pairs, one could use:

   	paried before1 * after1  before2 * after2;

Checking assumptions

Paired sample t-test assumes that

  1. The two groups of data are dependent;
  2. The differences between control and treatment follow normal distribution;

Reading the output

           Paired sample t-test example                                  
                                                                 

                                       The TTEST Procedure

                                Difference:  control - treatment

                  N        Mean     Std Dev     Std Err     Minimum     Maximum

                  6     -7.3333      4.1312      1.6865    -15.0000     -4.0000

                     Mean       95% CL Mean        Std Dev      95% CL Std Dev

                  -7.3333    -11.6687  -2.9979      4.1312      2.5787  10.1322

                                      DF    t Value    Pr > |t|

                                       5      -4.35      0.0074



Interpreting the result

Based on the data, conduct a hypothesis test (with a 0.05 significance level) to see if there is evidence that the response time is significantly different in the treatment than control group. Use α= 0.05. The mean difference is negative (time increased) and equal to -7.333. The p-value is 0.0074, meaning the probability of such a difference is 0.74%. We can state that response times are longer under the drug treatment compared to the control values.

Note that SAS only perform a two side test, meaning the hypothesis is to compare a significant difference between two groups. If one wants to test whether one group is greater(smaller) than the other, p-value must be divided by 2. For example, the p-value/2=0.0074/2=0.00342 < 0.05, hence the concluse for the one side test is still to reject the hypothesis.