From my model I can get the overall effect of the interaction, but I’m only interested in certain parts of the interaction. I'm wondering if this can be done with ESTIMATE statements.
My data: Each subject was followed for 4 days, and they were randomized to one of two trainers on each day. Subjects were with each trainer at least once, but could have been with one trainer 3 times and the other trainer once (like subject 3). At the end of each day, a test was given.
This is a simplified snapshot of my actual data.
PTNO DAY TRAINER SCORE
1 1 1 50
1 2 2 60
1 3 1 55
1 4 2 45
2 1 2 70
2 2 1 72
2 3 1 90
2 4 2 85
3 1 1 67
3 2 1 79
3 3 1 80
3 4 2 85
4 1 2 62
4 2 1 68
4 3 1 70
4 4 2 72
...
...
From this model I can get the p-value for the interaction of trainer*day, and from LSEMANS / DIFF I can see the comparisons for each trainer and day individually, but I want to know the overall effect of comparing trainers on the same day. Can this be done with estimate statements?
PROC GLIMMIX DATA=ads;
CLASS ptno trainer day;
MODEL score = trainer day trainer*day ;
random int / subject=ptno;
RANDOM day / subject=ptno*trainer type=un residual;
LSMEANS trainer day / cl diff;
LSMEANS trainer*day/ cl slice=day Diff;
Run;
I know how to do an estimate statement to compare trainers on a given day (but this gives same result as LSMEANS anyways so I didn’t include in my model) but I don’t know how to write an estimate statement to compare trainers overall, on the same day (i.e. trainer 1 vs 2 on day 1, and trainer 1 vs 2 on day 2, and trainer 1 vs 2 on day 3, and trainer 1 vs 2 on day 4) Can this be done with estimate statements?
estimate 'Trainer 1 vs 2 on day 2' trainer 1 -1 trainer*day 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
That is exactly what the SLICEDIFF option to the LSMEANS statement in PROC GLIMMIX can give you. Using your code, I would suggest the following change:
PROC GLIMMIX DATA=ads;
CLASS ptno trainer day;
MODEL score = trainer day trainer*day ;
random int / subject=ptno;
RANDOM day / subject=ptno*trainer type=un residual;
LSMEANS trainer day / cl diff;
LSMEANS trainer*day/ cl slicediff=day ;
Run;
Change from the slice=day option to the slicediff=day option.
More complex hypotheses/comparisons can be constructed using the LSMESTIMATE statement, which I think is about a thousand times easier to understand than an ordinary ESTIMATE as you are comparing the already computed lsmeans (or linear functions of the lsmeans) rather than using the ESTIMATE statement to pull appropriate solution terms into a value.
SteveDenham
You probably can work hard enough to get the ESTIMATE statement to do what you want, but it seems to me it would be a lot simpler with the SLICE statement.
For example, directly from the documentation
slice A*B / sliceBy = B;
seems to do what you are asking for.
@tka726 wrote:
... I'm hoping to get a type 3 test/p-value for the overall effect of comparing trainers on the same day. Is that possible?
Is this not the main effect of TRAINER? When main effects are computed in a statistical model with other variables, the effect of other variables is "removed".
@tka726 wrote:
Sorry, I am explaining this poorly. I'm not looking to remove the effect of 'day';
DAY is in the model. In essence anything that the model does for the effect of TRAINER had the effect of DAY removed.
I want to know the effect of 'trainer', but using only comparisons on the same day ... i.e. not considering trainer 1 on day 3 vs trainer 2 on day 1.
So is what you want this: the effect of trainer on DAY 1 (plus) the effect of trainer on DAY 2 (plus) the effect of trainer on DAY 3 (plus) the effect of trainer on DAY 4?? I use (plus) because I'm not really sure what mathematical operation you are talking about, it may not be addition, but I don't really know what operation you want there.
Or if you don't want something like what I just described, then you have to be much more precise and specific in your description.
That is exactly what the SLICEDIFF option to the LSMEANS statement in PROC GLIMMIX can give you. Using your code, I would suggest the following change:
PROC GLIMMIX DATA=ads;
CLASS ptno trainer day;
MODEL score = trainer day trainer*day ;
random int / subject=ptno;
RANDOM day / subject=ptno*trainer type=un residual;
LSMEANS trainer day / cl diff;
LSMEANS trainer*day/ cl slicediff=day ;
Run;
Change from the slice=day option to the slicediff=day option.
More complex hypotheses/comparisons can be constructed using the LSMESTIMATE statement, which I think is about a thousand times easier to understand than an ordinary ESTIMATE as you are comparing the already computed lsmeans (or linear functions of the lsmeans) rather than using the ESTIMATE statement to pull appropriate solution terms into a value.
SteveDenham
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.