1
votes

I’m learning about PROC MIXED in SAS to understand how to use Random and Repeated statement, using simple repeated data (pre, post). I checked lots of similar questions, but I’m still a beginner, so have two below questions. Please give me some advice.

1.About paired test, there would be two cases, subject (id) as “fixed effect” or as “random effect” in the following simple repeated data (pre, post). I often see it as “fixed effect”, generally speaking, that’s the theory? Why?

2.In the following case, putting “random” and “repeated” together would be not correct? How should I do?

2021.3.21 I edited the following program. I got the result “random=repeated” like that. But I couldn’t understand about the “random+repeated”. It would be also correct? Anyway, id is no variance in this case, so, it wouldn’t affect the model?

/* data */
data dt00;
 input id x y;
 cards;
1 1 2
2 1 2
3 1 3
4 1 3
5 1 3
6 1 4
7 1 4
1 2 15
2 2 9
3 2 13
4 2 10
5 2 7
6 2 11
7 2 5 
;
run;

title "random";
proc mixed data = dt00 covtest;* REML ;
 parms/nobound;
 class x id;
 model y = x / ddfm = kr2;
 random id;
*        Estimate    SE       Z      Pr Z;
*id      -1.3333   2.5757  -0.52    0.6047;
*Residual 7.5000   4.3301   1.73    0.0416;
* DF    F      Pr F;
* 6    22.87   0.0031;

title "repeated";
proc mixed data = dt00 covtest;* REML ;
 class x id;
 model y = x / ddfm = kr2 ;
 repeated x / subject = id type = cs; 
run;
*        Estimate    SE       Z      Pr Z; 
*id      -1.3333   2.5757  -0.52    0.6047;
*Residual 7.5000   4.3301   1.73    0.0416; 
* DF    F      Pr F;
* 6    22.87   0.0031;

title "random + repeated";
proc mixed data = dt00 covtest;* REML ;
 parms/nobound;
 class x id;
 model y = x / solution ddfm = kr2 ;
 random id;
 repeated x / subject = id type = cs; 
run;
*        Estimate    SE       Z      Pr Z; 
*id       0.1117   2.5757   0.04    0.4827; 
*CS      -1.4451   0        .       .; 
*Residual 7.5000   4.3301   1.73    0.0416; 
* DF    F      Pr F;
* 6    22.87   0.0031;

title "fixed effect";
proc mixed data = dt00 covtest;* REML ;
 class x id;
 model y = x id / solution ddfm = kr2 ;
run;
*        Estimate    SE       Z      Pr Z; 
*Residual 7.5000   4.3301   1.73    0.0416 ;
* DF    F      Pr F;
* 6    22.87   0.0031;

title "paired ttest";
proc sort data = dt00; by id; run;
proc transpose data = dt00 out = dt01;
 by id;
 id x;
 var y;
run;
data dt02; set dt01; diff = _2 - _1; run;

proc ttest data = dt02 alpha = 0.05;
 paired _1 * _2;
run;
* DF    T      Pr T;
* 6   -4.78   0.0031;

1

1 Answers

2
votes

When you specify RANDOM patient, you are saying that the covariance between patients (different people) is 0. (This is fine if there is not another grouping that would make patients more similar).

In PROC MIXED, You can include patient as a fixed factor, but that usually uses most of the degrees of freedom. If instead, you treat patient as a random factor, you are still controlling for each person, but you use less degrees of freedom.

If there is extra non-independence (or even non-constant variance), you can still estimate those non-zero covariances by adding a Repeated statement. Therefore, it’s fine to include a REPEATED statement along with a RANDOM statement, and is sometimes necessary to have a good fitting model. The repeated statement controls the covariance structure of the residuals for a single subject.

And everyone starts somewhere, so don't sweat it.