User Tools

Site Tools


krackhardt_datasets

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
krackhardt_datasets [2019/12/04 08:37] – [correlation matrix out of the combined matrix (friend and advice)] hkimscilkrackhardt_datasets [2019/12/04 08:47] – [Using cutree] hkimscil
Line 1374: Line 1374:
 # different numbers of clusters and assign vertices to clusters # different numbers of clusters and assign vertices to clusters
 # as appropriate. For example: # as appropriate. For example:
-cutree(krack_reports_to_advice_hclust, k=2) +cutree(krack_friend_advice_hclust, k=2) 
- +</code> 
 + 
 +<code> 
 +> cutree(krack_friend_advice_hclust, k=2) 
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21  
 +  2  1  1  1  2  1  1  1  1  2  2  1  2  1  1  2  1  1  1  1  
 +>  
 +>  
 +</code> 
 + 
 +<code> 
 # Now we'll try to figure out the number of clusters that best  # Now we'll try to figure out the number of clusters that best 
 # describes the underlying data. To do this, we'll loop through # describes the underlying data. To do this, we'll loop through
Line 1399: Line 1409:
 # set a variable for our number of vertices. # set a variable for our number of vertices.
 clustered_observed_cors = vector() clustered_observed_cors = vector()
-num_vertices = length(V(krack_reports_to)) +num_vertices = length(V(krack_advice)) 
- + 
 # Next, we loop through the different possible cluster  # Next, we loop through the different possible cluster 
 # configurations, produce matrices of within- and between- # configurations, produce matrices of within- and between-
Line 1407: Line 1418:
    
 # pdf("6.3_m182_studentnet_task_social_clustered_observed_corrs.pdf") # pdf("6.3_m182_studentnet_task_social_clustered_observed_corrs.pdf")
-clustered_observed_cors <-clustConfigurations(num_vertices, krack_reports_to_advice_hclustkrack_reports_to_advice_cors)+clustered_observed_cors <-clustConfigurations(num_vertices, krack_friend_advice_hclustkrack_friend_advice_cors)
 clustered_observed_cors clustered_observed_cors
 plot(clustered_observed_cors$correlations) plot(clustered_observed_cors$correlations)
 # dev.off() # dev.off()
- +
 clustered_observed_cors$correlations clustered_observed_cors$correlations
 +</code>
 +
 +<code>
 +> clustered_observed_cors <-clustConfigurations(num_vertices, krack_friend_advice_hclust, krack_friend_advice_cors)
 +Warning message:
 +In cor(as.vector(d[g1[i], , ]), as.vector(d[g2[j], , ]), use = "complete.obs") :
 +  표준편차가 0입니다
 +> clustered_observed_cors
 +$label
 +[1] "number of clusters:  1"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1 
 +
 +$correlation
 +[1] NA
 +
 +$label
 +[1] "number of clusters:  2"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  1  1  1  2  1  1  1  1  2  2  1  2  1  1  2  1  1  1  1 
 +
 +$correlation
 +[1] 0.4896211
 +
 +$label
 +[1] "number of clusters:  3"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  1  3  2  1  1  3  3  2  2  3  2  3  1  2  3  3  1  1 
 +
 +$correlation
 +[1] 0.5944114
 +
 +$label
 +[1] "number of clusters:  4"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  1  3  2  1  1  3  4  2  2  3  2  3  1  2  4  3  1  1 
 +
 +$correlation
 +[1] 0.6398013
 +
 +$label
 +[1] "number of clusters:  5"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  1  3  2  4  1  3  5  2  2  3  2  3  1  2  5  3  4  4 
 +
 +$correlation
 +[1] 0.6538231
 +
 +$label
 +[1] "number of clusters:  6"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  1  3  4  5  1  3  6  4  2  3  4  3  1  4  6  3  5  5 
 +
 +$correlation
 +[1] 0.6723019
 +
 +$label
 +[1] "number of clusters:  7"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  1  3  4  5  1  3  6  4  2  3  4  3  1  4  6  3  5  7 
 +
 +$correlation
 +[1] 0.7019599
 +
 +$label
 +[1] "number of clusters:  8"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  1  3  4  5  1  3  6  4  2  3  4  3  1  7  6  3  5  8 
 +
 +$correlation
 +[1] 0.727137
 +
 +$label
 +[1] "number of clusters:  9"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  1  3  4  5  1  3  6  4  2  7  4  7  1  8  6  7  5  9 
 +
 +$correlation
 +[1] 0.7743714
 +
 +$label
 +[1] "number of clusters:  10"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  3  5  6  4  3  7  5  2  8  5  8  4  9  7  8  6 10 
 +
 +$correlation
 +[1] 0.7919439
 +
 +$label
 +[1] "number of clusters:  11"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  3  5  6  4  3  7  5  2  8  5  8  4  9 10  8  6 11 
 +
 +$correlation
 +[1] 0.8093965
 +
 +$label
 +[1] "number of clusters:  12"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  3  5  6  7  3  8  5  2  9  5  9  7 10 11  9  6 12 
 +
 +$correlation
 +[1] 0.8445199
 +
 +$label
 +[1] "number of clusters:  13"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  3  5  6  7  3  8  5  2  9  5 10  7 11 12  9  6 13 
 +
 +$correlation
 +[1] 0.8700886
 +
 +$label
 +[1] "number of clusters:  14"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  3  5  6  7  3  8  9  2 10  5 11  7 12 13 10  6 14 
 +
 +$correlation
 +[1] 0.8844067
 +
 +$label
 +[1] "number of clusters:  15"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  3  5  6  7  3  8  9  2 10 11 12  7 13 14 10  6 15 
 +
 +$correlation
 +[1] 0.9115517
 +
 +$label
 +[1] "number of clusters:  16"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  3  5  6  7  3  8  9  2 10 11 12  7 13 14 10 15 16 
 +
 +$correlation
 +[1] 0.9403353
 +
 +$label
 +[1] "number of clusters:  17"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  3  5  6  7  3  8  9  2 10 11 12  7 13 14 15 16 17 
 +
 +$correlation
 +[1] 0.9502702
 +
 +$label
 +[1] "number of clusters:  18"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  3  5  6  7  3  8  9 10 11 12 13  7 14 15 16 17 18 
 +
 +$correlation
 +[1] 0.9633198
 +
 +$label
 +[1] "number of clusters:  19"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  3  5  6  7  8  9 10 11 12 13 14  7 15 16 17 18 19 
 +
 +$correlation
 +[1] 0.9762881
 +
 +$label
 +[1] "number of clusters:  20"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  3  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 
 +
 +$correlation
 +[1] 0.9895545
 +
 +$label
 +[1] "number of clusters:  21"
 +
 +$clusters
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 +
 +$correlation
 +[1] 1
 +
 +$correlations
 + [1]        NA 0.4896211 0.5944114 0.6398013 0.6538231 0.6723019 0.7019599 0.7271370 0.7743714 0.7919439 0.8093965 0.8445199 0.8700886 0.8844067 0.9115517 0.9403353
 +[17] 0.9502702 0.9633198 0.9762881 0.9895545 1.0000000
 +
 +> plot(clustered_observed_cors$correlations)
 +
 +> clustered_observed_cors$correlations
 + [1]        NA 0.4896211 0.5944114 0.6398013 0.6538231 0.6723019 0.7019599 0.7271370 0.7743714 0.7919439 0.8093965 0.8445199 0.8700886 0.8844067 0.9115517 0.9403353
 +[17] 0.9502702 0.9633198 0.9762881 0.9895545 1.0000000
 +>
 +</code>
 +{{:pasted:20191204-081317.png}}
 +
 +<code> 
 # From a visual inspection of the correlation matrix, we can  # From a visual inspection of the correlation matrix, we can 
 # decide on the proper number of clusters in this network.  # decide on the proper number of clusters in this network. 
krackhardt_datasets.txt · Last modified: 2019/12/13 14:11 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki