# [R] Problem with 2-ways ANOVA interactions

Frodo Jedi frodo.jedi at yahoo.com
Thu Jan 6 00:10:24 CET 2011

```Dear All,
I have a problem in understanding how the interactions of 2 ways ANOVA work,
because I get conflicting results
from a t-test and an anova. For most of you my problem is very simple I am sure.

I need an help with an example, looking at one table I am analyzing. The table
is in attachment
and can be imported in R by means of this command:
scrd<-

This table is the result of a simple experiment. Subjects where exposed to some
stimuli and they where asked to evaluate the degree of realism
of the stimuli on a 7 point scale (i.e., data in column "response").
Each stimulus was presented in two conditions, "A" and "AH", where AH is the
condition A plus another thing (let´s call it "H").

Now, what means exactly in my table the interaction stimulus:condition?

I think that if I do the analysis anova(response ~ stimulus*condition) I will
get the comparison between

the same stimulus in condition A and in condition AH. Am I wrong?

For instance the comparison of stimulus flat_550_W_realism presented in
condition A with the same stimulus, flat_550_W_realism,

presented in condition AH.

The problem is that if I do a t-test between the values of this stimulus in the
A and AH condition I get significative difference,
while if I do the test with 2-ways ANOVA I don´t get any difference.
How is this possible?

Here I put the results analysis

#Here the result of ANOVA:
> fit1<- lm(response ~ stimulus + condition + stimulus:condition, data=scrd)
>#EQUIVALE A lm(response ~ stimulus*condition, data=scrd)
>
> anova(fit1)
Analysis of Variance Table

Response: response
Df Sum Sq Mean Sq F value   Pr(>F)
stimulus             6  15.05   2.509  1.1000   0.3647
condition            1  36.51  36.515 16.0089 9.64e-05 ***
stimulus:condition   6   1.47   0.244  0.1071   0.9955
Residuals          159 362.67   2.281
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

#As you can see the p-value for stimulus:condition is high.

#Now I do the t-test with the same values of the table concerning the stimulus
presented in A and AH conditions:

flat_550_W_realism                         =c(3,3,5,3,3,3,3,5,3,3,5,7,5,2,3)
flat_550_W_realism_AH                   =c(7,4,5,3,6,5,3,5,5,7,2,7,5,   5)

> t.test(flat_550_W_realism,flat_550_W_realism_AH, var.equal=TRUE)

Two Sample t-test

data:  flat_550_W_realism and flat_550_W_realism_AH
t = -2.2361, df = 27, p-value = 0.03381
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.29198603 -0.09849016
sample estimates:
mean of x mean of y
3.733333  4.928571

#Now we have a significative difference between these two stimuli (p-value =
0.03381)

Why I get this beheaviour?

Moreover, how by means of ANOVA I could track the  significative differences
between the stimuli presented in A and AH  condition
whitout doing the t-test?