R - statnet - grp_month - week 2

2017.12.02 - work log - prelim - R - statnet - grp month

R network analysis files

Related files:

  • network descriptives

    • network-level

      • files

        • R scripts:

          • context_text/R/db_connect.r
          • context_text/R/sna/functions-sna.r
          • context_text/R/sna/sna-load_data.r
          • context_text/R/sna/igraph/*
          • context_text/R/sna/statnet/*
      • statnet/sna

        • sna::gden() - graph density
        • R scripts:

          • context_text/R/sna/statnet/sna-statnet-init.r
          • context_text/R/sna/statnet/sna-statnet-network-stats.r
          • context_text/R/sna/statnet/sna-qap.r
      • igraph

        • igraph::transitivity() - vector of transitivity scores for each node in a graph, plus network-level transitivity score.

          • Q - interpretation?
        • R scripts:

          • context_text/R/sna/statnet/sna-igraph-init.r
          • context_text/R/sna/statnet/sna-igraph-network-stats.r

Setup

Setup - working directories

Store important directories and file names in variables:


In [1]:
getwd()


'/home/jonathanmorgan/work/django/research/work/phd_work/methods/network_analysis/statnet'

In [2]:
# code files (in particular SNA function library, modest though it may be)
code_directory <- "/home/jonathanmorgan/work/django/research/context_analysis/R/sna"
sna_function_file_path <- paste( code_directory, "/", 'functions-sna.r', sep = "" )

# home directory
home_directory <- getwd()
home_directory <- "/home/jonathanmorgan/work/django/research/work/phd_work/methods"

# data directories
data_directory <- paste( home_directory, "/data", sep = "" )
workspace_file_name <- "statnet-grp_month.RData"
workspace_file_path <- paste( data_directory, "/", workspace_file_name )

In [3]:
# set working directory to data directory for now.
setwd( data_directory )
getwd()


'/home/jonathanmorgan/work/django/research/work/phd_work/methods/data'

Setup - import SNA functions

source the file functions-sna.r.


In [4]:
source( sna_function_file_path )

Setup - import statnet functions

source the file statnet/functions-statnet.r.


In [5]:
# statnet/sna functions
# - /home/jonathanmorgan/work/django/research/context_analysis/R/sna/stanet/functions-statnet.r
statnetFunctionFilePath <- paste( code_directory, "/statnet/", 'functions-statnet.r', sep = "" )

In [6]:
source( statnetFunctionFilePath )


Loading required package: statnet.common

Attaching package: ‘statnet.common’

The following object is masked from ‘package:base’:

    order

Loading required package: network
network: Classes for Relational Data
Version 1.13.0.1 created on 2015-08-31.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
                    Mark S. Handcock, University of California -- Los Angeles
                    David R. Hunter, Penn State University
                    Martina Morris, University of Washington
                    Skye Bender-deMoll, University of Washington
 For citation information, type citation("network").
 Type help("network-package") to get started.

sna: Tools for Social Network Analysis
Version 2.4 created on 2016-07-23.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
 For citation information, type citation("sna").
 Type help(package="sna") to get started.

Setup - network data - render and store network data

First, need render to render network data and upload it to your server.

Directions for rendering network data are in 2017.11.14-work_log-prelim-network_analysis.ipynb. You want a tab-delimited matrix that includes both the network and attributes of nodes as columns, and you want it to include a header row.

Once you render your network data files, you should place them on the server.

High level data file layout:

  • tab-delimited.
  • first row and first column are labels
  • last 2 columns are traits of nodes (person_id and person_type)
  • each row and column after first until the trait columns represents a person found in one of the articles.
  • The people are in the same order from top to bottom and left to right.
  • Where the row and column of two people meet, and one of the people is an author, the nunber in the cell where they meet is the number of times the non-author was quoted in an article by the author. Does not include more basic two-mode co-location ties (appeared in same article, even if not an author and/or not quoted).

Files and their location on server:

data - grp_month - week 2

This is data from the Grand Rapids Press articles from December of 2009, coded by both humans and OpenCalais. The second full week of articles in this time period runs from 2009-12-13 to 2009-12-19.

Files:

  • automated week 2 subset - sourcenet_data-20180326-040445-grp_month-automated-week2_subset.tab
  • human week 2 subset - sourcenet_data-20180326-034401-grp_month-human-week2_subset.tab

Location in Dropbox: Dropbox/academia/MSU/program_stuff/prelim_paper/data/network_analysis/2017.11.14/network/new_coders/grp_month

Location on server: /home/jonathanmorgan/work/django/research/work/phd_work/data/network/grp_month

Setup - load workspace

You must load this file's workspace, from a previous run, if one exists:


In [7]:
# assumes that you've already set working directory above to the
#     working directory.
setwd( data_directory )
load( workspace_file_name )

grp_week_2 analysis

Look at the second full week from the month of data.


In [6]:
output_prefix <- "grp_week_2"

grp_week_2 (gw2) - automated - OpenCalais

First, we'll analyze the week of data coded by OpenCalais. Set up some variables to store where data is located:

grp_week_2 (gw2) - automated - Read data

Read in the data from tab-delimited data file, then get it in right data structures for use in R SNA.


In [10]:
# initialize variables
gw2AutomatedDataFolder <- paste( data_directory, "/network/grp_month", sep = "" )
gw2AutomatedDataFile <- "sourcenet_data-20180326-040445-grp_month-automated-week2_subset.tab"
gw2AutomatedDataPath <- paste( gw2AutomatedDataFolder, "/", gw2AutomatedDataFile, sep = "" )

In [11]:
gw2AutomatedDataPath


'/home/jonathanmorgan/work/django/research/work/phd_work/methods/data/network/grp_month/sourcenet_data-20180326-040445-grp_month-automated-week2_subset.tab'

Load the data file into memory


In [12]:
# tab-delimited:
gw2AutomatedDataDF <- read.delim( gw2AutomatedDataPath, header = TRUE, row.names = 1, check.names = FALSE )

In [13]:
# get count of rows...
gw2AutomatedRowCount <- nrow( gw2AutomatedDataDF )
paste( output_prefix, "automated row count =", gw2AutomatedRowCount, sep = " " )

# ...and columns
gw2AutomatedColumnCount <- ncol( gw2AutomatedDataDF )
paste( output_prefix, "automated column count =", gw2AutomatedColumnCount, sep = " " )


'grp_week_2 automated row count = 1167'
'grp_week_2 automated column count = 1169'

Get just the tie rows and columns for initializing network libraries.


In [14]:
# the below syntax returns only as many columns as there are rows, so
#     omitting any trait columns that lie in columns on the right side
#     of the file.
gw2AutomatedNetworkDF <- gw2AutomatedDataDF[ , 1 : gw2AutomatedRowCount ]
#str( gw2AutomatedNetworkDF )

In [15]:
# convert to a matrix
gw2AutomatedNetworkMatrix <- as.matrix( gw2AutomatedNetworkDF )
# str( gw2AutomatedNetworkMatrix )

grp_week_2 (gw2) - automated - initialize statnet

First, load the statnet package, then load the automated grp_month week 2 subset data into statnet object and assign attributes to nodes.

Based on context_text/R/sna/statnet/sna-statnet-init.r.


In [16]:
# make sure you've loaded the statnet library
# install.packages( "statnet" )
library( statnet )


Loading required package: tergm
Loading required package: statnet.common

Attaching package: ‘statnet.common’

The following object is masked from ‘package:base’:

    order

Loading required package: ergm
Loading required package: network
network: Classes for Relational Data
Version 1.13.0 created on 2015-08-31.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
                    Mark S. Handcock, University of California -- Los Angeles
                    David R. Hunter, Penn State University
                    Martina Morris, University of Washington
                    Skye Bender-deMoll, University of Washington
 For citation information, type citation("network").
 Type help("network-package") to get started.


ergm: version 3.8.0, created on 2017-08-18
Copyright (c) 2017, Mark S. Handcock, University of California -- Los Angeles
                    David R. Hunter, Penn State University
                    Carter T. Butts, University of California -- Irvine
                    Steven M. Goodreau, University of Washington
                    Pavel N. Krivitsky, University of Wollongong
                    Martina Morris, University of Washington
                    with contributions from
                    Li Wang
                    Kirk Li, University of Washington
                    Skye Bender-deMoll, University of Washington
Based on "statnet" project software (statnet.org).
For license and citation information see statnet.org/attribution
or type citation("ergm").

NOTE: Versions before 3.6.1 had a bug in the implementation of the bd()
constriant which distorted the sampled distribution somewhat. In
addition, Sampson's Monks datasets had mislabeled vertices. See the
NEWS and the documentation for more details.

Loading required package: networkDynamic

networkDynamic: version 0.9.0, created on 2016-01-12
Copyright (c) 2016, Carter T. Butts, University of California -- Irvine
                    Ayn Leslie-Cook, University of Washington
                    Pavel N. Krivitsky, University of Wollongong
                    Skye Bender-deMoll, University of Washington
                    with contributions from
                    Zack Almquist, University of California -- Irvine
                    David R. Hunter, Penn State University
                    Li Wang
                    Kirk Li, University of Washington
                    Steven M. Goodreau, University of Washington
                    Jeffrey Horner
                    Martina Morris, University of Washington
Based on "statnet" project software (statnet.org).
For license and citation information see statnet.org/attribution
or type citation("networkDynamic").


tergm: version 3.4.1, created on 2017-09-12
Copyright (c) 2017, Pavel N. Krivitsky, University of Wollongong
                    Mark S. Handcock, University of California -- Los Angeles
                    with contributions from
                    David R. Hunter, Penn State University
                    Steven M. Goodreau, University of Washington
                    Martina Morris, University of Washington
                    Nicole Bohme Carnegie, New York University
                    Carter T. Butts, University of California -- Irvine
                    Ayn Leslie-Cook, University of Washington
                    Skye Bender-deMoll
                    Li Wang
                    Kirk Li, University of Washington
Based on "statnet" project software (statnet.org).
For license and citation information see statnet.org/attribution
or type citation("tergm").

Loading required package: ergm.count

ergm.count: version 3.2.2, created on 2016-03-29
Copyright (c) 2016, Pavel N. Krivitsky, University of Wollongong
                    with contributions from
                    Mark S. Handcock, University of California -- Los Angeles
                    David R. Hunter, Penn State University
Based on "statnet" project software (statnet.org).
For license and citation information see statnet.org/attribution
or type citation("ergm.count").

NOTE: The form of the term ‘CMP’ has been changed in version 3.2 of
‘ergm.count’. See the news or help('CMP') for more information.

Loading required package: sna
sna: Tools for Social Network Analysis
Version 2.4 created on 2016-07-23.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
 For citation information, type citation("sna").
 Type help(package="sna") to get started.


statnet: version 2016.9, created on 2016-08-29
Copyright (c) 2016, Mark S. Handcock, University of California -- Los Angeles
                    David R. Hunter, Penn State University
                    Carter T. Butts, University of California -- Irvine
                    Steven M. Goodreau, University of Washington
                    Pavel N. Krivitsky, University of Wollongong
                    Skye Bender-deMoll
                    Martina Morris, University of Washington
Based on "statnet" project software (statnet.org).
For license and citation information see statnet.org/attribution
or type citation("statnet").


There are updates for the following statnet packages on CRAN:
        Installed ReposVer   Built  
network "1.13.0"  "1.13.0.1" "3.4.2"
Restart R and use "statnet::update_statnet()" to get the updates.

In [17]:
# If you have a data frame of attributes (each attribute is a column, with
#     attribute name the column name), you can associate those attributes
#     when you create the network.
# attribute help: http://www.inside-r.org/packages/cran/network/docs/loading.attributes

# load attributes from a file:
#tab_attribute_test1 <- read.delim( "tab-test1-attribute_data.txt", header = TRUE, row.names = 1, check.names = FALSE )

# or create DataFrame by just grabbing the attribute columns
gw2AutomatedNetworkAttributeDF <- gw2AutomatedDataDF[ , 1168:1169 ]

# convert matrix to statnet network object instance.
gw2AutomatedNetworkStatnet <- network( gw2AutomatedNetworkMatrix, matrix.type = "adjacency", directed = FALSE, vertex.attr = gw2AutomatedNetworkAttributeDF )

# look at information now.
gw2AutomatedNetworkStatnet

# Network attributes:
#  vertices = 314
#  directed = FALSE
#  hyper = FALSE
#  loops = FALSE
#  multiple = FALSE
#  bipartite = FALSE
#  total edges= 309
#    missing edges= 0
#    non-missing edges= 309
#
# Vertex attribute names:
#    person_type vertex.names
#
# No edge attributes


 Network attributes:
  vertices = 1167 
  directed = FALSE 
  hyper = FALSE 
  loops = FALSE 
  multiple = FALSE 
  bipartite = FALSE 
  total edges= 290 
    missing edges= 0 
    non-missing edges= 290 

 Vertex attribute names: 
    person_id person_type vertex.names 

No edge attributes

In [18]:
# calais - include ties Greater than or equal to 0 (GE0)
gw2AutomatedMeanTieWeightGE0Vector <- apply( gw2AutomatedNetworkMatrix, 1, calculateListMean )
gw2AutomatedDataDF$meanTieWeightGE0 <- gw2AutomatedMeanTieWeightGE0Vector

# calais - include ties Greater than or equal to 1 (GE1)
gw2AutomatedMeanTieWeightGE1Vector <- apply( gw2AutomatedNetworkMatrix, 1, calculateListMean, minValueToIncludeIN = 1 )
gw2AutomatedDataDF$meanTieWeightGE1 <- gw2AutomatedMeanTieWeightGE1Vector

# automated - Max tie weight?
gw2AutomatedMaxTieWeightVector <- apply( gw2AutomatedNetworkMatrix, 1, calculateListMax )
gw2AutomatedDataDF$maxTieWeight <- gw2AutomatedMaxTieWeightVector

grp_week_2 (gw2) - automated - Basic metrics


In [19]:
# assuming that our statnet network object is in reference test1_statnet.

# Use the degree function in the sna package to create vector of degree values
#    for each node.  Make sure to pass the gw2ode parameter to tell it that the
#    graph is not directed (gw2ode = "graph", instead of "digraph").
# Doc: http://www.inside-r.org/packages/cran/sna/docs/degree
#degree_vector <- degree( test1_statnet, gw2ode = "graph" )

# If you have other libraries loaded that also implement a degree function, you
#    can also call this with package name:
gw2AutomatedDegreeVector <- sna::degree( gw2AutomatedNetworkStatnet, gmode = "graph" )

# output the vector
gw2AutomatedDegreeVector

# want more info on the degree function?  You can get to it eventually through
#    the following:
#help( package = "sna" )
#??sna::degree

# what is the average (mean) degree?
gw2AutomatedAvgDegree <- mean( gw2AutomatedDegreeVector )
paste( output_prefix, "average degree =", gw2AutomatedAvgDegree, sep = " " )

# subset vector to get only those that are above mean
gw2AutomatedAboveMeanVector <- gw2AutomatedDegreeVector[ gw2AutomatedDegreeVector > gw2AutomatedAvgDegree ]

# Take the degree and associate it with each node as a node attribute.
#    (%v% is a shortcut for the get.vertex.attribute command)
gw2AutomatedNetworkStatnet %v% "degree" <- gw2AutomatedDegreeVector

# also add degree vector to original data frame
gw2AutomatedDataDF$degree <- gw2AutomatedDegreeVector


  1. 3
  2. 0
  3. 4
  4. 0
  5. 8
  6. 0
  7. 0
  8. 17
  9. 10
  10. 0
  11. 3
  12. 0
  13. 0
  14. 1
  15. 0
  16. 20
  17. 14
  18. 16
  19. 18
  20. 11
  21. 1
  22. 1
  23. 0
  24. 0
  25. 1
  26. 0
  27. 5
  28. 0
  29. 0
  30. 0
  31. 0
  32. 0
  33. 0
  34. 0
  35. 0
  36. 0
  37. 0
  38. 0
  39. 0
  40. 0
  41. 0
  42. 1
  43. 0
  44. 1
  45. 1
  46. 1
  47. 0
  48. 0
  49. 11
  50. 2
  51. 1
  52. 3
  53. 0
  54. 0
  55. 0
  56. 1
  57. 0
  58. 1
  59. 0
  60. 0
  61. 0
  62. 0
  63. 0
  64. 0
  65. 0
  66. 0
  67. 0
  68. 1
  69. 0
  70. 0
  71. 0
  72. 3
  73. 1
  74. 0
  75. 0
  76. 0
  77. 0
  78. 0
  79. 0
  80. 0
  81. 0
  82. 0
  83. 0
  84. 0
  85. 0
  86. 0
  87. 0
  88. 0
  89. 0
  90. 0
  91. 0
  92. 0
  93. 0
  94. 0
  95. 0
  96. 0
  97. 0
  98. 0
  99. 0
  100. 0
  101. 0
  102. 0
  103. 0
  104. 0
  105. 1
  106. 0
  107. 0
  108. 0
  109. 0
  110. 0
  111. 0
  112. 0
  113. 0
  114. 0
  115. 0
  116. 0
  117. 0
  118. 0
  119. 0
  120. 0
  121. 0
  122. 0
  123. 0
  124. 0
  125. 1
  126. 0
  127. 0
  128. 0
  129. 0
  130. 0
  131. 0
  132. 0
  133. 0
  134. 26
  135. 0
  136. 0
  137. 0
  138. 0
  139. 0
  140. 0
  141. 0
  142. 0
  143. 1
  144. 2
  145. 0
  146. 0
  147. 0
  148. 0
  149. 0
  150. 0
  151. 7
  152. 0
  153. 0
  154. 0
  155. 0
  156. 0
  157. 0
  158. 0
  159. 0
  160. 0
  161. 0
  162. 0
  163. 0
  164. 0
  165. 0
  166. 0
  167. 0
  168. 0
  169. 0
  170. 0
  171. 0
  172. 0
  173. 2
  174. 0
  175. 0
  176. 7
  177. 21
  178. 0
  179. 1
  180. 0
  181. 0
  182. 0
  183. 14
  184. 0
  185. 0
  186. 0
  187. 0
  188. 0
  189. 0
  190. 0
  191. 1
  192. 0
  193. 0
  194. 0
  195. 0
  196. 0
  197. 0
  198. 0
  199. 0
  200. 0
  201. 0
  202. 0
  203. 0
  204. 0
  205. 0
  206. 0
  207. 0
  208. 0
  209. 0
  210. 0
  211. 1
  212. 0
  213. 0
  214. 0
  215. 0
  216. 0
  217. 0
  218. 0
  219. 0
  220. 0
  221. 0
  222. 2
  223. 0
  224. 0
  225. 0
  226. 0
  227. 0
  228. 0
  229. 0
  230. 0
  231. 0
  232. 0
  233. 2
  234. 0
  235. 0
  236. 0
  237. 0
  238. 0
  239. 0
  240. 0
  241. 0
  242. 0
  243. 0
  244. 3
  245. 0
  246. 0
  247. 0
  248. 0
  249. 0
  250. 0
  251. 0
  252. 0
  253. 0
  254. 0
  255. 0
  256. 0
  257. 0
  258. 0
  259. 0
  260. 0
  261. 0
  262. 0
  263. 0
  264. 0
  265. 0
  266. 0
  267. 0
  268. 0
  269. 0
  270. 0
  271. 0
  272. 0
  273. 0
  274. 0
  275. 0
  276. 0
  277. 0
  278. 0
  279. 0
  280. 0
  281. 0
  282. 0
  283. 0
  284. 0
  285. 0
  286. 0
  287. 0
  288. 0
  289. 0
  290. 0
  291. 0
  292. 0
  293. 0
  294. 0
  295. 0
  296. 0
  297. 0
  298. 0
  299. 0
  300. 0
  301. 0
  302. 0
  303. 0
  304. 0
  305. 0
  306. 0
  307. 0
  308. 0
  309. 18
  310. 6
  311. 17
  312. 0
  313. 0
  314. 0
  315. 1
  316. 0
  317. 5
  318. 2
  319. 0
  320. 0
  321. 0
  322. 0
  323. 0
  324. 2
  325. 1
  326. 0
  327. 0
  328. 1
  329. 0
  330. 1
  331. 0
  332. 0
  333. 0
  334. 0
  335. 0
  336. 0
  337. 0
  338. 0
  339. 0
  340. 0
  341. 1
  342. 0
  343. 0
  344. 0
  345. 0
  346. 0
  347. 0
  348. 0
  349. 0
  350. 0
  351. 0
  352. 0
  353. 0
  354. 0
  355. 0
  356. 0
  357. 0
  358. 0
  359. 0
  360. 0
  361. 1
  362. 0
  363. 0
  364. 1
  365. 1
  366. 0
  367. 1
  368. 0
  369. 3
  370. 0
  371. 0
  372. 0
  373. 1
  374. 0
  375. 1
  376. 0
  377. 0
  378. 1
  379. 1
  380. 0
  381. 1
  382. 0
  383. 0
  384. 1
  385. 0
  386. 2
  387. 1
  388. 2
  389. 0
  390. 0
  391. 0
  392. 0
  393. 0
  394. 0
  395. 0
  396. 0
  397. 0
  398. 0
  399. 1
  400. 1
  401. 1
  402. 0
  403. 0
  404. 0
  405. 0
  406. 7
  407. 1
  408. 0
  409. 0
  410. 0
  411. 0
  412. 1
  413. 0
  414. 0
  415. 0
  416. 0
  417. 0
  418. 0
  419. 0
  420. 0
  421. 0
  422. 0
  423. 0
  424. 0
  425. 0
  426. 0
  427. 0
  428. 0
  429. 0
  430. 0
  431. 0
  432. 0
  433. 0
  434. 0
  435. 0
  436. 0
  437. 0
  438. 0
  439. 0
  440. 0
  441. 0
  442. 2
  443. 0
  444. 2
  445. 1
  446. 0
  447. 0
  448. 0
  449. 0
  450. 0
  451. 0
  452. 0
  453. 0
  454. 0
  455. 0
  456. 0
  457. 0
  458. 0
  459. 0
  460. 0
  461. 0
  462. 0
  463. 0
  464. 0
  465. 0
  466. 0
  467. 0
  468. 0
  469. 0
  470. 0
  471. 0
  472. 0
  473. 0
  474. 0
  475. 1
  476. 2
  477. 0
  478. 0
  479. 0
  480. 0
  481. 0
  482. 0
  483. 0
  484. 0
  485. 0
  486. 0
  487. 1
  488. 1
  489. 1
  490. 1
  491. 1
  492. 0
  493. 1
  494. 1
  495. 0
  496. 0
  497. 0
  498. 1
  499. 0
  500. 0
  501. 0
  502. 0
  503. 0
  504. 0
  505. 0
  506. 0
  507. 0
  508. 0
  509. 0
  510. 0
  511. 0
  512. 0
  513. 0
  514. 0
  515. 0
  516. 0
  517. 1
  518. 1
  519. 1
  520. 0
  521. 1
  522. 1
  523. 1
  524. 1
  525. 1
  526. 0
  527. 0
  528. 0
  529. 0
  530. 0
  531. 0
  532. 0
  533. 0
  534. 1
  535. 1
  536. 1
  537. 1
  538. 0
  539. 0
  540. 0
  541. 0
  542. 0
  543. 1
  544. 1
  545. 1
  546. 1
  547. 1
  548. 1
  549. 1
  550. 1
  551. 1
  552. 1
  553. 1
  554. 1
  555. 1
  556. 1
  557. 1
  558. 1
  559. 0
  560. 0
  561. 0
  562. 0
  563. 0
  564. 0
  565. 0
  566. 0
  567. 0
  568. 0
  569. 0
  570. 0
  571. 0
  572. 0
  573. 0
  574. 0
  575. 0
  576. 1
  577. 0
  578. 0
  579. 0
  580. 0
  581. 0
  582. 0
  583. 0
  584. 0
  585. 0
  586. 0
  587. 0
  588. 0
  589. 0
  590. 0
  591. 1
  592. 0
  593. 0
  594. 0
  595. 0
  596. 0
  597. 0
  598. 0
  599. 0
  600. 0
  601. 1
  602. 1
  603. 0
  604. 0
  605. 1
  606. 1
  607. 1
  608. 1
  609. 1
  610. 1
  611. 0
  612. 0
  613. 0
  614. 0
  615. 0
  616. 0
  617. 0
  618. 0
  619. 5
  620. 1
  621. 1
  622. 1
  623. 1
  624. 1
  625. 1
  626. 1
  627. 1
  628. 1
  629. 1
  630. 1
  631. 1
  632. 1
  633. 1
  634. 1
  635. 1
  636. 1
  637. 1
  638. 1
  639. 1
  640. 1
  641. 1
  642. 1
  643. 1
  644. 0
  645. 0
  646. 0
  647. 0
  648. 0
  649. 0
  650. 0
  651. 0
  652. 0
  653. 0
  654. 0
  655. 0
  656. 0
  657. 0
  658. 0
  659. 0
  660. 0
  661. 0
  662. 0
  663. 0
  664. 0
  665. 0
  666. 2
  667. 1
  668. 1
  669. 0
  670. 0
  671. 0
  672. 0
  673. 0
  674. 0
  675. 0
  676. 0
  677. 0
  678. 0
  679. 0
  680. 0
  681. 0
  682. 0
  683. 0
  684. 0
  685. 0
  686. 0
  687. 0
  688. 0
  689. 0
  690. 0
  691. 0
  692. 0
  693. 0
  694. 0
  695. 0
  696. 0
  697. 0
  698. 0
  699. 0
  700. 0
  701. 0
  702. 0
  703. 0
  704. 0
  705. 0
  706. 0
  707. 0
  708. 0
  709. 0
  710. 0
  711. 0
  712. 0
  713. 0
  714. 0
  715. 0
  716. 0
  717. 0
  718. 0
  719. 0
  720. 0
  721. 0
  722. 0
  723. 0
  724. 0
  725. 0
  726. 0
  727. 0
  728. 0
  729. 0
  730. 0
  731. 0
  732. 0
  733. 0
  734. 0
  735. 0
  736. 0
  737. 0
  738. 0
  739. 0
  740. 0
  741. 1
  742. 1
  743. 1
  744. 1
  745. 1
  746. 1
  747. 1
  748. 1
  749. 1
  750. 1
  751. 1
  752. 1
  753. 1
  754. 1
  755. 0
  756. 1
  757. 1
  758. 2
  759. 1
  760. 0
  761. 1
  762. 0
  763. 1
  764. 1
  765. 1
  766. 0
  767. 1
  768. 1
  769. 1
  770. 1
  771. 1
  772. 0
  773. 2
  774. 2
  775. 2
  776. 2
  777. 2
  778. 1
  779. 1
  780. 1
  781. 1
  782. 1
  783. 1
  784. 1
  785. 1
  786. 1
  787. 1
  788. 1
  789. 1
  790. 0
  791. 0
  792. 0
  793. 0
  794. 0
  795. 0
  796. 0
  797. 0
  798. 0
  799. 1
  800. 0
  801. 0
  802. 0
  803. 0
  804. 0
  805. 0
  806. 1
  807. 0
  808. 0
  809. 0
  810. 0
  811. 0
  812. 0
  813. 0
  814. 0
  815. 0
  816. 0
  817. 0
  818. 0
  819. 0
  820. 0
  821. 1
  822. 1
  823. 0
  824. 1
  825. 0
  826. 0
  827. 0
  828. 0
  829. 0
  830. 0
  831. 0
  832. 0
  833. 0
  834. 0
  835. 0
  836. 0
  837. 0
  838. 0
  839. 1
  840. 1
  841. 1
  842. 1
  843. 1
  844. 1
  845. 1
  846. 1
  847. 1
  848. 1
  849. 1
  850. 1
  851. 1
  852. 1
  853. 1
  854. 1
  855. 1
  856. 1
  857. 0
  858. 1
  859. 1
  860. 0
  861. 1
  862. 1
  863. 1
  864. 1
  865. 1
  866. 0
  867. 1
  868. 1
  869. 1
  870. 1
  871. 1
  872. 1
  873. 1
  874. 1
  875. 1
  876. 1
  877. 1
  878. 1
  879. 1
  880. 1
  881. 1
  882. 1
  883. 0
  884. 1
  885. 1
  886. 1
  887. 1
  888. 1
  889. 1
  890. 1
  891. 1
  892. 1
  893. 1
  894. 0
  895. 1
  896. 1
  897. 2
  898. 1
  899. 1
  900. 1
  901. 1
  902. 1
  903. 1
  904. 1
  905. 1
  906. 1
  907. 1
  908. 1
  909. 1
  910. 1
  911. 0
  912. 1
  913. 1
  914. 1
  915. 1
  916. 0
  917. 0
  918. 0
  919. 0
  920. 0
  921. 0
  922. 0
  923. 0
  924. 1
  925. 1
  926. 0
  927. 0
  928. 1
  929. 1
  930. 1
  931. 1
  932. 1
  933. 1
  934. 1
  935. 0
  936. 1
  937. 1
  938. 1
  939. 1
  940. 1
  941. 1
  942. 1
  943. 1
  944. 0
  945. 0
  946. 0
  947. 0
  948. 0
  949. 0
  950. 0
  951. 0
  952. 0
  953. 0
  954. 0
  955. 0
  956. 0
  957. 0
  958. 0
  959. 0
  960. 0
  961. 0
  962. 0
  963. 0
  964. 0
  965. 0
  966. 0
  967. 0
  968. 0
  969. 0
  970. 0
  971. 0
  972. 0
  973. 0
  974. 0
  975. 0
  976. 0
  977. 0
  978. 0
  979. 0
  980. 0
  981. 0
  982. 0
  983. 0
  984. 0
  985. 0
  986. 0
  987. 0
  988. 0
  989. 0
  990. 0
  991. 0
  992. 0
  993. 0
  994. 0
  995. 0
  996. 0
  997. 0
  998. 0
  999. 0
  1000. 0
  1001. 0
  1002. 0
  1003. 0
  1004. 0
  1005. 0
  1006. 0
  1007. 0
  1008. 0
  1009. 0
  1010. 0
  1011. 0
  1012. 0
  1013. 0
  1014. 0
  1015. 0
  1016. 0
  1017. 0
  1018. 0
  1019. 0
  1020. 0
  1021. 0
  1022. 0
  1023. 0
  1024. 0
  1025. 0
  1026. 0
  1027. 0
  1028. 0
  1029. 0
  1030. 0
  1031. 0
  1032. 0
  1033. 0
  1034. 0
  1035. 0
  1036. 0
  1037. 0
  1038. 0
  1039. 0
  1040. 0
  1041. 0
  1042. 0
  1043. 0
  1044. 0
  1045. 0
  1046. 0
  1047. 0
  1048. 0
  1049. 0
  1050. 0
  1051. 0
  1052. 0
  1053. 0
  1054. 0
  1055. 0
  1056. 0
  1057. 0
  1058. 0
  1059. 0
  1060. 0
  1061. 0
  1062. 0
  1063. 0
  1064. 0
  1065. 0
  1066. 0
  1067. 0
  1068. 0
  1069. 0
  1070. 0
  1071. 0
  1072. 0
  1073. 0
  1074. 0
  1075. 0
  1076. 0
  1077. 0
  1078. 0
  1079. 0
  1080. 0
  1081. 0
  1082. 0
  1083. 0
  1084. 0
  1085. 0
  1086. 0
  1087. 0
  1088. 0
  1089. 0
  1090. 0
  1091. 0
  1092. 0
  1093. 0
  1094. 0
  1095. 0
  1096. 0
  1097. 0
  1098. 0
  1099. 0
  1100. 0
  1101. 0
  1102. 0
  1103. 0
  1104. 0
  1105. 0
  1106. 0
  1107. 0
  1108. 0
  1109. 0
  1110. 0
  1111. 0
  1112. 0
  1113. 0
  1114. 0
  1115. 0
  1116. 0
  1117. 0
  1118. 0
  1119. 0
  1120. 0
  1121. 0
  1122. 0
  1123. 0
  1124. 0
  1125. 0
  1126. 0
  1127. 0
  1128. 0
  1129. 0
  1130. 0
  1131. 0
  1132. 0
  1133. 0
  1134. 0
  1135. 1
  1136. 1
  1137. 1
  1138. 1
  1139. 1
  1140. 1
  1141. 1
  1142. 1
  1143. 1
  1144. 1
  1145. 1
  1146. 0
  1147. 0
  1148. 0
  1149. 0
  1150. 0
  1151. 0
  1152. 0
  1153. 0
  1154. 0
  1155. 0
  1156. 0
  1157. 0
  1158. 0
  1159. 0
  1160. 0
  1161. 0
  1162. 0
  1163. 0
  1164. 0
  1165. 0
  1166. 0
  1167. 0
'grp_week_2 average degree = 0.497000856898029'

In [20]:
# average author degree (person types 2 and 4)
gw2AutomatedAverageAuthorDegree2And4 <- calcAuthorMeanDegree( dataFrameIN = gw2AutomatedDataDF, includeBothIN = TRUE )
paste( output_prefix, "average author degree (2 and 4) =", gw2AutomatedAverageAuthorDegree2And4, sep = " " )

# average author degree (person type 2 only)
gw2AutomatedAverageAuthorDegreeOnly2 <- calcAuthorMeanDegree( dataFrameIN = gw2AutomatedDataDF, includeBothIN = FALSE )
paste( output_prefix, "average author degree (only 2) =", gw2AutomatedAverageAuthorDegreeOnly2, sep = " " )

# average source degree (person types 3 and 4)
gw2AutomatedAverageSourceDegree3And4 <- calcSourceMeanDegree( dataFrameIN = gw2AutomatedDataDF, includeBothIN = TRUE )
paste( output_prefix, "average source degree (3 and 4) =", gw2AutomatedAverageSourceDegree3And4, sep = " " )

# average source degree (person type 3 only)
gw2AutomatedAverageSourceDegreeOnly3 <- calcSourceMeanDegree( dataFrameIN = gw2AutomatedDataDF, includeBothIN = FALSE )
paste( output_prefix, "average source degree (only 3) =", gw2AutomatedAverageSourceDegreeOnly3, sep = " " )


'grp_week_2 average author degree (2 and 4) = 9.125'
'grp_week_2 average author degree (only 2) = 9.125'
'grp_week_2 average source degree (3 and 4) = 1.06273062730627'
'grp_week_2 average source degree (only 3) = 1.06273062730627'

grp_week_2 (gw2) - automated - More metrics

Now that we have the data in statnet object, run the code in the following for more in-depth information:

  • context_text/R/sna/statnet/sna-statnet-network-stats.r

In [21]:
# Links:
# - manual (PDF): http://cran.r-project.org/web/packages/sna/sna.pdf
# - good notes: http://www.shizukalab.com/toolkits/sna/node-level-calculations

# Also, be advised that statnet and igraph don't really play nice together.
#    If you'll be using both, best idea is to have a workspace for each.

#==============================================================================#
# statnet
#==============================================================================#

# make sure you've loaded the statnet library (includes sna)
# install.packages( "statnet" )
#library( statnet )

#==============================================================================#
# NODE level
#==============================================================================#

# what is the standard deviation of the degrees?
gw2AutomatedDegreeSd <- sd( gw2AutomatedDegreeVector )
paste( output_prefix, "degree SD =", gw2AutomatedDegreeSd, sep = " " )

# what is the variance of the degrees?
gw2AutomatedDegreeVar <- var( gw2AutomatedDegreeVector )
paste( output_prefix, "degree variance =", gw2AutomatedDegreeVar, sep = " " )

# what is the max value among the degrees?
gw2AutomatedDegreeMax <- max( gw2AutomatedDegreeVector )
paste( output_prefix, "degree max =", gw2AutomatedDegreeMax, sep = " " )

# calculate and plot degree distributions
gw2AutomatedDegreeFrequenciesTable <- table( gw2AutomatedDegreeVector )
paste( output_prefix, "degree frequencies =", gw2AutomatedDegreeFrequenciesTable, sep = " " )
gw2AutomatedDegreeFrequenciesTable

# node-level undirected betweenness
gw2AutomatedBetweenness <- sna::betweenness( gw2AutomatedNetworkStatnet, gmode = "graph", cmode = "undirected" )

#paste( "betweenness = ", gw2AutomatedBetweenness, sep = "" )
# associate with each node as a node attribute.
#    (%v% is a shortcut for the get.vertex.attribute command)
gw2AutomatedNetworkStatnet %v% "betweenness" <- gw2AutomatedBetweenness

# also add degree vector to original data frame
gw2AutomatedDataDF$betweenness <- gw2AutomatedBetweenness

#==============================================================================#
# NETWORK level
#==============================================================================#

# graph-level degree centrality
gw2AutomatedDegreeCentrality <- sna::centralization( gw2AutomatedNetworkStatnet, sna::degree, mode = "graph" )
paste( output_prefix, "degree centrality =", gw2AutomatedDegreeCentrality, sep = " " )

# graph-level betweenness centrality
gw2AutomatedBetweennessCentrality <- sna::centralization( gw2AutomatedNetworkStatnet, sna::betweenness, mode = "graph", cmode = "undirected" )
paste( output_prefix, "betweenness centrality =", gw2AutomatedBetweennessCentrality, sep = " " )

# graph-level connectedness
gw2AutomatedConnectedness <- sna::connectedness( gw2AutomatedNetworkStatnet )
paste( output_prefix, "connectedness =", gw2AutomatedConnectedness, sep = " " )

# graph-level transitivity
gw2AutomatedTransitivity <- sna::gtrans( gw2AutomatedNetworkStatnet, mode = "graph" )
paste( output_prefix, "transitivity =", gw2AutomatedTransitivity, sep = " " )

# graph-level density
gw2AutomatedDensity <- sna::gden( gw2AutomatedNetworkStatnet, mode = "graph" )
paste( output_prefix, "density =", gw2AutomatedDensity, sep = " " )


'grp_week_2 degree SD = 1.89151293574895'
'grp_week_2 degree variance = 3.57782118610561'
'grp_week_2 degree max = 26'
  1. 'grp_week_2 degree frequencies = 864'
  2. 'grp_week_2 degree frequencies = 255'
  3. 'grp_week_2 degree frequencies = 20'
  4. 'grp_week_2 degree frequencies = 6'
  5. 'grp_week_2 degree frequencies = 1'
  6. 'grp_week_2 degree frequencies = 3'
  7. 'grp_week_2 degree frequencies = 1'
  8. 'grp_week_2 degree frequencies = 3'
  9. 'grp_week_2 degree frequencies = 1'
  10. 'grp_week_2 degree frequencies = 1'
  11. 'grp_week_2 degree frequencies = 2'
  12. 'grp_week_2 degree frequencies = 2'
  13. 'grp_week_2 degree frequencies = 1'
  14. 'grp_week_2 degree frequencies = 2'
  15. 'grp_week_2 degree frequencies = 2'
  16. 'grp_week_2 degree frequencies = 1'
  17. 'grp_week_2 degree frequencies = 1'
  18. 'grp_week_2 degree frequencies = 1'
gw2AutomatedDegreeVector
  0   1   2   3   4   5   6   7   8  10  11  14  16  17  18  20  21  26 
864 255  20   6   1   3   1   3   1   1   2   2   1   2   2   1   1   1 
'grp_week_2 degree centrality = 0.021909760819794'
'grp_week_2 betweenness centrality = 0.00122803850997202'
'grp_week_2 connectedness = 0.00501204507606991'
Warning message in sna::gtrans(gw2AutomatedNetworkStatnet, mode = "graph"):
“gtrans called with use.adjacency=TRUE, but your data looks too large for that to work well.  Overriding to edgelist method.”
'grp_week_2 transitivity = 0.0154639175257732'
'grp_week_2 density = 0.000426244302656972'

grp_week_2 (gw2) - automated - create node attribute DataFrame

If you want to just work with the traits of the nodes/vertexes, you can combine the attribute vectors into a data frame.


In [22]:
#==============================================================================#
# output attributes to data frame
#==============================================================================#

# if you want to just work with the traits of the nodes/vertexes, you can
#    combine the attribute vectors into a data frame.

# first, output network object to see what attributes you have
gw2AutomatedNetworkStatnet

# then, combine them into a data frame.
gw2AutomatedNodeAttrDF <- data.frame( id = gw2AutomatedNetworkStatnet %v% "vertex.names",
                                      person_id = gw2AutomatedNetworkStatnet %v% "person_id",
                                      person_type = gw2AutomatedNetworkStatnet %v% "person_type",
                                      degree = gw2AutomatedNetworkStatnet %v% "degree",
                                      betweenness = gw2AutomatedNetworkStatnet %v% "betweenness" )


 Network attributes:
  vertices = 1167 
  directed = FALSE 
  hyper = FALSE 
  loops = FALSE 
  multiple = FALSE 
  bipartite = FALSE 
  total edges= 290 
    missing edges= 0 
    non-missing edges= 290 

 Vertex attribute names: 
    betweenness degree person_id person_type vertex.names 

No edge attributes

grp_week_2 (gw2) - human

Next, we'll analyze the same week from the month of data coded by human coders. Set up some variables to store where data is located:

grp_week_2 (gw2) - human - Read data

Read in the data from tab-delimited data file, then get it in right data structures for use in R SNA.


In [23]:
# initialize variables
gw2HumanDataFolder <- paste( data_directory, "/network/grp_month", sep = "" )
gw2HumanDataFile <- "sourcenet_data-20180326-034401-grp_month-human-week2_subset.tab"
gw2HumanDataPath <- paste( gw2HumanDataFolder, "/", gw2HumanDataFile, sep = "" )

In [24]:
gw2HumanDataPath


'/home/jonathanmorgan/work/django/research/work/phd_work/methods/data/network/grp_month/sourcenet_data-20180326-034401-grp_month-human-week2_subset.tab'

Load the data file into memory


In [25]:
# tab-delimited:
gw2HumanDataDF <- read.delim( gw2HumanDataPath, header = TRUE, row.names = 1, check.names = FALSE )

In [26]:
# get count of rows...
gw2HumanRowCount <- nrow( gw2HumanDataDF )
paste( output_prefix, "automated row count =", gw2HumanRowCount, sep = " " )

# ...and columns
gw2HumanColumnCount <- ncol( gw2HumanDataDF )
paste( output_prefix, "automated column count =", gw2HumanColumnCount, sep = " " )


'grp_week_2 automated row count = 1167'
'grp_week_2 automated column count = 1169'

Get just the tie rows and columns for initializing network libraries.


In [27]:
# the below syntax returns only as many columns as there are rows, so
#     omitting any trait columns that lie in columns on the right side
#     of the file.
gw2HumanNetworkDF <- gw2HumanDataDF[ , 1 : gw2HumanRowCount ]
#str( gw2HumanNetworkDF )

In [28]:
# convert to a matrix
gw2HumanNetworkMatrix <- as.matrix( gw2HumanNetworkDF )
# str( gw2HumanNetworkMatrix )

grp_week_2 (gw2) - human - initialize statnet

First, load the statnet package, then load the automated grp_month week of data into statnet object and assign attributes to nodes.

Based on context_text/R/sna/statnet/sna-statnet-init.r.


In [29]:
# make sure you've loaded the statnet library
# install.packages( "statnet" )
library( statnet )

In [30]:
# If you have a data frame of attributes (each attribute is a column, with
#     attribute name the column name), you can associate those attributes
#     when you create the network.
# attribute help: http://www.inside-r.org/packages/cran/network/docs/loading.attributes

# load attributes from a file:
#tab_attribute_test1 <- read.delim( "tab-test1-attribute_data.txt", header = TRUE, row.names = 1, check.names = FALSE )

# or create DataFrame by just grabbing the attribute columns
#gw2HumanNetworkAttributeDF <- gw2HumanDataDF[ , 1169:1170 ]
gw2HumanNetworkAttributeDF <- gw2HumanDataDF[ , 1168:1169 ]

# convert matrix to statnet network object instance.
gw2HumanNetworkStatnet <- network( gw2HumanNetworkMatrix, matrix.type = "adjacency", directed = FALSE, vertex.attr = gw2HumanNetworkAttributeDF )

# look at information now.
gw2HumanNetworkStatnet

# Network attributes:
#  vertices = 314
#  directed = FALSE
#  hyper = FALSE
#  loops = FALSE
#  multiple = FALSE
#  bipartite = FALSE
#  total edges= 309
#    missing edges= 0
#    non-missing edges= 309
#
# Vertex attribute names:
#    person_type vertex.names
#
# No edge attributes


 Network attributes:
  vertices = 1167 
  directed = FALSE 
  hyper = FALSE 
  loops = FALSE 
  multiple = FALSE 
  bipartite = FALSE 
  total edges= 293 
    missing edges= 0 
    non-missing edges= 293 

 Vertex attribute names: 
    person_id person_type vertex.names 

No edge attributes

In [31]:
# human - include ties Greater than or equal to 0 (GE0)
gw2HumanMeanTieWeightGE0Vector <- apply( gw2HumanNetworkMatrix, 1, calculateListMean )
gw2HumanDataDF$meanTieWeightGE0 <- gw2HumanMeanTieWeightGE0Vector

# human - include ties Greater than or equal to 1 (GE1)
gw2HumanMeanTieWeightGE1Vector <- apply( gw2HumanNetworkMatrix, 1, calculateListMean, minValueToIncludeIN = 1 )
gw2HumanDataDF$meanTieWeightGE1 <- gw2HumanMeanTieWeightGE1Vector

# human - Max tie weight?
gw2HumanMaxTieWeightVector <- apply( gw2HumanNetworkMatrix, 1, calculateListMax )
gw2HumanDataDF$maxTieWeight <- gw2HumanMaxTieWeightVector

grp_week_2 (gw2) - human - Basic metrics


In [32]:
# assuming that our statnet network object is in reference test1_statnet.

# Use the degree function in the sna package to create vector of degree values
#    for each node.  Make sure to pass the gmode parameter to tell it that the
#    graph is not directed (gmode = "graph", instead of "digraph").
# Doc: http://www.inside-r.org/packages/cran/sna/docs/degree
#degree_vector <- degree( test1_statnet, gmode = "graph" )

# If you have other libraries loaded that also implement a degree function, you
#    can also call this with package name:
gw2HumanDegreeVector <- sna::degree( gw2HumanNetworkStatnet, gmode = "graph" )

# output the vector
gw2HumanDegreeVector

# want more info on the degree function?  You can get to it eventually through
#    the following:
#help( package = "sna" )
#??sna::degree

# what is the average (mean) degree?
gw2HumanAvgDegree <- mean( gw2HumanDegreeVector )
paste( output_prefix, "average degree =", gw2HumanAvgDegree, sep = " " )

# subset vector to get only those that are above mean
gw2HumanAboveMeanVector <- gw2HumanDegreeVector[ gw2HumanDegreeVector > gw2HumanAvgDegree ]

# Take the degree and associate it with each node as a node attribute.
#    (%v% is a shortcut for the get.vertex.attribute command)
gw2HumanNetworkStatnet %v% "degree" <- gw2HumanDegreeVector

# also add degree vector to original data frame
gw2HumanDataDF$degree <- gw2HumanDegreeVector


  1. 3
  2. 0
  3. 5
  4. 0
  5. 7
  6. 0
  7. 0
  8. 18
  9. 10
  10. 0
  11. 3
  12. 0
  13. 0
  14. 1
  15. 0
  16. 19
  17. 14
  18. 17
  19. 18
  20. 8
  21. 1
  22. 0
  23. 0
  24. 0
  25. 1
  26. 1
  27. 5
  28. 0
  29. 0
  30. 0
  31. 0
  32. 0
  33. 0
  34. 0
  35. 0
  36. 0
  37. 0
  38. 0
  39. 0
  40. 0
  41. 0
  42. 1
  43. 0
  44. 1
  45. 1
  46. 1
  47. 0
  48. 0
  49. 14
  50. 2
  51. 1
  52. 4
  53. 0
  54. 0
  55. 0
  56. 1
  57. 0
  58. 0
  59. 0
  60. 0
  61. 0
  62. 0
  63. 0
  64. 0
  65. 0
  66. 0
  67. 0
  68. 1
  69. 0
  70. 0
  71. 0
  72. 3
  73. 1
  74. 0
  75. 0
  76. 0
  77. 0
  78. 0
  79. 0
  80. 0
  81. 0
  82. 0
  83. 0
  84. 0
  85. 0
  86. 0
  87. 0
  88. 0
  89. 0
  90. 0
  91. 0
  92. 0
  93. 0
  94. 0
  95. 0
  96. 0
  97. 0
  98. 0
  99. 0
  100. 0
  101. 0
  102. 0
  103. 0
  104. 0
  105. 1
  106. 0
  107. 0
  108. 0
  109. 0
  110. 0
  111. 0
  112. 0
  113. 0
  114. 0
  115. 0
  116. 0
  117. 0
  118. 0
  119. 0
  120. 0
  121. 0
  122. 0
  123. 0
  124. 0
  125. 1
  126. 0
  127. 0
  128. 0
  129. 0
  130. 0
  131. 0
  132. 0
  133. 0
  134. 26
  135. 0
  136. 0
  137. 0
  138. 0
  139. 0
  140. 0
  141. 0
  142. 0
  143. 1
  144. 2
  145. 0
  146. 0
  147. 0
  148. 0
  149. 0
  150. 0
  151. 8
  152. 0
  153. 0
  154. 0
  155. 0
  156. 0
  157. 0
  158. 0
  159. 0
  160. 0
  161. 0
  162. 0
  163. 0
  164. 0
  165. 0
  166. 0
  167. 0
  168. 0
  169. 0
  170. 0
  171. 0
  172. 0
  173. 2
  174. 0
  175. 0
  176. 6
  177. 18
  178. 0
  179. 1
  180. 1
  181. 0
  182. 0
  183. 12
  184. 0
  185. 0
  186. 0
  187. 0
  188. 0
  189. 0
  190. 0
  191. 1
  192. 0
  193. 0
  194. 0
  195. 0
  196. 0
  197. 0
  198. 0
  199. 0
  200. 0
  201. 0
  202. 0
  203. 0
  204. 0
  205. 0
  206. 0
  207. 0
  208. 0
  209. 0
  210. 0
  211. 1
  212. 0
  213. 0
  214. 0
  215. 0
  216. 0
  217. 0
  218. 0
  219. 0
  220. 0
  221. 0
  222. 2
  223. 0
  224. 0
  225. 0
  226. 0
  227. 0
  228. 0
  229. 0
  230. 0
  231. 0
  232. 0
  233. 2
  234. 0
  235. 0
  236. 0
  237. 0
  238. 0
  239. 0
  240. 0
  241. 0
  242. 0
  243. 0
  244. 3
  245. 0
  246. 0
  247. 0
  248. 0
  249. 0
  250. 0
  251. 0
  252. 0
  253. 0
  254. 0
  255. 0
  256. 0
  257. 0
  258. 0
  259. 0
  260. 0
  261. 2
  262. 0
  263. 0
  264. 0
  265. 0
  266. 0
  267. 0
  268. 0
  269. 0
  270. 0
  271. 0
  272. 0
  273. 0
  274. 0
  275. 0
  276. 0
  277. 0
  278. 0
  279. 0
  280. 0
  281. 0
  282. 0
  283. 0
  284. 0
  285. 0
  286. 0
  287. 0
  288. 0
  289. 0
  290. 0
  291. 0
  292. 0
  293. 0
  294. 0
  295. 0
  296. 0
  297. 0
  298. 1
  299. 0
  300. 0
  301. 0
  302. 0
  303. 0
  304. 0
  305. 0
  306. 0
  307. 0
  308. 0
  309. 18
  310. 6
  311. 21
  312. 0
  313. 0
  314. 0
  315. 1
  316. 0
  317. 6
  318. 3
  319. 0
  320. 0
  321. 1
  322. 0
  323. 0
  324. 2
  325. 1
  326. 0
  327. 0
  328. 1
  329. 0
  330. 1
  331. 0
  332. 0
  333. 0
  334. 0
  335. 0
  336. 0
  337. 0
  338. 0
  339. 0
  340. 0
  341. 1
  342. 0
  343. 0
  344. 0
  345. 0
  346. 0
  347. 0
  348. 0
  349. 0
  350. 0
  351. 0
  352. 0
  353. 0
  354. 0
  355. 0
  356. 0
  357. 0
  358. 0
  359. 0
  360. 0
  361. 1
  362. 0
  363. 0
  364. 1
  365. 1
  366. 0
  367. 1
  368. 0
  369. 3
  370. 0
  371. 0
  372. 0
  373. 1
  374. 0
  375. 1
  376. 0
  377. 1
  378. 1
  379. 1
  380. 0
  381. 1
  382. 0
  383. 0
  384. 1
  385. 0
  386. 2
  387. 1
  388. 2
  389. 0
  390. 0
  391. 0
  392. 0
  393. 0
  394. 1
  395. 0
  396. 0
  397. 0
  398. 0
  399. 1
  400. 1
  401. 1
  402. 0
  403. 0
  404. 1
  405. 0
  406. 7
  407. 1
  408. 0
  409. 0
  410. 0
  411. 0
  412. 1
  413. 0
  414. 0
  415. 0
  416. 0
  417. 0
  418. 0
  419. 0
  420. 0
  421. 0
  422. 0
  423. 0
  424. 0
  425. 0
  426. 0
  427. 0
  428. 0
  429. 0
  430. 0
  431. 0
  432. 0
  433. 0
  434. 0
  435. 0
  436. 0
  437. 0
  438. 0
  439. 0
  440. 0
  441. 0
  442. 2
  443. 0
  444. 2
  445. 1
  446. 0
  447. 0
  448. 0
  449. 0
  450. 0
  451. 0
  452. 0
  453. 0
  454. 0
  455. 0
  456. 0
  457. 0
  458. 0
  459. 0
  460. 0
  461. 0
  462. 0
  463. 0
  464. 0
  465. 0
  466. 0
  467. 0
  468. 0
  469. 0
  470. 0
  471. 0
  472. 0
  473. 0
  474. 0
  475. 1
  476. 2
  477. 0
  478. 0
  479. 0
  480. 0
  481. 0
  482. 0
  483. 0
  484. 0
  485. 0
  486. 0
  487. 1
  488. 1
  489. 1
  490. 1
  491. 1
  492. 1
  493. 1
  494. 1
  495. 0
  496. 0
  497. 0
  498. 1
  499. 0
  500. 0
  501. 0
  502. 0
  503. 0
  504. 0
  505. 0
  506. 0
  507. 0
  508. 0
  509. 0
  510. 0
  511. 0
  512. 0
  513. 0
  514. 0
  515. 0
  516. 0
  517. 1
  518. 1
  519. 1
  520. 0
  521. 0
  522. 1
  523. 1
  524. 1
  525. 1
  526. 0
  527. 0
  528. 0
  529. 0
  530. 0
  531. 0
  532. 0
  533. 0
  534. 1
  535. 1
  536. 1
  537. 1
  538. 0
  539. 0
  540. 0
  541. 0
  542. 1
  543. 1
  544. 1
  545. 1
  546. 1
  547. 1
  548. 1
  549. 1
  550. 0
  551. 1
  552. 1
  553. 1
  554. 1
  555. 1
  556. 1
  557. 1
  558. 1
  559. 0
  560. 0
  561. 0
  562. 0
  563. 0
  564. 0
  565. 0
  566. 0
  567. 0
  568. 0
  569. 0
  570. 0
  571. 0
  572. 0
  573. 0
  574. 0
  575. 0
  576. 1
  577. 0
  578. 0
  579. 0
  580. 0
  581. 0
  582. 0
  583. 0
  584. 0
  585. 0
  586. 0
  587. 0
  588. 0
  589. 0
  590. 0
  591. 1
  592. 0
  593. 0
  594. 0
  595. 0
  596. 0
  597. 0
  598. 0
  599. 0
  600. 0
  601. 1
  602. 1
  603. 0
  604. 0
  605. 1
  606. 1
  607. 1
  608. 1
  609. 1
  610. 1
  611. 0
  612. 0
  613. 0
  614. 0
  615. 0
  616. 0
  617. 0
  618. 0
  619. 5
  620. 1
  621. 1
  622. 1
  623. 1
  624. 1
  625. 1
  626. 2
  627. 1
  628. 1
  629. 1
  630. 1
  631. 1
  632. 1
  633. 1
  634. 1
  635. 1
  636. 1
  637. 1
  638. 1
  639. 1
  640. 1
  641. 1
  642. 1
  643. 1
  644. 0
  645. 0
  646. 0
  647. 0
  648. 0
  649. 0
  650. 0
  651. 0
  652. 0
  653. 0
  654. 0
  655. 0
  656. 0
  657. 0
  658. 0
  659. 0
  660. 0
  661. 0
  662. 0
  663. 0
  664. 0
  665. 0
  666. 2
  667. 1
  668. 1
  669. 0
  670. 0
  671. 0
  672. 0
  673. 0
  674. 0
  675. 0
  676. 0
  677. 0
  678. 0
  679. 0
  680. 0
  681. 0
  682. 0
  683. 0
  684. 0
  685. 0
  686. 0
  687. 0
  688. 0
  689. 0
  690. 0
  691. 0
  692. 0
  693. 0
  694. 0
  695. 0
  696. 0
  697. 0
  698. 0
  699. 0
  700. 0
  701. 0
  702. 0
  703. 0
  704. 0
  705. 0
  706. 0
  707. 0
  708. 0
  709. 0
  710. 0
  711. 0
  712. 0
  713. 0
  714. 0
  715. 0
  716. 0
  717. 0
  718. 0
  719. 0
  720. 0
  721. 0
  722. 0
  723. 0
  724. 0
  725. 0
  726. 0
  727. 0
  728. 0
  729. 0
  730. 0
  731. 0
  732. 0
  733. 0
  734. 0
  735. 0
  736. 0
  737. 0
  738. 0
  739. 0
  740. 1
  741. 1
  742. 1
  743. 0
  744. 1
  745. 1
  746. 1
  747. 1
  748. 0
  749. 1
  750. 1
  751. 1
  752. 1
  753. 1
  754. 1
  755. 1
  756. 1
  757. 1
  758. 2
  759. 1
  760. 1
  761. 1
  762. 1
  763. 1
  764. 1
  765. 1
  766. 1
  767. 1
  768. 1
  769. 0
  770. 1
  771. 1
  772. 1
  773. 2
  774. 2
  775. 2
  776. 2
  777. 2
  778. 1
  779. 1
  780. 1
  781. 1
  782. 1
  783. 1
  784. 0
  785. 1
  786. 1
  787. 1
  788. 1
  789. 1
  790. 0
  791. 0
  792. 0
  793. 0
  794. 0
  795. 0
  796. 0
  797. 0
  798. 0
  799. 0
  800. 0
  801. 0
  802. 0
  803. 0
  804. 0
  805. 0
  806. 1
  807. 0
  808. 0
  809. 0
  810. 0
  811. 0
  812. 0
  813. 1
  814. 0
  815. 0
  816. 0
  817. 0
  818. 0
  819. 0
  820. 0
  821. 1
  822. 1
  823. 1
  824. 1
  825. 1
  826. 1
  827. 0
  828. 0
  829. 0
  830. 0
  831. 0
  832. 0
  833. 0
  834. 0
  835. 0
  836. 0
  837. 0
  838. 1
  839. 1
  840. 1
  841. 1
  842. 1
  843. 1
  844. 1
  845. 1
  846. 0
  847. 1
  848. 0
  849. 1
  850. 1
  851. 1
  852. 1
  853. 0
  854. 1
  855. 1
  856. 1
  857. 1
  858. 1
  859. 1
  860. 1
  861. 1
  862. 1
  863. 1
  864. 1
  865. 0
  866. 0
  867. 1
  868. 1
  869. 0
  870. 1
  871. 1
  872. 1
  873. 1
  874. 1
  875. 1
  876. 1
  877. 1
  878. 1
  879. 1
  880. 1
  881. 1
  882. 1
  883. 0
  884. 1
  885. 1
  886. 1
  887. 1
  888. 1
  889. 1
  890. 1
  891. 1
  892. 1
  893. 1
  894. 1
  895. 1
  896. 1
  897. 2
  898. 0
  899. 1
  900. 1
  901. 1
  902. 1
  903. 1
  904. 1
  905. 1
  906. 1
  907. 1
  908. 1
  909. 1
  910. 1
  911. 0
  912. 1
  913. 1
  914. 1
  915. 1
  916. 0
  917. 0
  918. 0
  919. 0
  920. 0
  921. 0
  922. 0
  923. 0
  924. 1
  925. 1
  926. 1
  927. 1
  928. 0
  929. 1
  930. 1
  931. 1
  932. 1
  933. 1
  934. 0
  935. 1
  936. 1
  937. 1
  938. 1
  939. 1
  940. 1
  941. 1
  942. 1
  943. 1
  944. 0
  945. 0
  946. 0
  947. 0
  948. 0
  949. 0
  950. 0
  951. 0
  952. 0
  953. 0
  954. 0
  955. 0
  956. 0
  957. 0
  958. 0
  959. 0
  960. 0
  961. 0
  962. 0
  963. 0
  964. 0
  965. 0
  966. 0
  967. 0
  968. 0
  969. 0
  970. 0
  971. 0
  972. 0
  973. 0
  974. 0
  975. 0
  976. 0
  977. 0
  978. 0
  979. 0
  980. 0
  981. 0
  982. 0
  983. 0
  984. 0
  985. 0
  986. 0
  987. 0
  988. 0
  989. 0
  990. 0
  991. 0
  992. 0
  993. 0
  994. 0
  995. 0
  996. 0
  997. 0
  998. 0
  999. 0
  1000. 0
  1001. 0
  1002. 0
  1003. 0
  1004. 0
  1005. 0
  1006. 0
  1007. 0
  1008. 0
  1009. 0
  1010. 0
  1011. 0
  1012. 0
  1013. 0
  1014. 0
  1015. 0
  1016. 0
  1017. 0
  1018. 0
  1019. 0
  1020. 0
  1021. 0
  1022. 0
  1023. 0
  1024. 0
  1025. 0
  1026. 0
  1027. 0
  1028. 0
  1029. 0
  1030. 0
  1031. 0
  1032. 0
  1033. 0
  1034. 0
  1035. 0
  1036. 0
  1037. 0
  1038. 0
  1039. 0
  1040. 0
  1041. 0
  1042. 0
  1043. 0
  1044. 0
  1045. 0
  1046. 0
  1047. 0
  1048. 0
  1049. 0
  1050. 0
  1051. 0
  1052. 0
  1053. 0
  1054. 0
  1055. 0
  1056. 0
  1057. 0
  1058. 0
  1059. 0
  1060. 0
  1061. 0
  1062. 0
  1063. 0
  1064. 0
  1065. 0
  1066. 0
  1067. 0
  1068. 0
  1069. 0
  1070. 0
  1071. 0
  1072. 0
  1073. 0
  1074. 0
  1075. 0
  1076. 0
  1077. 0
  1078. 0
  1079. 0
  1080. 0
  1081. 0
  1082. 0
  1083. 0
  1084. 0
  1085. 0
  1086. 0
  1087. 0
  1088. 0
  1089. 0
  1090. 0
  1091. 0
  1092. 0
  1093. 0
  1094. 0
  1095. 0
  1096. 0
  1097. 0
  1098. 0
  1099. 0
  1100. 0
  1101. 0
  1102. 0
  1103. 0
  1104. 0
  1105. 0
  1106. 0
  1107. 0
  1108. 0
  1109. 0
  1110. 0
  1111. 0
  1112. 0
  1113. 0
  1114. 0
  1115. 0
  1116. 0
  1117. 0
  1118. 0
  1119. 0
  1120. 0
  1121. 0
  1122. 0
  1123. 0
  1124. 0
  1125. 0
  1126. 0
  1127. 0
  1128. 0
  1129. 0
  1130. 0
  1131. 0
  1132. 0
  1133. 0
  1134. 0
  1135. 0
  1136. 1
  1137. 0
  1138. 0
  1139. 0
  1140. 1
  1141. 0
  1142. 0
  1143. 0
  1144. 0
  1145. 0
  1146. 0
  1147. 0
  1148. 0
  1149. 0
  1150. 0
  1151. 0
  1152. 0
  1153. 0
  1154. 0
  1155. 0
  1156. 0
  1157. 0
  1158. 0
  1159. 0
  1160. 0
  1161. 0
  1162. 0
  1163. 0
  1164. 0
  1165. 0
  1166. 0
  1167. 0
'grp_week_2 average degree = 0.502142245072836'

In [33]:
# average author degree (person types 2 and 4)
gw2HumanAverageAuthorDegree2And4 <- calcAuthorMeanDegree( dataFrameIN = gw2HumanDataDF, includeBothIN = TRUE )
paste( output_prefix, "average author degree (2 and 4) = ", gw2HumanAverageAuthorDegree2And4, sep = " " )

# average author degree (person type 2 only)
gw2HumanAverageAuthorDegreeOnly2 <- calcAuthorMeanDegree( dataFrameIN = gw2HumanDataDF, includeBothIN = FALSE )
paste( output_prefix, "average author degree (only 2) = ", gw2HumanAverageAuthorDegreeOnly2, sep = " " )

# average source degree (person types 3 and 4)
gw2HumanAverageSourceDegree3And4 <- calcSourceMeanDegree( dataFrameIN = gw2HumanDataDF, includeBothIN = TRUE )
paste( output_prefix, "average source degree (3 and 4) = ", gw2HumanAverageSourceDegree3And4, sep = " " )

# average source degree (person type 3 only)
gw2HumanAverageSourceDegreeOnly3 <- calcSourceMeanDegree( dataFrameIN = gw2HumanDataDF, includeBothIN = FALSE )
paste( output_prefix, "average source degree (only 3) = ", gw2HumanAverageSourceDegreeOnly3, sep = " " )


'grp_week_2 average author degree (2 and 4) = 9.21875'
'grp_week_2 average author degree (only 2) = 9.21875'
'grp_week_2 average source degree (3 and 4) = 1.06985294117647'
'grp_week_2 average source degree (only 3) = 1.06985294117647'

grp_week_2 (gw2) - human - More metrics

Now that we have the data in statnet object, run the code in the following for more in-depth information:

  • context_text/R/sna/statnet/sna-statnet-network-stats.r

In [34]:
# Links:
# - manual (PDF): http://cran.r-project.org/web/packages/sna/sna.pdf
# - good notes: http://www.shizukalab.com/toolkits/sna/node-level-calculations

# Also, be advised that statnet and igraph don't really play nice together.
#    If you'll be using both, best idea is to have a workspace for each.

#==============================================================================#
# statnet
#==============================================================================#

# make sure you've loaded the statnet library (includes sna)
# install.packages( "statnet" )
#library( statnet )

#==============================================================================#
# NODE level
#==============================================================================#

# what is the standard deviation of the degrees?
gw2HumanDegreeSd <- sd( gw2HumanDegreeVector )
paste( output_prefix, "degree SD =", gw2HumanDegreeSd, sep = " " )

# what is the variance of the degrees?
gw2HumanDegreeVar <- var( gw2HumanDegreeVector )
paste( output_prefix, "degree variance =", gw2HumanDegreeVar, sep = " " )

# what is the max value among the degrees?
gw2HumanDegreeMax <- max( gw2HumanDegreeVector )
paste( output_prefix, "degree max =", gw2HumanDegreeMax, sep = " " )

# calculate and plot degree distributions
gw2HumanDegreeFrequenciesTable <- table( gw2HumanDegreeVector )
paste( output_prefix, "degree frequencies =", gw2HumanDegreeFrequenciesTable, sep = " " )
gw2HumanDegreeFrequenciesTable

# node-level undirected betweenness
gw2HumanBetweenness <- sna::betweenness( gw2HumanNetworkStatnet, gmode = "graph", cmode = "undirected" )

#paste( "betweenness = ", gw2HumanBetweenness, sep = "" )
# associate with each node as a node attribute.
#    (%v% is a shortcut for the get.vertex.attribute command)
gw2HumanNetworkStatnet %v% "betweenness" <- gw2HumanBetweenness

# also add degree vector to original data frame
gw2HumanDataDF$betweenness <- gw2HumanBetweenness

#==============================================================================#
# NETWORK level
#==============================================================================#

# graph-level degree centrality
gw2HumanDegreeCentrality <- sna::centralization( gw2HumanNetworkStatnet, sna::degree, mode = "graph" )
paste( output_prefix, "degree centrality =", gw2HumanDegreeCentrality, sep = " " )

# graph-level betweenness centrality
gw2HumanBetweennessCentrality <- sna::centralization( gw2HumanNetworkStatnet, sna::betweenness, mode = "graph", cmode = "undirected" )
paste( output_prefix, "betweenness centrality =", gw2HumanBetweennessCentrality, sep = " " )

# graph-level connectedness
gw2HumanConnectedness <- sna::connectedness( gw2HumanNetworkStatnet )
paste( output_prefix, "connectedness =", gw2HumanConnectedness, sep = " " )

# graph-level transitivity
gw2HumanTransitivity <- sna::gtrans( gw2HumanNetworkStatnet, mode = "graph" )
paste( output_prefix, "transitivity =", gw2HumanTransitivity, sep = " " )

# graph-level density
gw2HumanDensity <- sna::gden( gw2HumanNetworkStatnet, mode = "graph" )
paste( output_prefix, "density =", gw2HumanDensity, sep = " " )


'grp_week_2 degree SD = 1.90281560908688'
'grp_week_2 degree variance = 3.62070724218466'
'grp_week_2 degree max = 26'
  1. 'grp_week_2 degree frequencies = 863'
  2. 'grp_week_2 degree frequencies = 254'
  3. 'grp_week_2 degree frequencies = 21'
  4. 'grp_week_2 degree frequencies = 6'
  5. 'grp_week_2 degree frequencies = 1'
  6. 'grp_week_2 degree frequencies = 3'
  7. 'grp_week_2 degree frequencies = 3'
  8. 'grp_week_2 degree frequencies = 2'
  9. 'grp_week_2 degree frequencies = 2'
  10. 'grp_week_2 degree frequencies = 1'
  11. 'grp_week_2 degree frequencies = 1'
  12. 'grp_week_2 degree frequencies = 2'
  13. 'grp_week_2 degree frequencies = 1'
  14. 'grp_week_2 degree frequencies = 4'
  15. 'grp_week_2 degree frequencies = 1'
  16. 'grp_week_2 degree frequencies = 1'
  17. 'grp_week_2 degree frequencies = 1'
gw2HumanDegreeVector
  0   1   2   3   4   5   6   7   8  10  12  14  17  18  19  21  26 
863 254  21   6   1   3   3   2   2   1   1   2   1   4   1   1   1 
'grp_week_2 degree centrality = 0.0219053438261471'
'grp_week_2 betweenness centrality = 0.00134242513432529'
'grp_week_2 connectedness = 0.00570726423178283'
Warning message in sna::gtrans(gw2HumanNetworkStatnet, mode = "graph"):
“gtrans called with use.adjacency=TRUE, but your data looks too large for that to work well.  Overriding to edgelist method.”
'grp_week_2 transitivity = 0.0152671755725191'
'grp_week_2 density = 0.000430653726477561'

grp_week_2 (gw2) - human - create node attribute DataFrame

If you want to just work with the traits of the nodes/vertexes, you can combine the attribute vectors into a data frame.


In [35]:
#==============================================================================#
# output attributes to data frame
#==============================================================================#

# if you want to just work with the traits of the nodes/vertexes, you can
#    combine the attribute vectors into a data frame.

# first, output network object to see what attributes you have
gw2HumanNetworkStatnet

# then, combine them into a data frame.
gw2HumanNodeAttrDF <- data.frame( id = gw2HumanNetworkStatnet %v% "vertex.names",
                                 person_id = gw2HumanNetworkStatnet %v% "person_id",
                                 person_type = gw2HumanNetworkStatnet %v% "person_type",
                                 degree = gw2HumanNetworkStatnet %v% "degree",
                                 betweenness = gw2HumanNetworkStatnet %v% "betweenness" )


 Network attributes:
  vertices = 1167 
  directed = FALSE 
  hyper = FALSE 
  loops = FALSE 
  multiple = FALSE 
  bipartite = FALSE 
  total edges= 293 
    missing edges= 0 
    non-missing edges= 293 

 Vertex attribute names: 
    betweenness degree person_id person_type vertex.names 

No edge attributes

grp_week_2 QAP graph correlation between automated and ground truth

Now, compare the automated and human-coded networks themselves using graph correlation in QAP.

Based on: context_text/R/sna/statnet/sna-qap.r


In [8]:
outputPrefix <- "grp_week_2 a2b"

In [9]:
grpWeek2a2bOutput <- compareMatricesQAP( gw2HumanNetworkMatrix, gw2AutomatedNetworkMatrix, outputPrefix )


==> Start of  compareMatricesQAP  at  2019-07-25 12:04:46
----> grp_week_2 a2b graph correlation = 0.908007732272713 ( @ 2019-07-25 12:04:55 )
----> grp_week_2 a2b QAP correlation analysis complete at 2019-07-25 12:08:08.  Summary:
QAP Test Results

Estimated p-values:
	p(f(perm) >= f(d)): 0 
	p(f(perm) <= f(d)): 1 

Test Diagnostics:
	Test Value (f(d)): 0.9080077 
	Replications: 1000 
	Distribution Summary:
		Min:	 -0.0004142993 
		1stQ:	 -0.0004142993 
		Med:	 -0.0004142993 
		Mean:	 -1.15967e-05 
		3rdQ:	 -0.0004142993 
		Max:	 0.01519433 

----> grp_week_2 a2b graph covariance = 0.000427519359459942 ( @ 2019-07-25 12:08:09 )
----> grp_week_2 a2b QAP covariance analysis complete at 2019-07-25 12:11:16.  Summary:
QAP Test Results

Estimated p-values:
	p(f(perm) >= f(d)): 0 
	p(f(perm) <= f(d)): 1 

Test Diagnostics:
	Test Value (f(d)): 0.0004275194 
	Replications: 1000 
	Distribution Summary:
		Min:	 -1.950655e-07 
		1stQ:	 -1.950655e-07 
		Med:	 -1.950655e-07 
		Mean:	 2.83455e-08 
		3rdQ:	 -1.950655e-07 
		Max:	 5.684171e-06 

----> grp_week_2 a2b graph hamming distance = 118 ( @ 2019-07-25 12:11:16 )
----> grp_week_2 a2b QAP hamming distance analysis complete at 2019-07-25 12:14:04.  Summary:
QAP Test Results

Estimated p-values:
	p(f(perm) >= f(d)): 1 
	p(f(perm) <= f(d)): 0 

Test Diagnostics:
	Test Value (f(d)): 118 
	Replications: 1000 
	Distribution Summary:
		Min:	 1194 
		1stQ:	 1202 
		Med:	 1202 
		Mean:	 1201.524 
		3rdQ:	 1202 
		Max:	 1202 

==> End of  compareMatricesQAP  at  2019-07-25 12:14:04

In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( grpWeek2a2bOutput, outputPrefix, TRUE )

Save workspace image

Save all the information in the current image, in case we need/want it later.


In [10]:
# help( save.image )
message( paste( "Output workspace to: ", workspace_file_name, sep = "" ) )
save.image( file = workspace_file_name )


Output workspace to: statnet-grp_month.RData