A Comprehensive Guide to Performing Paired T-Test Using SAS

The paired sample t-test,  is also called as dependent sample t-test, it is a statistical method used to check that the mean difference between two randomly selected samples is zero. This test is performed when the subjects are marked twice so that we get two sets of observations. Examples where the test can be applied is case control and measure control studies. Let's take an example of testing the employee or the workers before and after implementing the programs and therefore can check the variation/ deviation by performing paired t test.

Hypothesis:

Like all the test available T-test also has two competing for the null hypothesis and the alternative hypothesis. The null hypothesis remains the same for each type of alternative hypothesis. The paired sample t-test hypotheses are formally defined below:

Null hypothesis (H0) : mean difference= 0

Alternative hypothesis(H1) : mean  difference greater or lesser than 0.

The alternative hypothesis assumes that the true mean is not equal to 0.

The goal of the testing is to make data more consistent.

ASSUMPTIONS: 

The paired sample t-test have many assumptions. We  know that T-test are relatively strong of all the test to measure the variation or degree of deviation from the assumptions to check the quality/reliability of the outputs. The paired T-test has four foremost assumptions:

All dependent variable should be continuous either interval or ratio.

All the observations should be independent of each other.

The dependent variable should not contain any outliers.

The dependent variable should be normally distributed.

PROCEDURE :

The paired sample t-test is summed up in the following four steps:

The four steps are as follows: 

Sample mean & sample standard deviation is calculated.

The value of the statistic is computed.

Probability value is calculated after looking into tables.

This value is calculated by comparing t to a t-distribution with (n − 1) degrees of freedom.

 

Paired T-test using SAS:

Performing paired T - test in SAS, we need to compare variables Z1 and Z2 that are measured on the same people, you can first create the difference , and then  perform a one sample t-test of:

DT pdt; set original;

d=Z1-Z2;

run;

-- COMMAND -- proc ttest DT=pdt h0=0;

var d;

run;

Hypotheses:

H0: The average difference in cholesterol is 0 from 1952 to 1962

H1: The average difference in cholesterol is not equal to  0 from 1952 to 1962.

Now, let's create the difference in cholesterol - dchl

data DT; set dixonmasy;

dchl=chl62-chl52;

run;

proc ttest data=dm; 

Setting a proper suitable title for the table you want to display

--title 'Paired t-test, using dchl variable';

var dchl;

run;

Again, we reject the null hypothesis as the p value <0.05 and state that we have significant evidence that cholesterol levels from 1952 to 1962, with 95% confidence limits of (-91.6, -48.0).

Alternatively, we can test the null hypothesis using  proc means:

 proc means data=pdt n mean std t prt clm;

title 't-test with proc means';

var dchl;

run;

the prt functions gives the associated p-value. 

The clm  function produces a 95% confidence interval for the mean. 

 dchl, the null hypothesis is that the mean difference is zero  

proc means DT=dm n mean std t prt clm;

title 'Paired t-test with proc means';

var dchl;

Run;

The third method and the final method is to use the original data with the paired function in proc t-test:

 proc ttest data=original;

title 'Paired t-test with proc ttest, paired statement';

paired z1*z2;

run;

The output from proc function is identical to dchl; 

Example:

 proc ttest data=work.dm;

title 'Paired t-test with proc ttest, paired statement';

paired chl62*chl52;

run;

 OUTCOMES

We conducted a paired t-test to determine whether, on average, to check the change cholesterol level  from 1952 to 1962. 

H0: There is no change, on average, in cholesterol from 1952 to 1962

H1: There is an average change in cholesterol from 1952 to 1962, i.e., H0: μd ≠ 0 .

Level of significance: α=0.05

Cholesterol deteriorated between 1952 and 1962 by an aggregate of 69.8. The 95% confidence interval  is (-91.6,-48.0)

The test statistic value is t = -6.70, with 19 degrees of freedom, and p < 0.0001. As  the p-value <0.05,  rejecting the null hypothesis and hence we can say that there is no difference in cholesterol level from 1952- 1962

Conclusion: There is significant evidence that cholesterol decreased from 1952 to 1962 (p <0.0001).the cholesterol levels in 1962 was 69.8 mg/dl  in 95 % confidence interval (48.0, 91.6) which is lower than the cholesterol levels in 1952.

Leave a Reply