# Comparison of frequency tables over time

I have an experiment in which students are asked to solve a maze under two groups (TRT v. Ctrl) over 10 different trials. In each trial, students can try 3 times to solve the maze. If they solve it in the first time, we assign 1, the second time 2, the 3rd time 3, and if in each trial a student cannot solve the maze, we assign 4. I'd like to test whether there is any "learning effect" over time. Consider two frequency tables below, one for the first trial and the other one for the 8th trial:

Trial1 <- matrix(c(18,14,7,7,2,6,5,30) , ncol = 4, byrow = TRUE)
Trial8 <- matrix(c(28,10,4,4,17,10,5,11) , ncol = 4, byrow = TRUE)
colnames(Trial1) <- colnames(Trial8) <- c(1:4)
rownames(Trial1) <- rownames(Trial8) <- c("CTRL","TRT")


For example, the table trial1 shows that 18 students in the CTRL group solve the puzzle in the first try in Trial 1.

My question is how I can test whether there is any learning effect? How to compare the two frequency tables?

• I removed the Fisher test tag which is irrelevant here since you have correlated data arranged in a 2x4x10 array (or a design with two factors--10 trials and 2 groups--and a response variable like "number of attempts before success", or three factors--10 trials, 2 groups, and 3 replicates--with outcome=success/failure).
– chl
Nov 5, 2012 at 21:56
• See mantelhaen.test but it needs your data structured a different way. I haven't time right now to figure out how to do that (and it will be easy for someone more skilled at R). Nov 5, 2012 at 22:28
– Momo
Nov 7, 2013 at 11:01

Im not sure that I clearly understand the design of an experiment, but if more details are given, I will maybe re-answer your question. Mainly - how did CTRL and TRT differ from each other? Was number of students equal in each trial?

As I understand it, this should help.

First, you need to reorganize your data into array:

Students <-array(c(18,14,7,7,2,6,5,30,28,10,4,4,17,10,5,11),
dim = c(4,2,2), dimnames = list(GROUP = c("1","2","3","4"),
Response = c("success","failure"),Trial.no = c("1","8")));Students


You can also add more trials (not only 1st and 8th as in this case)

mantelhaen.test(Students)


if p-value < 0.05, it is the evidence for learning effect