Resolving interaction between factors

94 views
Skip to first unread message

Narendra Kumar

unread,
Feb 12, 2017, 6:44:00 AM2/12/17
to ez4r
Hi all,

I am a research scholar in the field of Neurocognition of Language Comprehension. I am new to 'R' and very new to 'ez'. I performed repeated measure ANOVA and observed interaction between lateral electrodes and factors. Can you guide us the "command lines" to resolve the interaction between the ROI and factors ?

Regards,
Narendra

















/

Mike Lawrence

unread,
Feb 12, 2017, 12:07:30 PM2/12/17
to ez...@googlegroups.com
You'll have to pose a more specific question, ideally including code to demonstrate something you're confused about.


--
You received this message because you are subscribed to the Google Groups "ez4r" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Narendra Kumar

unread,
Feb 14, 2017, 6:38:29 AM2/14/17
to ez4r
Hi,

I resolved the interaction between the factors and ERP data. But I am stuck in resolving interaction between factors in my behavioural data.

Let me illustrate the problem.

My experiment is designed with three factors A (x,y), B (u, v), C (m, n) and each with two levels resulting in eight conditions. 
   
My data is in the following format
     Subj, Item, A, B, C, Ans_Judgement

I performed repeated measure ANOVA

data_answ<- aggregate(data$ans_judg, by=list(Subject=data$subj, A=data$A,B=data$B, C=data$C), mean, na.rm=T)
sub_ans_anova = ezANOVA(data = data_answ, dv = x,  wid = Subject, within = .(A, B, C))

The result showed an interaction effect of B*C. So I resolved the interaction as below:

Resolve interaction between B*C for Ans_Judg by B: B1=u

data_B1 <- data[data$B == "u",]
data_B2 <- data[data$B == "v",]


data_B1_Ans-Jud<- aggregate(data_B1$ans_judg, by=list(subj=data_B1$subj, A=data_B1$A,B=data_B1$B, C=data_C1$C), mean, na.rm=T)
B-C_anova = ezANOVA(data = data_B1_Ans-Jud[data_B1_Ans-Jud$B=="u",], dv = x,  wid = subj, within = .(A, C))

The result showed interaction effect of A*C here again, so I run the following code:

Resolve interaction between A*C for Ans_Judg by B1=u and A1= x:
 
data_B1_A1 <- data_B1[data_B1$A == "x",]
data_B1_A2 <- data_B1[data_B1$A == "y",]


data_B1_A1_Ans-Jud<- aggregate(data_B1_A1$ans_judg, by=list(subj=data_B1_A1$subj, A=data_B1_A1$A, B=data_B1_A1$B, C=data_B1_A1$C), mean, na.rm=T)
B-C-A1_anova = ezANOVA(data = data_B1_A1_Ans-Jud[data_B1_A1_Ans-Jud$A == "x",], dv = x,  wid = subj, within = C)
print(SF_Str_C1_anova)

Here the result showed the following error:

Warning: You have removed one or more Ss from the analysis. Refactoring "subj" for ANOVA.
Warning: You have removed one or more levels from variable "C". Refactoring for ANOVA.
Error in temp[[i]] : subscript out of bounds

Kindly help me in getting out of here. I will be thankful for the same.

Regards,
Narendra



Mike Lawrence

unread,
Feb 14, 2017, 11:58:59 AM2/14/17
to ez...@googlegroups.com
What does the plot produced by the following look like?

ezDesign(
    data = data_B1_A1_Ans-Jud[data_B1_A1_Ans-Jud$A == "x",]
    , x = x
    , y = subj
    , col = C
)


--
Mike Lawrence
Graduate Student
Department of Psychology & Neuroscience
Dalhousie University

~ Certainty is (possibly) folly ~

Narendra Kumar

unread,
Feb 14, 2017, 7:17:16 PM2/14/17
to ez4r

Hi,

it showed the following error:

Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?

I want to clarify one thing.  
ezDesign(
    data = data_B1_A1_Ans-Jud[data_B1_A1_Ans-Jud$A == "x",]
    , x = x     
    , y = subj
    , col = C
)

Here in x = x; do you refer x to the 'mean value' obtained  in
 data_B1_A1_Ans-Jud<- aggregate(data_B1_A1$ans_judg, by=list(subj=data_B1_A1$subj, A=data_B1_A1$A, B=data_B1_A1$B, C=data_B1_A1$C), mean, na.rm=T)
To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+uns...@googlegroups.com.

Mike Lawrence

unread,
Feb 14, 2017, 7:23:47 PM2/14/17
to ez...@googlegroups.com
Oops, try this:

ezDesign(
    data = data_B1_A1_Ans-Jud[data_B1_A1_Ans-Jud$A == "x",]
    , x = C 
    , y = subj
)



To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+unsubscribe@googlegroups.com.

Mike Lawrence

unread,
Feb 14, 2017, 7:26:45 PM2/14/17
to ez...@googlegroups.com
A strange thing is that I don't understand how you can have a data frame named "data_B1_A1_Ans-Jud" as the "-" should be causing an error

Narendra Kumar

unread,
Feb 14, 2017, 8:41:56 PM2/14/17
to ez4r
Hi Mike,

The data framed was named as "data_B1_A1_AJ". I wrote it just for the understanding. I run the earlier code sent by you also, but it gave the following error. 

ezDesign(
+     data = data_B1_A1_AJ[data_B1_A1_AJ$A == "x",]
+     , x = C 
+     , y = subj
+ )
Error in eval(expr, envir, enclos) : object 'Count' not found
In addition: Warning messages:
1: In max(counts$Count) : no non-missing arguments to max; returning -Inf
2: In min(counts$Count) : no non-missing arguments to min; returning Inf
3: In min(counts$Count) : no non-missing arguments to min; returning Inf
4: In max(counts$Count) : no non-missing arguments to max; returning -Inf
5: In min(counts$Count) : no non-missing arguments to min; returning Inf
6: In max(counts$Count) : no non-missing arguments to max; returning -Inf

Mike Lawrence

unread,
Feb 14, 2017, 8:47:18 PM2/14/17
to ez...@googlegroups.com
What happens if you do:

  with(
    data_B1_A1_AJ[data_B1_A1_AJ$A == "x",]
    , table( C , subj )
  )

?

To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+unsubscribe@googlegroups.com.

Narendra Kumar

unread,
Feb 14, 2017, 8:53:11 PM2/14/17
to ez4r
It showed the following

        subj
    C 202 204 205 208 209 210 211 213 214 215 218 219 220 221 222 223 224 225 226 227 228
    x   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    y   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0

Mike Lawrence

unread,
Feb 14, 2017, 8:56:18 PM2/14/17
to ez...@googlegroups.com
That's showing you that there is no data left in the data frame when you try to subset down to only those rows for which the entry in the "A" column is the value "x".


To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+unsubscribe@googlegroups.com.

Narendra Kumar

unread,
Feb 14, 2017, 8:59:47 PM2/14/17
to ez4r
Hi,

However to resolve the interaction between A*C for Ans_Judg by B1=u and A1= x:   

I run the following code:

print(summary ( aov(x ~ C + Error(subj/C), data=data_B1_A1_AJ)))

it showed the  following result:

Error: subj
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals 20 0.3417 0.01709               

Error: subj:C
          Df Sum Sq Mean Sq F value   Pr(>F)    
C         1  4.801   4.801   399.8 1.08e-14 ***
Residuals 20  0.240   0.012                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

The result showed a significant effect of factor C.

Mike Lawrence

unread,
Feb 14, 2017, 9:13:34 PM2/14/17
to ez...@googlegroups.com
Maybe we should step back a bit. It sounds like you have a design with 3 within-subject variables, "A", "B", & "C", and you've observed an interaction between "B" & "C" as well as between "A" & "C". Usually the next step would be to show these interactions visually, with something like:

  ezPlot(
    data = data_answ
    , dv = x
    ,  wid = Subject
    , within = .(B, C)
    , x = B
    , split = C
  )

and:

  ezPlot(
    data = data_answ
    , dv = x
    ,  wid = Subject
    , within = .(A, C)
    , x = A
    , split = C
  )

There's certainly no point in doing any further ANOVAs.



--
You received this message because you are subscribed to the Google Groups "ez4r" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+unsubscribe@googlegroups.com.

Narendra Kumar

unread,
Feb 14, 2017, 10:10:22 PM2/14/17
to ez...@googlegroups.com
I have a repeated measure within-subject design with three factors and each with two levels: A (x,y); B (u,v) and C(m,n).  After performing ANOVA I observed an interaction effect of B*C. Further, I resolved the interaction effect B*C by B1(u) and observed again an another interaction effect A*C for B1(u). Now, here I am trying to resolve the further interaction effect A*C by B1(u) and A1(x). 

Note: The interaction effect A*C was observed when interaction effect B*C was resolved by B1(u).

So, I am stuck here when using ezANOVA. 

One more thing I want to ask, looking at the description given above, do you think that I am performing  ANOVA (aov) correctly ? If yes, then why ezANOVA is not giving the result.

I plotted the graphs, it shows interaction effect between B*C but not between A*C, it is because the interaction effect A*C was observed when the interaction B*C was resolved by B1 (u).

--
You received this message because you are subscribed to a topic in the Google Groups "ez4r" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ez4r/kkB9BV5Ri28/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ez4r+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Research Scholar
Department of Humanities and Social Sciences
Indian Institute of Technology Ropar
Punjab, India - 140001 
Contact No.:- +91-8968945650
Social Networking Sites: - Facebook; Researchgate

 

Mike Lawrence

unread,
Feb 15, 2017, 5:52:51 AM2/15/17
to ez...@googlegroups.com
What do you mean when you say that you "resolved" a given interaction? 

To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+uns...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "ez4r" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ez4r/kkB9BV5Ri28/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ez4r+uns...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Research Scholar
Department of Humanities and Social Sciences
Indian Institute of Technology Ropar
Punjab, India - 140001 
Contact No.:- +91-8968945650
Social Networking Sites: - Facebook; Researchgate

 

--
You received this message because you are subscribed to the Google Groups "ez4r" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+uns...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--

Narendra Kumar

unread,
Feb 15, 2017, 11:30:26 AM2/15/17
to ez...@googlegroups.com
Hello Mike,

For details, kindly see section 4 'results' of the attached article.

Regards,
Narendra

On Wed, Feb 15, 2017 at 4:22 PM, Mike Lawrence <mike....@gmail.com> wrote:
What do you mean when you say that you "resolved" a given interaction? 
To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "ez4r" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ez4r/kkB9BV5Ri28/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ez4r+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Research Scholar
Department of Humanities and Social Sciences
Indian Institute of Technology Ropar
Punjab, India - 140001 
Contact No.:- +91-8968945650
Social Networking Sites: - Facebook; Researchgate

 

--
You received this message because you are subscribed to the Google Groups "ez4r" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--

--
Mike Lawrence
Graduate Student
Department of Psychology & Neuroscience
Dalhousie University

~ Certainty is (possibly) folly ~

--
You received this message because you are subscribed to a topic in the Google Groups "ez4r" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ez4r/kkB9BV5Ri28/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ez4r+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
The N400 as a correlate of interpretively relevant linguistic rules Evidence from Hindi.pdf

Mike Lawrence

unread,
Feb 15, 2017, 12:14:46 PM2/15/17
to ez...@googlegroups.com
Ah, I see that by "resolve", you mean run a series of post-hoc tests to examine the interaction. You have to be careful with these; in the end, the interaction term in the original anova is the most true story. In contrast, it is possible to have a p<.05 on an interaction and have either both post-hoc tests fail to reject the null or both post-hoc tests reject the null, possibly tempting you to think the interaction isn't there after all. This would be an error.

Note that you can achieve these post-hoc analyses with the ezPlot figures I suggested previously. The error bars are fisher's least significant difference, , and you can even supply one of the variables to the "diff" argument to compute/plot a difference score at each level of the other variable.

Now, if you insist on doing an entirely new ANOVA for each post-hoc (which will be less accurate than the ezPlot method, which uses the error term from the full anova), then you should be able to do:

  #look at the C effect in the first level of B
  ezANOVA(
    data = data_answ[data_answ$B==levels(data_answ$B)[1],]
    , dv = x
    ,  wid = Subject
    , within = .(C)
    , within_full = .(A)
  )
  #look at the C effect in the second level of B
  ezANOVA(
    data = data_answ[data_answ$B==levels(data_answ$B)[2],]
    , dv = x
    ,  wid = Subject
    , within = .(C)
    , within_full = .(A)
  )

  #look at the B effect in the first level of C
  ezANOVA(
    data = data_answ[data_answ$C==levels(data_answ$C)[1],]
    , dv = x
    ,  wid = Subject
    , within = .(B)
    , within_full = .(A)
  )
  #look at the B effect in the second level of C
  ezANOVA(
    data = data_answ[data_answ$C==levels(data_answ$C)[2],]
    , dv = x
    ,  wid = Subject
    , within = .(B)
    , within_full = .(A)
  )





On Wed, Feb 15, 2017 at 12:29 PM, Narendra Kumar <narendra.l...@gmail.com> wrote:
Hello Mike,

For details, kindly see section 4 'results' of the attached article.

Regards,
Narendra
On Wed, Feb 15, 2017 at 4:22 PM, Mike Lawrence <mike....@gmail.com> wrote:
What do you mean when you say that you "resolved" a given interaction? 
Reply all
Reply to author
Forward
0 new messages