User Tools

Site Tools


sna_eg_stanford:lab06

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sna_eg_stanford:lab06 [2019/12/03 15:18] – [Lab 06: Step 4 deleted] hkimscilsna_eg_stanford:lab06 [2019/12/11 10:40] (current) – [no pdf] hkimscil
Line 39: Line 39:
 library(NetCluster) library(NetCluster)
  
 +# install.packages(c("sna", "NetCluster"))
 ### ###
 #2. LOADING AND FORMATTING DATA #2. LOADING AND FORMATTING DATA
Line 55: Line 56:
 m182_friend <- delete_edges(m182_full, E(m182_full)[E(m182_full)$friend_tie==0]) m182_friend <- delete_edges(m182_full, E(m182_full)[E(m182_full)$friend_tie==0])
 summary(m182_friend) summary(m182_friend)
 +m182_friend[]
  
 m182_social <- delete_edges(m182_full, E(m182_full)[E(m182_full)$social_tie==0]) m182_social <- delete_edges(m182_full, E(m182_full)[E(m182_full)$social_tie==0])
 summary(m182_social) summary(m182_social)
 +m182_social[]
  
 m182_task <- delete_edges(m182_full, E(m182_full)[E(m182_full)$task_tie==0]) m182_task <- delete_edges(m182_full, E(m182_full)[E(m182_full)$task_tie==0])
 summary(m182_task) summary(m182_task)
 +m182_task[]
  
 # Look at the plots for each sub-graph # Look at the plots for each sub-graph
Line 992: Line 996:
  
 # Look at the plots for each sub-graph # Look at the plots for each sub-graph
-pdf("6.1_m182_studentnet_friend_social_task_plots.pdf", width = 10)+pdf("6.1_m182_studentnet_friend_social_task_plots.pdf", width = 10)
 par(mfrow = c(1,3)) par(mfrow = c(1,3))
  
Line 1003: Line 1007:
 task_layout <- layout.fruchterman.reingold(m182_task) task_layout <- layout.fruchterman.reingold(m182_task)
 plot(m182_task, layout=task_layout, main = "task", edge.arrow.size=.5) plot(m182_task, layout=task_layout, main = "task", edge.arrow.size=.5)
-dev.off()+dev.off() 
 +# back to normal window pannel (no partition) 
 +par(mfrow = c(1,1)) 
  
 ### ###
Line 1084: Line 1091:
 # the "method" parameter. # the "method" parameter.
  
-pdf("6.2_m182_studentnet_social_hclust.pdf")+pdf("6.2_m182_studentnet_social_hclust.pdf")
 m182_task_social_hclust <- hclust(m182_task_social_dist) m182_task_social_hclust <- hclust(m182_task_social_dist)
 plot(m182_task_social_hclust) plot(m182_task_social_hclust)
-dev.off()+dev.off()
  
 # cutree() allows us to use the output of hclust() to set # cutree() allows us to use the output of hclust() to set
Line 1124: Line 1131:
 # with the observed correlation matrix. # with the observed correlation matrix.
  
-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,m182_task_social_hclust,m182_task_social_cors) clustered_observed_cors <-clustConfigurations(num_vertices,m182_task_social_hclust,m182_task_social_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
Line 1278: Line 1285:
 nS <- nScree(ev$values, ap$eigen$qevpea) nS <- nScree(ev$values, ap$eigen$qevpea)
  
-pdf("6.6_m182_studentnet_task_social_pca_scree.pdf")+pdf("6.6_m182_studentnet_task_social_pca_scree.pdf")
 plotnScree(nS)  plotnScree(nS) 
  
Line 1285: Line 1292:
 plotnScree(nS)  plotnScree(nS) 
 abline(h=1) abline(h=1)
-dev.off()+dev.off()
  
  
Line 1322: Line 1329:
 m182_task_factor_hclust <- hclust(m182_task_factor_dist) m182_task_factor_hclust <- hclust(m182_task_factor_dist)
  
-pdf("6.7_m182_studentnet_task_social_pca_hclust.pdf")+pdf("6.7_m182_studentnet_task_social_pca_hclust.pdf")
 plot(m182_task_factor_hclust) plot(m182_task_factor_hclust)
-dev.off()+dev.off()
  
 # And compare to NetCluster based on correlations and triads: # And compare to NetCluster based on correlations and triads:
-pdf("6.8_m182_task_cluster_by_correlation_PCA_Triads.pdf"+pdf("6.8_m182_task_cluster_by_correlation_PCA_Triads.pdf"
-par(mfrow = c(1,3))+par(mfrow = c(1,2))
 plot(m182_task_social_hclust, main = "Correlation") plot(m182_task_social_hclust, main = "Correlation")
 plot(m182_task_factor_hclust, main = "PCA") plot(m182_task_factor_hclust, main = "PCA")
-plot(m182_task_triad_hclust, main = "Triads"+# the below one that didn't work 
-dev.off()+plot(m182_task_triad_hclust, main = "Triads"
 +dev.off()
  
  
sna_eg_stanford/lab06.1575353882.txt.gz · Last modified: 2019/12/03 15:18 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki