I run a mixed model according to the PROC MIXED step in SAS. My code is like this below:
proc mixed data=inds;
class subject arm(ref='C组(对照组)') ;
model aval =base arm avisitn arm*avisitn /s ;
random subject ;
repeated / subject=subject ;
lsmeans arm / diff cl at avisitn=0;
lsmeans arm / diff cl at avisitn=1;
lsmeans arm / diff cl at avisitn=2;
ods output diffs=diff ;
run;Then I change the variable in the model option at the left side of the equation like this:
proc mixed data=inds;
class subject arm(ref='C组(对照组)') ;
model chg =base arm avisitn arm*avisitn /s;
random subject ;
repeated / subject=subject ;
/* lsmeans arm / pdiff cl at avisitn=0;*/
lsmeans arm / pdiff cl at avisitn=1;
lsmeans arm / pdiff cl at avisitn=2;
ods output diffs=diff1 ;
run;I just change the variable from the value at each time point to the change from baseline. Then I find that the Differences of Least Squares Means is the same. I do not know how this works. Can anyone tell me why?
A explanation from the model and a suggestion from the code so that I can see why I get the same results.
@XixiHaha wrote:
I just change the variable from the value at each time point to the change from baseline. Then I find that the Differences of Least Squares Means is the same. I do not know how this works. Can anyone tell me why?
A explanation from the model and a suggestion from the code so that I can see why I get the same results.
It would help if you showed us the two outputs so we can see for ourselves what you are seeing.
Nevertheless, if all you did was change from the value at each time point to the change from baseline, then differences of Least Squares Means won't change. This is simple algebra. You have just subtracted a constant value from the values. Your original differences were
(Mean of AVAL at level 1) – (Mean of AVAL at level 2) <== first formula
and now they are
((Mean of AVAL at level 1) – baseline) – ((Mean of AVAL at level 2) – baseline) <= second formula
Homework assignment for you ... show that the result of the first formula is exactly equal to the result of the second formula using algebra
@XixiHaha wrote:
I just change the variable from the value at each time point to the change from baseline. Then I find that the Differences of Least Squares Means is the same. I do not know how this works. Can anyone tell me why?
A explanation from the model and a suggestion from the code so that I can see why I get the same results.
It would help if you showed us the two outputs so we can see for ourselves what you are seeing.
Nevertheless, if all you did was change from the value at each time point to the change from baseline, then differences of Least Squares Means won't change. This is simple algebra. You have just subtracted a constant value from the values. Your original differences were
(Mean of AVAL at level 1) – (Mean of AVAL at level 2) <== first formula
and now they are
((Mean of AVAL at level 1) – baseline) – ((Mean of AVAL at level 2) – baseline) <= second formula
Homework assignment for you ... show that the result of the first formula is exactly equal to the result of the second formula using algebra
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.