# how to do a contrast analysis for an interaction between two within subjects effects?

#### marie

##### New Member
Hello!

I have a quite simple data pattern but find it hard to test a specific contrast I expected. I have 2 within subjects factors, each with two levels. Let's call them reward (high vs. low) and task pressure (high vs. low), while the dependent variable is performance (see the example GLM below). I expect that only one cell will deviate from all the rest, which do not differ from each other. Specifically, I expect that performance will be great when people get a high reward and are under high task pressure, but performance will be poor in all other conditions. Thus, I would like to test the specific contrast (3 -1 -1 -1).

I know how to do a similar contrast analysis within the levels of one variable, but not two as in this case.
I also know how to test the simple effect of one factor (reward) within one level of the other (high pressure) (I usually do this using a MANOVA syntax). Two of these simple effects analyses would give me the same information, but with less power, so that's not quite what I want.

Can somebody help me with this very specific contrast? I'd appreciate it very much if somebody could give me a useful SPSS syntax for this problem! I have looked in my standard statistics books and on the internet but all I ever come across are simple effects or contrasts within one factor.

Thank you very much in advance!

Marie

GLM reward1relax reward1rockon reward2relax reward2rockon
/WSFACTOR= reward 2 Polynomial pressure 2 Polynomial
/METHOD=SSTYPE(3)
/PRINT = descriptives
/CRITERIA=ALPHA(.05)
/WSDESIGN= reward pressure reward*pressure .

#### Jake

Re: how to do a contrast analysis for an interaction between two within subjects effe

For brevity let's call your conditions A through D, where A is the condition you predict to be different from the others. You can compute a difference score for each participant equal to 3*A - B - C - D. Then you just do a one-sample t-test on this difference score, testing against 0. (You can divide the difference scores by 4 first if you want it back in the original metric, but this won't affect the results of your test.) This is equivalent to the ANOVA contrast that you want. Unfortunately I don't use SPSS so I can't help you much with the syntax.

Edit: By the way, I just noticed that you refer to this contrast as an "interaction" in your thread title... this is not technically speaking an interaction.

Last edited:

#### marie

##### New Member
Re: how to do a contrast analysis for an interaction between two within subjects effe

Thank you! Why is it not technically an interaction?

#### Jake

Re: how to do a contrast analysis for an interaction between two within subjects effe

In colloquial terms, an interaction asks the question "To what extent does the effect of factor A on the dependent variable depend on what level factor B is at?" More concretely, let's call the two factors in your example A (consisting of levels a1 and a2) and B (consisting of b1 and b2). So our 4 groups are {a1b1; a1b2; a2b1; a2b2}. Another way to phrase the colloquial interaction question in this context would be "is there a different a1 - a2 difference at b1 compared to b2?" This phrasing makes it clear that the interaction is essentially asking about a difference in differences. A contrast to test the two-way interaction here would be {+1; -1; -1; +1}. We can see this because if we multiply these weights by the cell scores and then rearrange things slightly, we get
1*a1b1 - 1*a1b2 - 1*a2b1 + 1*a2b2
= (a1b1 - a2b1) - (a1b2 - a2b2).
So this contrasts asks whether the a1 - a2 difference at b1 differs from the a1 - a2 difference at b2, which we noted earlier is the interaction question.

The contrast you mentioned in the op, {3; -1; -1; -1}, asks something completely different. It asks whether the a1b1 score differs from the mean of the other 3 scores. This cannot be conceptualized as a question about different differences or whether the effect of one factor depends on the level of another factor, so it is not an interaction.

#### noetsi

##### Fortran must die
Re: how to do a contrast analysis for an interaction between two within subjects effe

You can address it with a linear contrast (comparing one level to the mean of several others is commonly done) but as jake says that is a totally different issue than interaction. If the impact of an independent variable on a dependent variable does not change with another IV, there is no interaction.

#### marie

##### New Member
Re: how to do a contrast analysis for an interaction between two within subjects effe

Thank you both!
I understand the theory, but I still don't know how to solve it technically. I thought about Jakes suggestion to compute difference scores. But to find proof for this contrast, I'd have to find in a t test that the difference score does NOT differ from zero, right? That's a very unconventional test and I don't think it would convince any reviewers.
And as for the linear contrast, I know how to do that in a GLM for one factor. But even though my contrast is technically not an interaction, I'd have to enter both factors, so the interaction term, in a GLM to specify for which factors I want to test a linear trend. But that doesn't work. Any suggestions for how to solve this technically?

#### Jake

Re: how to do a contrast analysis for an interaction between two within subjects effe

But to find proof for this contrast, I'd have to find in a t test that the difference score does NOT differ from zero, right? That's a very unconventional test and I don't think it would convince any reviewers.
It's not unconventional. As I mentioned earlier, it is completely mathematically equivalent to what you asked for. You can call it a t-test on a funny-looking difference score, or you can call it a within-subject ANOVA contrast; these are in a very literal sense two different names for the same thing. I urge you to play around with the two approaches and see the equivalence for yourself.

And as for the linear contrast, I know how to do that in a GLM for one factor. But even though my contrast is technically not an interaction, I'd have to enter both factors, so the interaction term, in a GLM to specify for which factors I want to test a linear trend. But that doesn't work. Any suggestions for how to solve this technically?
Doesn't work? If I'm understanding you correctly, you're saying that the SPSS developers did not decide to include this pretty basic capability in their menu system. So instead it looks like you'll have to define the new difference score variable by hand (e.g., filling in the column of contrast weights in Excel--our maybe you can do this in the SPSS data viewer), and then do your usual t-test routine on that new variable.

#### marie

##### New Member
Re: how to do a contrast analysis for an interaction between two within subjects effe

Hi,

I know the t-test does essentially the same as the anova, but in your example I'd have to go for a non-significant test, right?

It indeed doesn't work to specify your own contrast for an interaction term in a GLM just like for any single factor. But I guess I can just as easily call it one factor with 4 levels and that should give me the result I'm looking for!

#### helicon

##### Member
Re: how to do a contrast analysis for an interaction between two within subjects effe

Marie, you can test custom hypotheses in SPSS using the /lmatrix (for between-subjects) and /mmatrix (for within-subjects) subcommands.

An example of its use:

GLM reward1relax reward1rockon reward2relax reward2rockon
/WSFACTOR=reward 2 Polynomial pressure 2 Polynomial
/METHOD=SSTYPE(3)
/PRINT = descriptives
/CRITERIA=ALPHA(.05)
/WSDESIGN=reward pressure reward*pressure
/MMATRIX 'custom test label here'
reward1relax -1 reward1rockon -1 reward2relax -1 reward2rockon 3.

http://publib.boulder.ibm.com/infocenter/spssstat/v20r0m0/topic/com.ibm.spss.statistics.help/syn_glm_lmatrix.htm
http://listserv.uga.edu/cgi-bin/wa?A2=ind0001&L=spssx-l&P=21344
http://www.nicholasgibson.com/lmatrix.html

Last edited:

#### Jake

Re: how to do a contrast analysis for an interaction between two within subjects effe

I know the t-test does essentially the same as the anova, but in your example I'd have to go for a non-significant test, right?
No, you're still testing for a significant difference like you would normally do.

But I guess I can just as easily call it one factor with 4 levels and that should give me the result I'm looking for!
Yes, exactly!

#### marie

##### New Member
Re: how to do a contrast analysis for an interaction between two within subjects effe

Thank you all again! You all helped me a lot!

helicon, the mmatrix command was a great suggestion! treating the 2 factors like one with 4 levels of course gives the same result, but very handy to know for the future!

#### jdavidc

##### New Member
Re: how to do a contrast analysis for an interaction between two within subjects effe

Hi folks, I know this is an older thread (circa 2012) but I wanted to respond to Marie and Jake's conversation, and particularly Jake's statements about Marie's within-subjects example not being an interaction. I believe this might be a mistake. Marie was arguing that if one cell in a 2X2 within-subjects design was different from the others, this would be an interaction-- which was disputed by some folks. I've been thinking about a similar issue with some of my colleagues and found this relevant thread-- so I'm grateful you all have been thinking about these issues.

My view is that Marie's example is a form of an interaction, called an ordinal (or spreading) interaction in the literature. To apply this to my particular case, I'm interested in comparing two groups from baseline to post-treatment (a 2X2 mixed design-- one between subjects variable with two levels, and one within-subjects variable time with two levels). In my case, I'm predicting that my two groups at baseline will be equivalent, and that only my treatment group at post-test will increase (relative to no change in my control group). Essentially, I'm hypothesizing that my treatment group at post-treatment will be higher than the three other means which are not hypothesized to be different. This is a classic example of an ordinal interaction, and predicts that only one cell in this 2X2 design will be different from the others. I believe this is the same pattern Marie had predicted in her study.

The second consideration is how one might set up contrast weights in their general linear models to test this a priori hypothesized ordinal interaction. Standard practice suggests you first test for an overall significant 2-way interaction F stat, then go in an interpret your interaction pattern. But in my case with a predicted ordinal interaction effect, I see merit in using contrast weights much like what Marie offered in her initial comment (-1/3 -1/3 1 -1/3) [with the "1" referring to my treatment group at post-test)].

I'm curious what the group (if there still is one!) thinks about these comments, warm wishes.

#### hlsmith

##### Less is more. Stay pure. Stay poor.
Re: how to do a contrast analysis for an interaction between two within subjects effe

I think part of the issue may be the OP provided what they thought the code may be throwing off others. When I read the first thread I felt this was an interaction that may fall under "epistasis ". Ex, you may need two genes turned on to get the phenotype (trait) turned on. Here perhaps there is no effect unless both variables are high.

#### Jake

Re: how to do a contrast analysis for an interaction between two within subjects effe

I think we are in agreement that, for the example marie discussed and for your example, testing a contrast of the form [1, -1/3, -1/3, -1/3] (or equivalently, as I wrote it back then, [3, -1, -1, -1]) would be valuable. In fact this contrast seems to be the key prediction of both of your studies.

With that said, I stand by my earlier comments that this contrast is not equivalent to an interaction...however...while in 2012 I apparently said that this contrast was "completely different" from an interaction, today I would soften this statement: although the proposed contrast is not statistically equivalent to an interaction (ordinal or disordinal), it is fairly strongly related (in a statistical sense) to the interaction contrast. Put another way, the two contrasts provide some overlapping information and some non-overlapping information. The most straightforward way to see this is just to compute the squared correlation of the two contrasts, which gives the proportion of shared variance between them:
$$\text{cor}([3,-1,-1,-1],[1,-1,-1,1])^2=0.577^2=1/3$$
So the variance explained by these two contrasts overlaps by one-third, but two-thirds of the variance explained by each contrast is unique. Hope this makes sense.

#### hlsmith

##### Less is more. Stay pure. Stay poor.
Re: how to do a contrast analysis for an interaction between two within subjects effe

The inflation of the 1,1 cell is an interaction in my opinion. The contrast approach may be unconventional, but can get at this. I liked the ordinal visualization. However Davids question feel like the mechanism may be different.

Jake can you expand on your corr statement, I am home alone with my young daughters and can quite get a free moment to review it or figure it out. I also think I can contribute an approach on this topic but wont get a free moment until tonight!

#### hlsmith

##### Less is more. Stay pure. Stay poor.
Re: how to do a contrast analysis for an interaction between two within subjects effe

The null hypothesis for an interaction is B3 = 0, now it is up to the investigator on how they want to test it.

#### Jake

Re: how to do a contrast analysis for an interaction between two within subjects effe

I don't really know how else I can explain this...the interaction effect in a 2-by-2 factorial design is defined as g1 - g2 - g3 + g4, where g1-g4 are the 4 group/cell means. A test of this interaction effect is achieved by testing the [1, -1, -1, 1] contrast (or an equivalent contrast) as part of a complete, orthogonal set of contrast codes. Any contrast that is NOT statistically equivalent to that contrast--by definition--does not test the interaction! End of story.

#### hlsmith

##### Less is more. Stay pure. Stay poor.
Re: how to do a contrast analysis for an interaction between two within subjects effe

There is also combinotorical partitioning modeling, which I am not sure about with 2 variables.

Perhaps MDR could be used as well, but not familiar with its intricacies, especially with 2 variables.

#### jdavidc

##### New Member
Re: how to do a contrast analysis for an interaction between two within subjects effe

Hi folks, I'm delighted to see that Jake and others are still around! Thanks for your comments. I think there's agreement that if one cell is different than the other three cells in these designs, this is indeed an interaction. I also don't dispute Jake's point that the interaction contrasts [-1 -1 3 1] vs [-1 1 1 -1] are not going to be equivalent, although with some overlapping variance. But this doesn't clarify the principle question about how one goes about testing for an a priori hypothesized ordinal interaction, where you are predicting that one cell (my treatment group at post-treatment) will be different from the other three cells which are hypothesized to be equivalent (e.g., in a 2 X 2 design). To elaborate further, the [-1 1 1 -1] contrast weights, in my particular case, would be testing a different type of interaction pattern, namely that the treatment group would increase from baseline to post-treatment whereas my control group would decrease from baseline to post-treatment. I'm predicting no change in my control group, not a decrease. Thoughts?

#### hlsmith

##### Less is more. Stay pure. Stay poor.
Re: how to do a contrast analysis for an interaction between two within subjects effe

So you have the interaction turned into a categorical variable, with groups 00, 01, 10, 11, and above is your contrast? I am terrible with contrasts:

-1, -1, 3, 1, seems off since they are suppose to sum to "0" correct. If you thought the direction should change, you can still look at it with all "-", you would just need to look at the sign on the test statistic.

-1, 1, 1, -1, seems like the 2 vs 1 and 4; 3 vs 1 and 4?