BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
emaneman
Pyrite | Level 9

hello all, 

I have the following model

 

PROC MIXED;
CLASS A B;
MODEL DV = A B A*B;
 
A and B both have two levels, so it is a classic 2x2. There is a significant interaction, and the pattern of means shows that it is basically one of the four means that differs from the three others. Can I:
 
1. use contrast or lsmestimate to test that it is indeed the case, and
2. that this specific contrast, which takes the form of 1 1 1 vs -3, accounts for all the variance in the interaction?
 
I remember learning this in graduate school, but it was 25 years ago...
 
Thank you in advance.
 
Eman
1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

Yes, you could use the CONTRAST or LSMESTIMATE statement to make that particular comparison. The LSMESTIMATE statement is easier since you don't have to determine the correct contrast coefficients. But the interaction is really the "difference in difference" (DID) as discussed in this note. This code does both:

proc mixed;
class a b;
model y=a|b;
lsmeans a*b;
lsmestimate a*b 'avg1,2,3 v 4' 1 1 1 -3 /e;
lsmestimate a*b 'did' 1 -1 -1 1 /e;
run;

As for question 2, it might help to use GLM to see the sums of squares. The E options in the LSMESTIMATE statements above show the coefficients of the contrasts defined by the statements. You could use those coefficients in a CONTRAST statement. That is done below in GLM to show the sums of squares of the DID contrast, which is the same as the interaction, and of your contrast.

proc glm;
class a b;
model y=a|b;
lsmeans a*b;
contrast 'avg1,2,3 v 4' a 2 -2 b 2 -2 a*b 1 1 1 -3 /e;
contrast 'did' a*b 1 -1 -1 1 /e;
run;

 

View solution in original post

2 REPLIES 2
StatDave
SAS Super FREQ

Yes, you could use the CONTRAST or LSMESTIMATE statement to make that particular comparison. The LSMESTIMATE statement is easier since you don't have to determine the correct contrast coefficients. But the interaction is really the "difference in difference" (DID) as discussed in this note. This code does both:

proc mixed;
class a b;
model y=a|b;
lsmeans a*b;
lsmestimate a*b 'avg1,2,3 v 4' 1 1 1 -3 /e;
lsmestimate a*b 'did' 1 -1 -1 1 /e;
run;

As for question 2, it might help to use GLM to see the sums of squares. The E options in the LSMESTIMATE statements above show the coefficients of the contrasts defined by the statements. You could use those coefficients in a CONTRAST statement. That is done below in GLM to show the sums of squares of the DID contrast, which is the same as the interaction, and of your contrast.

proc glm;
class a b;
model y=a|b;
lsmeans a*b;
contrast 'avg1,2,3 v 4' a 2 -2 b 2 -2 a*b 1 1 1 -3 /e;
contrast 'did' a*b 1 -1 -1 1 /e;
run;

 

emaneman
Pyrite | Level 9

Thank you Dave!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 2 replies
  • 1365 views
  • 3 likes
  • 2 in conversation