I have a set of data described by two qualitative variables. The data can therefore be analysed as a matrix, showing how many occurrences there are at each intersection of the two variables' levels.
I am looking for a measure to express the difference between two such matrices: the first, in which all intersections of the two variables are equally populated (uniform distribution), and the second, in which some intersections are much more (or much less) populated than others. Here are two matrices like the ones I have: they are counts of positive integers in all cells (r code).
m1 <- matrix(c(3,3,3,
3,3,3,
3,3,3), nrow=3, ncol=3, byrow=TRUE)
m2 <- matrix(c(6,3,0,
0,6,0,
3,3,6), nrow=3, ncol=3, byrow=TRUE)
I want to express the idea the the first matrix is more uniform than the second. Is there a measure that I can use? I believe that there should be a straightforward answer, something like a generalisation of variance for matrices. I just want to be sure to get the right one.