BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pronabesh
Fluorite | Level 6

Hi SAS Community,

I am analyzing a single factor within subject design dataset where

1. subjects were measured at baseline and follow-up (2 time points only). Here is a small subset of the data, where test is 1=baseline and 2=follow-up.

data within_subject;

input id test outcome;

datalines;

1 1 3

1 2 2

2 1 4

2 2 3

3 1 9

3 2 7

4 1 4

4 2 2

5 1 1

5 2 0.5

;

run;

I used proc mixed to test for baseline to post difference (syntax show below)

proc mixed data=within_subject;

class test;

model outcome=test;

repeated /subject=id type=ar(1);

lsmeans test;

run;

Since this data has only 2 time points, my understanding is that I will get the same result by using a paired t-test. Of course for paired t-test I will need to structure my data as a wide datafile instead of a person-time datafile as shown below:

data t_test;

input id test1 test2;

datalines;

1 3 2

2 4 3

3 9 7

4 4 2

5 1 0.5

;

run;

The paired t-test code is shown below:

proc ttest data=t_test;

      paired test1*test2;

   run;

I got the same result using both codes but just wanted to confirm with the SAS experts that both approach have the same correlation structure.

Best,

Pronabesh

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

Yes, you should get the same.  You could use type=un in proc mixed if you want unequal variances and a covariance for the pre and post.  It doesn't matter in proc ttest, as the variable that is actually fit is the difference, and the assumptions all fall on the difference.

Steve Denham

View solution in original post

3 REPLIES 3
SteveDenham
Jade | Level 19

Yes, you should get the same.  You could use type=un in proc mixed if you want unequal variances and a covariance for the pre and post.  It doesn't matter in proc ttest, as the variable that is actually fit is the difference, and the assumptions all fall on the difference.

Steve Denham

pronabesh
Fluorite | Level 6

Thank you for confirming that Steve. I got the same results using unstructured and first order auto-regressive. Is it correct to assume that with 2 time points ar(1) has the same correlation structure as un?

As always, that you so much for your help.

Best,

Pronabesh

SteveDenham
Jade | Level 19

With two time points, and no other factors, either random or fixed, un and ar(1) will give the same results.  Note that the entries in the matrix may not be the same, but the two matrices are congruent (I think that is the correct word for matrices that are the same except for a scalar factor).

Steve Denham

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1801 views
  • 3 likes
  • 2 in conversation