1
$\begingroup$

I'm playing around with network graphs and am wondering how to show that there is:

  1. a statistically significant difference in in-degree distribution between nodes for 2 time periods
  2. the in-degree distribution is more equally dispersed among nodes at time 2

Now let's say I have a classroom of students and I asked them to name the 3 kids who they thought was getting the most negative attention from other students. Let's say three kids (J, K, and L) were getting the most negative attention (we'll say they're being bullied).

Now we conduct a session (treatment) and now conduct a follow up question to the classroom again asking the three students that were receiving the most negative attention.

Here I plotted that out with R as a network graph. You can see from the weighting I obviously made this the 'ideal' situation that I have described and after the treatment the vertices are more equally distributed.

How can I show a statistically significant: (a) change in the distribution of in-degrees (incoming edges) and (b) the distribution of in-degrees (incoming edges) is more equal?

enter image description here

library(igraph); library(reshape2)

weights_1 <- c(.01, .01, .01, .01, .01, .05, .05, .05, .05, .25, .25, .25)
weights_2 <- rep(1/11, 12)

selects <- function(p, n = 12) {
    melt(data.frame(from = LETTERS[1:n],
            do.call(rbind, lapply(1:n, function(i) {
                sample(LETTERS[1:n][-i], 3, FALSE, prob = p[-i])
            }))), 
        id="from", value.name="to", 
        variable.name = "choice.n"
    )[, c(1, 3, 2)]
}

set.seed(100)
time_1 <- selects(weights_1)
t1 <- graph.data.frame(time_1)

set.seed(100)
time_2 <- selects(weights_2)
t2 <- graph.data.frame(time_2)

E(t1)$arrow.size <- .6
E(t2)$arrow.size <- .6

par(mfrow=c(1,2))
plot(t1, layout=layout.circle); mtext("Time 1")
plot(t2, layout=layout.circle); mtext("Time 2")

EDIT It occurs to me that it may be easier to help if the Boolean matrices and adjacency matrices are already created:

Here it is as a viewable format:

$Boolean_time1
  A B C D E F G H I J K L
A 0 0 0 0 0 0 0 0 0 0 0 0
B 0 0 0 0 0 0 0 0 0 0 0 0
C 0 0 0 0 0 0 0 0 0 0 0 0
D 0 0 0 0 0 0 0 0 0 0 0 0
E 0 0 0 0 0 0 0 0 0 0 1 1
F 0 0 1 0 0 0 0 0 0 0 0 1
G 1 0 0 0 0 0 0 0 0 1 0 1
H 0 0 0 0 1 0 0 0 1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1 0 1 2 0 0 0
J 0 0 1 1 1 0 2 1 0 4 1 1
K 1 0 1 0 0 3 2 2 0 1 5 0
L 0 0 1 1 0 0 1 0 0 1 0 2

As an easy to grab R format:

 dats <- structure(list(Boolean_time1 = structure(list(A = c(0L, 0L, 0L,                 
     0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 1L), B = c(0L, 0L, 0L, 0L, 0L,                      
     0L, 0L, 0L, 0L, 1L, 1L, 1L), C = c(0L, 0L, 0L, 0L, 0L, 1L, 0L,                      
     0L, 0L, 0L, 1L, 1L), D = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,                      
     1L, 1L, 0L), E = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L,                      
     1L), F = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L), G = c(0L,               
     0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L), H = c(0L, 0L, 0L,                      
     0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L), I = c(0L, 0L, 0L, 0L, 0L,                      
     0L, 0L, 1L, 0L, 0L, 1L, 1L), J = c(0L, 0L, 0L, 0L, 0L, 0L, 1L,                      
     0L, 0L, 0L, 1L, 1L), K = c(0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,                      
     1L, 0L, 1L), L = c(0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L,                      
     0L)), .Names = c("A", "B", "C", "D", "E", "F", "G", "H", "I",                       
     "J", "K", "L"), row.names = c("A", "B", "C", "D", "E", "F", "G",                    
     "H", "I", "J", "K", "L"), class = "data.frame"), Boolean_time2 = structure(list(    
         A = c(0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L), B = c(0L,                
         0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L), C = c(0L, 0L,                      
         0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L), D = c(0L, 0L, 1L,                      
         0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L), E = c(0L, 0L, 0L, 0L,                      
         0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L), F = c(0L, 0L, 0L, 1L, 0L,                      
         0L, 1L, 0L, 0L, 1L, 0L, 0L), G = c(0L, 0L, 0L, 0L, 1L, 0L,                      
         0L, 1L, 0L, 1L, 0L, 0L), H = c(0L, 0L, 0L, 0L, 0L, 0L, 1L,                      
         0L, 0L, 1L, 1L, 0L), I = c(0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L,                      
         0L, 0L, 1L, 0L), J = c(0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L,                      
         0L, 0L, 1L), K = c(1L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L,                      
         0L, 0L), L = c(1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L,                      
         0L)), .Names = c("A", "B", "C", "D", "E", "F", "G", "H",                        
     "I", "J", "K", "L"), row.names = c("A", "B", "C", "D", "E", "F",                    
     "G", "H", "I", "J", "K", "L"), class = "data.frame"), adjmat_time1 = structure(c(0, 
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                      
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                      
     0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0,                      
     1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 3, 0, 0, 1, 1, 2, 0,                      
     0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2,                      
     2, 0, 0, 0, 0, 0, 1, 0, 1, 0, 2, 7, 5, 5, 0, 0, 0, 0, 0, 1, 1,                      
     2, 2, 5, 9, 7, 0, 0, 0, 0, 1, 1, 2, 2, 0, 5, 7, 9), .Dim = c(12L,                   
     12L), .Dimnames = list(c("A", "B", "C", "D", "E", "F", "G", "H",                    
     "I", "J", "K", "L"), c("A", "B", "C", "D", "E", "F", "G", "H",                      
     "I", "J", "K", "L"))), adjmat_time2 = structure(c(2, 0, 0, 0,                       
     1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                      
     0, 3, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 2, 0, 0, 2, 0, 0, 1,                      
     0, 1, 1, 0, 0, 0, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 4, 1,                      
     1, 1, 0, 3, 0, 1, 0, 0, 2, 1, 1, 5, 0, 0, 2, 2, 1, 1, 0, 1, 0,                      
     1, 1, 0, 4, 1, 1, 2, 0, 0, 0, 1, 0, 1, 1, 0, 1, 2, 0, 0, 0, 0,                      
     0, 1, 1, 1, 0, 2, 1, 0, 4, 1, 1, 1, 0, 1, 0, 0, 3, 2, 2, 0, 1,                      
     5, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 2), .Dim = c(12L, 12L), .Dimnames = list(    
         c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",                        
         "L"), c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J",                       
         "K", "L")))), .Names = c("Boolean_time1", "Boolean_time2",                      
     "adjmat_time1", "adjmat_time2"))     
$\endgroup$
  • $\begingroup$ What do you mean by "vertex distribution?" Do you instead mean, "degree distribution?" $\endgroup$ – BenjaminLind Mar 12 '14 at 3:42
  • $\begingroup$ @BenjaminLind I may mean that I'm not sure. What I'm talking about it the distribution of arrow heads. Are these degrees rather than vertices? $\endgroup$ – Tyler Rinker Mar 12 '14 at 13:44
  • $\begingroup$ @Tyler The arrows are usually called edges or links. The students would be called vertices or nodes. The degree of a vertex is the number of edges it has. $\endgroup$ – Mikkel N. Schmidt Mar 12 '14 at 14:43
  • $\begingroup$ Then yes, I am looking at the degree (but incoming edges; maybe there's a better choice of words here too) that a node has, that is is the degree distribution becoming more equalized? PS thank you for the very succinct vocab lesson, often searching is all about knowing the right vocab which obviously I did not have. Edited question to reflect your comments. $\endgroup$ – Tyler Rinker Mar 12 '14 at 15:30
  • $\begingroup$ I'm reading and thinking centralization may be helpful. $\endgroup$ – Tyler Rinker Mar 13 '14 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.