R - statnet - grp_month - week 3

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 3

This is data from the Grand Rapids Press articles from December of 2009, coded by both humans and OpenCalais. The third full week of articles runs from 2009-12-20 to 2009-12-26.

Files:

  • automated week 3 subset - sourcenet_data-20180326-040736-grp_month-automated-week3_subset.tab
  • human week 3 subset - sourcenet_data-20180326-034548-grp_month-human-week3_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_3 analysis

Look at the third full week of articles from the month of data.


In [6]:
output_prefix <- "grp_week_3"

grp_week_3 (gw3) - automated - OpenCalais

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

grp_week_3 (gw3) - 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 [7]:
# initialize variables
gw3AutomatedDataFolder <- paste( data_directory, "/network/grp_month", sep = "" )
gw3AutomatedDataFile <- "sourcenet_data-20180326-040736-grp_month-automated-week3_subset.tab"
gw3AutomatedDataPath <- paste( gw3AutomatedDataFolder, "/", gw3AutomatedDataFile, sep = "" )

In [8]:
gw3AutomatedDataPath


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

Load the data file into memory


In [9]:
# tab-delimited:
gw3AutomatedDataDF <- read.delim( gw3AutomatedDataPath, header = TRUE, row.names = 1, check.names = FALSE )

In [10]:
# get count of rows...
gw3AutomatedRowCount <- nrow( gw3AutomatedDataDF )
paste( output_prefix, "automated row count =", gw3AutomatedRowCount, sep = " " )

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


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

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


In [11]:
# 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.
gw3AutomatedNetworkDF <- gw3AutomatedDataDF[ , 1 : gw3AutomatedRowCount ]
#str( gw3AutomatedNetworkDF )

In [12]:
# convert to a matrix
gw3AutomatedNetworkMatrix <- as.matrix( gw3AutomatedNetworkDF )
# str( gw3AutomatedNetworkMatrix )

grp_week_3 (gw3) - automated - initialize statnet

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

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


In [13]:
# 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 [14]:
# 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
gw3AutomatedNetworkAttributeDF <- gw3AutomatedDataDF[ , 1168:1169 ]

# convert matrix to statnet network object instance.
gw3AutomatedNetworkStatnet <- network( gw3AutomatedNetworkMatrix, matrix.type = "adjacency", directed = FALSE, vertex.attr = gw3AutomatedNetworkAttributeDF )

# look at information now.
gw3AutomatedNetworkStatnet

# 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= 252 
    missing edges= 0 
    non-missing edges= 252 

 Vertex attribute names: 
    person_id person_type vertex.names 

No edge attributes

In [15]:
# calais - include ties Greater than or equal to 0 (GE0)
gw3AutomatedMeanTieWeightGE0Vector <- apply( gw3AutomatedNetworkMatrix, 1, calculateListMean )
gw3AutomatedDataDF$meanTieWeightGE0 <- gw3AutomatedMeanTieWeightGE0Vector

# calais - include ties Greater than or equal to 1 (GE1)
gw3AutomatedMeanTieWeightGE1Vector <- apply( gw3AutomatedNetworkMatrix, 1, calculateListMean, minValueToIncludeIN = 1 )
gw3AutomatedDataDF$meanTieWeightGE1 <- gw3AutomatedMeanTieWeightGE1Vector

# automated - Max tie weight?
gw3AutomatedMaxTieWeightVector <- apply( gw3AutomatedNetworkMatrix, 1, calculateListMax )
gw3AutomatedDataDF$maxTieWeight <- gw3AutomatedMaxTieWeightVector

grp_week_3 (gw3) - automated - Basic metrics


In [16]:
# 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 gw3ode parameter to tell it that the
#    graph is not directed (gw3ode = "graph", instead of "digraph").
# Doc: http://www.inside-r.org/packages/cran/sna/docs/degree
#degree_vector <- degree( test1_statnet, gw3ode = "graph" )

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

# output the vector
gw3AutomatedDegreeVector

# 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?
gw3AutomatedAvgDegree <- mean( gw3AutomatedDegreeVector )
paste( output_prefix, "average degree =", gw3AutomatedAvgDegree, sep = " " )

# subset vector to get only those that are above mean
gw3AutomatedAboveMeanVector <- gw3AutomatedDegreeVector[ gw3AutomatedDegreeVector > gw3AutomatedAvgDegree ]

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

# also add degree vector to original data frame
gw3AutomatedDataDF$degree <- gw3AutomatedDegreeVector


  1. 5
  2. 0
  3. 10
  4. 0
  5. 11
  6. 0
  7. 0
  8. 9
  9. 7
  10. 0
  11. 3
  12. 0
  13. 8
  14. 0
  15. 0
  16. 23
  17. 2
  18. 0
  19. 0
  20. 9
  21. 0
  22. 2
  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. 11
  39. 0
  40. 0
  41. 0
  42. 0
  43. 2
  44. 0
  45. 1
  46. 0
  47. 0
  48. 0
  49. 11
  50. 0
  51. 0
  52. 5
  53. 0
  54. 0
  55. 0
  56. 0
  57. 0
  58. 0
  59. 0
  60. 0
  61. 0
  62. 0
  63. 0
  64. 0
  65. 0
  66. 0
  67. 0
  68. 0
  69. 2
  70. 0
  71. 0
  72. 5
  73. 0
  74. 0
  75. 2
  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. 0
  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. 1
  122. 0
  123. 0
  124. 0
  125. 0
  126. 0
  127. 0
  128. 0
  129. 0
  130. 0
  131. 0
  132. 0
  133. 0
  134. 0
  135. 0
  136. 0
  137. 0
  138. 0
  139. 0
  140. 0
  141. 0
  142. 0
  143. 0
  144. 7
  145. 0
  146. 0
  147. 0
  148. 0
  149. 0
  150. 0
  151. 5
  152. 0
  153. 0
  154. 0
  155. 0
  156. 0
  157. 0
  158. 0
  159. 0
  160. 0
  161. 1
  162. 0
  163. 0
  164. 0
  165. 0
  166. 0
  167. 0
  168. 0
  169. 0
  170. 0
  171. 0
  172. 0
  173. 1
  174. 0
  175. 0
  176. 8
  177. 14
  178. 1
  179. 1
  180. 0
  181. 0
  182. 0
  183. 20
  184. 0
  185. 0
  186. 0
  187. 0
  188. 0
  189. 0
  190. 0
  191. 0
  192. 0
  193. 0
  194. 0
  195. 0
  196. 0
  197. 2
  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. 2
  211. 0
  212. 0
  213. 0
  214. 0
  215. 0
  216. 0
  217. 0
  218. 0
  219. 0
  220. 0
  221. 0
  222. 1
  223. 0
  224. 0
  225. 0
  226. 0
  227. 0
  228. 0
  229. 0
  230. 0
  231. 1
  232. 0
  233. 7
  234. 0
  235. 0
  236. 0
  237. 0
  238. 0
  239. 0
  240. 0
  241. 0
  242. 0
  243. 0
  244. 0
  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. 1
  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. 1
  295. 0
  296. 0
  297. 1
  298. 1
  299. 0
  300. 0
  301. 0
  302. 0
  303. 0
  304. 0
  305. 0
  306. 0
  307. 0
  308. 0
  309. 26
  310. 11
  311. 7
  312. 1
  313. 0
  314. 0
  315. 0
  316. 6
  317. 0
  318. 0
  319. 0
  320. 0
  321. 0
  322. 1
  323. 0
  324. 0
  325. 0
  326. 2
  327. 0
  328. 0
  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. 0
  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. 0
  362. 0
  363. 0
  364. 0
  365. 0
  366. 0
  367. 0
  368. 0
  369. 8
  370. 0
  371. 0
  372. 0
  373. 0
  374. 0
  375. 0
  376. 0
  377. 0
  378. 0
  379. 0
  380. 0
  381. 0
  382. 0
  383. 0
  384. 0
  385. 0
  386. 0
  387. 0
  388. 0
  389. 0
  390. 0
  391. 0
  392. 0
  393. 1
  394. 0
  395. 0
  396. 0
  397. 0
  398. 1
  399. 0
  400. 0
  401. 0
  402. 0
  403. 1
  404. 0
  405. 0
  406. 0
  407. 0
  408. 0
  409. 0
  410. 0
  411. 0
  412. 0
  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. 1
  443. 1
  444. 1
  445. 0
  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. 0
  476. 0
  477. 0
  478. 1
  479. 0
  480. 0
  481. 0
  482. 0
  483. 0
  484. 0
  485. 0
  486. 0
  487. 0
  488. 0
  489. 0
  490. 0
  491. 0
  492. 0
  493. 0
  494. 0
  495. 0
  496. 0
  497. 0
  498. 0
  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. 0
  518. 0
  519. 0
  520. 1
  521. 0
  522. 1
  523. 1
  524. 0
  525. 0
  526. 0
  527. 0
  528. 0
  529. 0
  530. 0
  531. 0
  532. 0
  533. 0
  534. 0
  535. 0
  536. 0
  537. 0
  538. 0
  539. 0
  540. 0
  541. 0
  542. 0
  543. 0
  544. 0
  545. 0
  546. 0
  547. 0
  548. 0
  549. 0
  550. 0
  551. 0
  552. 0
  553. 0
  554. 0
  555. 0
  556. 0
  557. 0
  558. 0
  559. 0
  560. 0
  561. 0
  562. 0
  563. 1
  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. 0
  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. 2
  595. 0
  596. 0
  597. 0
  598. 0
  599. 0
  600. 0
  601. 0
  602. 0
  603. 0
  604. 0
  605. 0
  606. 0
  607. 0
  608. 0
  609. 0
  610. 0
  611. 0
  612. 0
  613. 0
  614. 0
  615. 0
  616. 0
  617. 0
  618. 0
  619. 0
  620. 0
  621. 0
  622. 0
  623. 0
  624. 0
  625. 0
  626. 0
  627. 0
  628. 0
  629. 0
  630. 0
  631. 0
  632. 0
  633. 0
  634. 0
  635. 0
  636. 0
  637. 0
  638. 0
  639. 0
  640. 0
  641. 0
  642. 0
  643. 0
  644. 1
  645. 1
  646. 0
  647. 2
  648. 2
  649. 0
  650. 2
  651. 2
  652. 0
  653. 1
  654. 1
  655. 1
  656. 0
  657. 0
  658. 1
  659. 1
  660. 1
  661. 1
  662. 1
  663. 1
  664. 1
  665. 1
  666. 2
  667. 1
  668. 0
  669. 1
  670. 1
  671. 1
  672. 1
  673. 1
  674. 1
  675. 1
  676. 1
  677. 1
  678. 1
  679. 0
  680. 1
  681. 1
  682. 1
  683. 1
  684. 1
  685. 1
  686. 1
  687. 1
  688. 1
  689. 1
  690. 1
  691. 1
  692. 1
  693. 0
  694. 1
  695. 1
  696. 1
  697. 0
  698. 1
  699. 1
  700. 1
  701. 1
  702. 1
  703. 1
  704. 1
  705. 1
  706. 1
  707. 0
  708. 1
  709. 1
  710. 1
  711. 1
  712. 1
  713. 1
  714. 1
  715. 1
  716. 1
  717. 1
  718. 1
  719. 1
  720. 1
  721. 1
  722. 1
  723. 0
  724. 0
  725. 0
  726. 1
  727. 1
  728. 1
  729. 1
  730. 1
  731. 1
  732. 1
  733. 0
  734. 0
  735. 1
  736. 0
  737. 0
  738. 0
  739. 0
  740. 0
  741. 0
  742. 0
  743. 0
  744. 0
  745. 0
  746. 0
  747. 0
  748. 0
  749. 0
  750. 0
  751. 0
  752. 0
  753. 0
  754. 0
  755. 0
  756. 0
  757. 0
  758. 0
  759. 0
  760. 0
  761. 0
  762. 0
  763. 0
  764. 0
  765. 0
  766. 0
  767. 0
  768. 0
  769. 0
  770. 0
  771. 0
  772. 0
  773. 0
  774. 0
  775. 0
  776. 0
  777. 0
  778. 0
  779. 0
  780. 0
  781. 1
  782. 0
  783. 0
  784. 0
  785. 0
  786. 0
  787. 0
  788. 0
  789. 0
  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. 1
  804. 0
  805. 0
  806. 0
  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. 0
  822. 0
  823. 0
  824. 0
  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. 0
  840. 0
  841. 0
  842. 0
  843. 0
  844. 0
  845. 0
  846. 0
  847. 0
  848. 0
  849. 0
  850. 0
  851. 0
  852. 0
  853. 0
  854. 0
  855. 0
  856. 0
  857. 0
  858. 0
  859. 0
  860. 0
  861. 0
  862. 0
  863. 0
  864. 0
  865. 0
  866. 0
  867. 0
  868. 0
  869. 0
  870. 0
  871. 0
  872. 0
  873. 0
  874. 0
  875. 0
  876. 0
  877. 0
  878. 0
  879. 0
  880. 0
  881. 0
  882. 0
  883. 1
  884. 0
  885. 0
  886. 0
  887. 0
  888. 0
  889. 0
  890. 0
  891. 0
  892. 0
  893. 0
  894. 0
  895. 0
  896. 0
  897. 0
  898. 0
  899. 0
  900. 0
  901. 0
  902. 0
  903. 0
  904. 0
  905. 0
  906. 0
  907. 0
  908. 0
  909. 0
  910. 0
  911. 0
  912. 0
  913. 0
  914. 0
  915. 0
  916. 1
  917. 1
  918. 1
  919. 1
  920. 0
  921. 1
  922. 1
  923. 1
  924. 0
  925. 0
  926. 0
  927. 0
  928. 0
  929. 0
  930. 0
  931. 0
  932. 0
  933. 0
  934. 0
  935. 0
  936. 0
  937. 0
  938. 0
  939. 1
  940. 0
  941. 1
  942. 0
  943. 0
  944. 0
  945. 0
  946. 1
  947. 1
  948. 1
  949. 1
  950. 1
  951. 1
  952. 1
  953. 1
  954. 1
  955. 1
  956. 1
  957. 1
  958. 1
  959. 1
  960. 1
  961. 0
  962. 0
  963. 1
  964. 1
  965. 1
  966. 1
  967. 1
  968. 1
  969. 1
  970. 1
  971. 1
  972. 1
  973. 1
  974. 1
  975. 1
  976. 1
  977. 1
  978. 1
  979. 1
  980. 0
  981. 0
  982. 0
  983. 1
  984. 0
  985. 1
  986. 1
  987. 1
  988. 1
  989. 1
  990. 1
  991. 1
  992. 1
  993. 1
  994. 1
  995. 0
  996. 1
  997. 1
  998. 1
  999. 1
  1000. 1
  1001. 1
  1002. 1
  1003. 1
  1004. 1
  1005. 1
  1006. 1
  1007. 0
  1008. 0
  1009. 1
  1010. 1
  1011. 1
  1012. 0
  1013. 1
  1014. 1
  1015. 0
  1016. 1
  1017. 1
  1018. 1
  1019. 1
  1020. 0
  1021. 1
  1022. 0
  1023. 0
  1024. 0
  1025. 0
  1026. 0
  1027. 0
  1028. 0
  1029. 0
  1030. 0
  1031. 0
  1032. 0
  1033. 1
  1034. 1
  1035. 6
  1036. 1
  1037. 1
  1038. 1
  1039. 1
  1040. 1
  1041. 0
  1042. 0
  1043. 0
  1044. 0
  1045. 0
  1046. 2
  1047. 2
  1048. 0
  1049. 2
  1050. 2
  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. 2
  1068. 0
  1069. 2
  1070. 2
  1071. 2
  1072. 1
  1073. 0
  1074. 1
  1075. 1
  1076. 1
  1077. 1
  1078. 0
  1079. 0
  1080. 0
  1081. 0
  1082. 1
  1083. 1
  1084. 1
  1085. 1
  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. 0
  1137. 0
  1138. 0
  1139. 0
  1140. 0
  1141. 0
  1142. 0
  1143. 0
  1144. 0
  1145. 0
  1146. 1
  1147. 2
  1148. 2
  1149. 1
  1150. 1
  1151. 1
  1152. 1
  1153. 1
  1154. 1
  1155. 1
  1156. 1
  1157. 1
  1158. 1
  1159. 2
  1160. 2
  1161. 1
  1162. 0
  1163. 0
  1164. 0
  1165. 0
  1166. 0
  1167. 0
'grp_week_3 average degree = 0.431876606683805'

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

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

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

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


'grp_week_3 average author degree (2 and 4) = 8.2258064516129'
'grp_week_3 average author degree (only 2) = 8.13333333333333'
'grp_week_3 average source degree (3 and 4) = 1.14537444933921'
'grp_week_3 average source degree (only 3) = 1.10176991150442'

grp_week_3 (gw3) - 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 [18]:
# 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?
gw3AutomatedDegreeSd <- sd( gw3AutomatedDegreeVector )
paste( output_prefix, "degree SD =", gw3AutomatedDegreeSd, sep = " " )

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

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

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

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

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

# also add degree vector to original data frame
gw3AutomatedDataDF$betweenness <- gw3AutomatedBetweenness

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

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

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

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

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

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


'grp_week_3 degree SD = 1.66497935492982'
'grp_week_3 degree variance = 2.77215625234251'
'grp_week_3 degree max = 26'
  1. 'grp_week_3 degree frequencies = 910'
  2. 'grp_week_3 degree frequencies = 205'
  3. 'grp_week_3 degree frequencies = 26'
  4. 'grp_week_3 degree frequencies = 1'
  5. 'grp_week_3 degree frequencies = 5'
  6. 'grp_week_3 degree frequencies = 2'
  7. 'grp_week_3 degree frequencies = 4'
  8. 'grp_week_3 degree frequencies = 3'
  9. 'grp_week_3 degree frequencies = 2'
  10. 'grp_week_3 degree frequencies = 1'
  11. 'grp_week_3 degree frequencies = 4'
  12. 'grp_week_3 degree frequencies = 1'
  13. 'grp_week_3 degree frequencies = 1'
  14. 'grp_week_3 degree frequencies = 1'
  15. 'grp_week_3 degree frequencies = 1'
gw3AutomatedDegreeVector
  0   1   2   3   5   6   7   8   9  10  11  14  20  23  26 
910 205  26   1   5   2   4   3   2   1   4   1   1   1   1 
'grp_week_3 degree centrality = 0.021965709405988'
'grp_week_3 betweenness centrality = 0.00207525084843086'
'grp_week_3 connectedness = 0.00449908210494135'
Warning message in sna::gtrans(gw3AutomatedNetworkStatnet, 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_3 transitivity = 0.0366598778004073'
'grp_week_3 density = 0.000370391600929507'

grp_week_3 (gw3) - 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 [19]:
#==============================================================================#
# 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
gw3AutomatedNetworkStatnet

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


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

 Vertex attribute names: 
    betweenness degree person_id person_type vertex.names 

No edge attributes

grp_week_3 (gw3) - 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_3 (gw3) - 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 [20]:
# initialize variables
gw3HumanDataFolder <- paste( data_directory, "/network/grp_month", sep = "" )
gw3HumanDataFile <- "sourcenet_data-20180326-034548-grp_month-human-week3_subset.tab"
gw3HumanDataPath <- paste( gw3HumanDataFolder, "/", gw3HumanDataFile, sep = "" )

In [21]:
gw3HumanDataPath


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

Load the data file into memory


In [22]:
# tab-delimited:
gw3HumanDataDF <- read.delim( gw3HumanDataPath, header = TRUE, row.names = 1, check.names = FALSE )

In [23]:
# get count of rows...
gw3HumanRowCount <- nrow( gw3HumanDataDF )
paste( output_prefix, "automated row count =", gw3HumanRowCount, sep = " " )

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


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

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


In [24]:
# 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.
gw3HumanNetworkDF <- gw3HumanDataDF[ , 1 : gw3HumanRowCount ]
#str( gw3HumanNetworkDF )

In [25]:
# convert to a matrix
gw3HumanNetworkMatrix <- as.matrix( gw3HumanNetworkDF )
# str( gw3HumanNetworkMatrix )

grp_week_3 (gw3) - human - initialize statnet

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

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


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

In [27]:
# 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
#gw3HumanNetworkAttributeDF <- gw3HumanDataDF[ , 1169:1170 ]
gw3HumanNetworkAttributeDF <- gw3HumanDataDF[ , 1168:1169 ]

# convert matrix to statnet network object instance.
gw3HumanNetworkStatnet <- network( gw3HumanNetworkMatrix, matrix.type = "adjacency", directed = FALSE, vertex.attr = gw3HumanNetworkAttributeDF )

# look at information now.
gw3HumanNetworkStatnet

# 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= 266 
    missing edges= 0 
    non-missing edges= 266 

 Vertex attribute names: 
    person_id person_type vertex.names 

No edge attributes

In [28]:
# human - include ties Greater than or equal to 0 (GE0)
gw3HumanMeanTieWeightGE0Vector <- apply( gw3HumanNetworkMatrix, 1, calculateListMean )
gw3HumanDataDF$meanTieWeightGE0 <- gw3HumanMeanTieWeightGE0Vector

# human - include ties Greater than or equal to 1 (GE1)
gw3HumanMeanTieWeightGE1Vector <- apply( gw3HumanNetworkMatrix, 1, calculateListMean, minValueToIncludeIN = 1 )
gw3HumanDataDF$meanTieWeightGE1 <- gw3HumanMeanTieWeightGE1Vector

# human - Max tie weight?
gw3HumanMaxTieWeightVector <- apply( gw3HumanNetworkMatrix, 1, calculateListMax )
gw3HumanDataDF$maxTieWeight <- gw3HumanMaxTieWeightVector

grp_week_3 (gw3) - human - Basic metrics


In [29]:
# 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:
gw3HumanDegreeVector <- sna::degree( gw3HumanNetworkStatnet, gmode = "graph" )

# output the vector
gw3HumanDegreeVector

# 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?
gw3HumanAvgDegree <- mean( gw3HumanDegreeVector )
paste( output_prefix, "average degree =", gw3HumanAvgDegree, sep = " " )

# subset vector to get only those that are above mean
gw3HumanAboveMeanVector <- gw3HumanDegreeVector[ gw3HumanDegreeVector > gw3HumanAvgDegree ]

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

# also add degree vector to original data frame
gw3HumanDataDF$degree <- gw3HumanDegreeVector


  1. 4
  2. 0
  3. 8
  4. 0
  5. 10
  6. 0
  7. 0
  8. 8
  9. 9
  10. 0
  11. 3
  12. 0
  13. 11
  14. 0
  15. 0
  16. 26
  17. 2
  18. 0
  19. 0
  20. 9
  21. 0
  22. 2
  23. 0
  24. 0
  25. 1
  26. 1
  27. 6
  28. 0
  29. 0
  30. 0
  31. 0
  32. 0
  33. 0
  34. 0
  35. 0
  36. 0
  37. 0
  38. 11
  39. 0
  40. 0
  41. 0
  42. 0
  43. 1
  44. 0
  45. 1
  46. 0
  47. 0
  48. 0
  49. 13
  50. 0
  51. 0
  52. 6
  53. 0
  54. 0
  55. 0
  56. 0
  57. 0
  58. 0
  59. 0
  60. 0
  61. 0
  62. 0
  63. 0
  64. 0
  65. 0
  66. 0
  67. 0
  68. 0
  69. 2
  70. 0
  71. 0
  72. 5
  73. 0
  74. 0
  75. 2
  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. 0
  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. 1
  122. 0
  123. 0
  124. 0
  125. 0
  126. 0
  127. 0
  128. 0
  129. 0
  130. 0
  131. 0
  132. 0
  133. 0
  134. 0
  135. 0
  136. 0
  137. 0
  138. 0
  139. 0
  140. 0
  141. 0
  142. 0
  143. 0
  144. 7
  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. 1
  162. 0
  163. 0
  164. 0
  165. 0
  166. 0
  167. 0
  168. 0
  169. 0
  170. 0
  171. 0
  172. 0
  173. 1
  174. 0
  175. 0
  176. 8
  177. 12
  178. 1
  179. 1
  180. 0
  181. 0
  182. 0
  183. 22
  184. 0
  185. 0
  186. 0
  187. 0
  188. 0
  189. 0
  190. 0
  191. 0
  192. 0
  193. 0
  194. 0
  195. 0
  196. 0
  197. 2
  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. 2
  211. 0
  212. 0
  213. 0
  214. 0
  215. 0
  216. 0
  217. 0
  218. 0
  219. 0
  220. 0
  221. 0
  222. 1
  223. 0
  224. 0
  225. 0
  226. 0
  227. 0
  228. 0
  229. 0
  230. 0
  231. 1
  232. 0
  233. 9
  234. 0
  235. 0
  236. 0
  237. 0
  238. 0
  239. 0
  240. 0
  241. 0
  242. 0
  243. 0
  244. 0
  245. 0
  246. 0
  247. 0
  248. 0
  249. 1
  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. 1
  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. 1
  295. 0
  296. 0
  297. 1
  298. 1
  299. 0
  300. 0
  301. 0
  302. 0
  303. 0
  304. 0
  305. 0
  306. 0
  307. 0
  308. 0
  309. 28
  310. 10
  311. 7
  312. 1
  313. 0
  314. 0
  315. 0
  316. 9
  317. 0
  318. 0
  319. 0
  320. 1
  321. 0
  322. 1
  323. 0
  324. 0
  325. 0
  326. 2
  327. 0
  328. 0
  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. 0
  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. 0
  362. 0
  363. 1
  364. 0
  365. 0
  366. 0
  367. 0
  368. 0
  369. 7
  370. 0
  371. 0
  372. 0
  373. 0
  374. 0
  375. 0
  376. 0
  377. 0
  378. 0
  379. 0
  380. 0
  381. 0
  382. 0
  383. 0
  384. 0
  385. 0
  386. 0
  387. 0
  388. 0
  389. 0
  390. 0
  391. 0
  392. 0
  393. 0
  394. 0
  395. 0
  396. 0
  397. 0
  398. 1
  399. 0
  400. 0
  401. 0
  402. 0
  403. 1
  404. 0
  405. 0
  406. 0
  407. 0
  408. 0
  409. 0
  410. 0
  411. 0
  412. 0
  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. 1
  443. 1
  444. 1
  445. 0
  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. 0
  476. 0
  477. 0
  478. 1
  479. 0
  480. 0
  481. 0
  482. 0
  483. 0
  484. 0
  485. 0
  486. 0
  487. 0
  488. 0
  489. 0
  490. 0
  491. 0
  492. 0
  493. 0
  494. 0
  495. 0
  496. 0
  497. 0
  498. 0
  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. 0
  518. 0
  519. 0
  520. 1
  521. 0
  522. 1
  523. 1
  524. 0
  525. 0
  526. 0
  527. 0
  528. 0
  529. 0
  530. 0
  531. 0
  532. 0
  533. 0
  534. 0
  535. 0
  536. 0
  537. 0
  538. 0
  539. 0
  540. 0
  541. 0
  542. 0
  543. 0
  544. 0
  545. 0
  546. 0
  547. 0
  548. 0
  549. 0
  550. 0
  551. 0
  552. 0
  553. 0
  554. 0
  555. 0
  556. 0
  557. 0
  558. 0
  559. 0
  560. 0
  561. 0
  562. 0
  563. 1
  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. 0
  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. 2
  595. 0
  596. 0
  597. 0
  598. 0
  599. 0
  600. 0
  601. 0
  602. 0
  603. 0
  604. 0
  605. 0
  606. 0
  607. 0
  608. 0
  609. 0
  610. 0
  611. 0
  612. 0
  613. 0
  614. 0
  615. 0
  616. 0
  617. 0
  618. 0
  619. 0
  620. 0
  621. 0
  622. 0
  623. 0
  624. 0
  625. 0
  626. 1
  627. 0
  628. 0
  629. 0
  630. 0
  631. 0
  632. 0
  633. 0
  634. 0
  635. 0
  636. 0
  637. 0
  638. 0
  639. 0
  640. 0
  641. 0
  642. 0
  643. 0
  644. 1
  645. 1
  646. 1
  647. 2
  648. 2
  649. 2
  650. 2
  651. 2
  652. 0
  653. 1
  654. 1
  655. 1
  656. 1
  657. 1
  658. 1
  659. 1
  660. 1
  661. 1
  662. 1
  663. 1
  664. 1
  665. 1
  666. 2
  667. 1
  668. 1
  669. 1
  670. 1
  671. 1
  672. 1
  673. 1
  674. 1
  675. 1
  676. 1
  677. 1
  678. 1
  679. 1
  680. 1
  681. 1
  682. 1
  683. 1
  684. 1
  685. 1
  686. 1
  687. 1
  688. 1
  689. 1
  690. 1
  691. 1
  692. 1
  693. 1
  694. 1
  695. 1
  696. 1
  697. 1
  698. 1
  699. 1
  700. 1
  701. 1
  702. 1
  703. 1
  704. 1
  705. 1
  706. 1
  707. 1
  708. 1
  709. 1
  710. 1
  711. 1
  712. 1
  713. 1
  714. 1
  715. 1
  716. 1
  717. 1
  718. 1
  719. 1
  720. 1
  721. 1
  722. 1
  723. 1
  724. 1
  725. 1
  726. 1
  727. 1
  728. 1
  729. 1
  730. 1
  731. 1
  732. 1
  733. 0
  734. 1
  735. 1
  736. 1
  737. 0
  738. 0
  739. 0
  740. 0
  741. 0
  742. 0
  743. 0
  744. 0
  745. 0
  746. 0
  747. 0
  748. 0
  749. 0
  750. 0
  751. 0
  752. 0
  753. 0
  754. 0
  755. 0
  756. 0
  757. 0
  758. 0
  759. 0
  760. 0
  761. 0
  762. 0
  763. 0
  764. 0
  765. 0
  766. 0
  767. 0
  768. 0
  769. 0
  770. 0
  771. 0
  772. 0
  773. 0
  774. 0
  775. 0
  776. 0
  777. 0
  778. 0
  779. 0
  780. 0
  781. 1
  782. 0
  783. 0
  784. 0
  785. 0
  786. 0
  787. 0
  788. 0
  789. 0
  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. 1
  804. 0
  805. 0
  806. 0
  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. 0
  822. 0
  823. 0
  824. 0
  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. 0
  840. 0
  841. 0
  842. 0
  843. 0
  844. 0
  845. 0
  846. 0
  847. 0
  848. 0
  849. 0
  850. 0
  851. 0
  852. 0
  853. 0
  854. 0
  855. 0
  856. 0
  857. 0
  858. 0
  859. 0
  860. 0
  861. 0
  862. 0
  863. 0
  864. 0
  865. 0
  866. 0
  867. 0
  868. 0
  869. 0
  870. 0
  871. 0
  872. 0
  873. 0
  874. 0
  875. 0
  876. 0
  877. 0
  878. 0
  879. 0
  880. 0
  881. 0
  882. 0
  883. 1
  884. 0
  885. 0
  886. 0
  887. 0
  888. 0
  889. 0
  890. 0
  891. 0
  892. 0
  893. 0
  894. 0
  895. 0
  896. 0
  897. 0
  898. 0
  899. 0
  900. 0
  901. 0
  902. 0
  903. 0
  904. 0
  905. 0
  906. 0
  907. 0
  908. 0
  909. 0
  910. 0
  911. 0
  912. 0
  913. 0
  914. 0
  915. 0
  916. 1
  917. 1
  918. 1
  919. 1
  920. 1
  921. 1
  922. 1
  923. 1
  924. 0
  925. 0
  926. 0
  927. 0
  928. 0
  929. 0
  930. 0
  931. 0
  932. 0
  933. 0
  934. 0
  935. 0
  936. 0
  937. 0
  938. 0
  939. 1
  940. 0
  941. 1
  942. 0
  943. 0
  944. 0
  945. 1
  946. 1
  947. 1
  948. 1
  949. 1
  950. 1
  951. 1
  952. 1
  953. 1
  954. 1
  955. 1
  956. 1
  957. 1
  958. 1
  959. 1
  960. 1
  961. 1
  962. 1
  963. 1
  964. 1
  965. 1
  966. 1
  967. 1
  968. 1
  969. 1
  970. 1
  971. 1
  972. 1
  973. 1
  974. 1
  975. 1
  976. 1
  977. 1
  978. 1
  979. 1
  980. 1
  981. 1
  982. 1
  983. 1
  984. 1
  985. 1
  986. 1
  987. 1
  988. 1
  989. 1
  990. 1
  991. 1
  992. 1
  993. 1
  994. 1
  995. 1
  996. 1
  997. 1
  998. 1
  999. 1
  1000. 1
  1001. 1
  1002. 1
  1003. 1
  1004. 1
  1005. 1
  1006. 0
  1007. 0
  1008. 0
  1009. 1
  1010. 1
  1011. 1
  1012. 1
  1013. 0
  1014. 1
  1015. 1
  1016. 1
  1017. 1
  1018. 1
  1019. 1
  1020. 0
  1021. 1
  1022. 0
  1023. 0
  1024. 0
  1025. 0
  1026. 0
  1027. 0
  1028. 0
  1029. 0
  1030. 0
  1031. 0
  1032. 1
  1033. 1
  1034. 1
  1035. 5
  1036. 1
  1037. 1
  1038. 1
  1039. 1
  1040. 1
  1041. 0
  1042. 0
  1043. 0
  1044. 0
  1045. 0
  1046. 2
  1047. 2
  1048. 0
  1049. 2
  1050. 2
  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. 2
  1068. 2
  1069. 2
  1070. 2
  1071. 2
  1072. 1
  1073. 1
  1074. 1
  1075. 1
  1076. 1
  1077. 1
  1078. 0
  1079. 0
  1080. 0
  1081. 0
  1082. 1
  1083. 1
  1084. 1
  1085. 1
  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. 0
  1137. 0
  1138. 0
  1139. 0
  1140. 0
  1141. 0
  1142. 0
  1143. 0
  1144. 0
  1145. 0
  1146. 0
  1147. 0
  1148. 0
  1149. 0
  1150. 1
  1151. 0
  1152. 0
  1153. 0
  1154. 0
  1155. 0
  1156. 0
  1157. 0
  1158. 0
  1159. 2
  1160. 0
  1161. 1
  1162. 0
  1163. 0
  1164. 0
  1165. 0
  1166. 0
  1167. 0
'grp_week_3 average degree = 0.455869751499572'

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

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

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

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


'grp_week_3 average author degree (2 and 4) = 8.67741935483871'
'grp_week_3 average author degree (only 2) = 8.67741935483871'
'grp_week_3 average source degree (3 and 4) = 1.08677685950413'
'grp_week_3 average source degree (only 3) = 1.08677685950413'

grp_week_3 (gw3) - 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 [31]:
# 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?
gw3HumanDegreeSd <- sd( gw3HumanDegreeVector )
paste( output_prefix, "degree SD =", gw3HumanDegreeSd, sep = " " )

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

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

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

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

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

# also add degree vector to original data frame
gw3HumanDataDF$betweenness <- gw3HumanBetweenness

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

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

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

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

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

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


'grp_week_3 degree SD = 1.76915570666071'
'grp_week_3 degree variance = 3.12991191441014'
'grp_week_3 degree max = 28'
  1. 'grp_week_3 degree frequencies = 894'
  2. 'grp_week_3 degree frequencies = 223'
  3. 'grp_week_3 degree frequencies = 24'
  4. 'grp_week_3 degree frequencies = 1'
  5. 'grp_week_3 degree frequencies = 1'
  6. 'grp_week_3 degree frequencies = 2'
  7. 'grp_week_3 degree frequencies = 2'
  8. 'grp_week_3 degree frequencies = 3'
  9. 'grp_week_3 degree frequencies = 4'
  10. 'grp_week_3 degree frequencies = 4'
  11. 'grp_week_3 degree frequencies = 2'
  12. 'grp_week_3 degree frequencies = 2'
  13. 'grp_week_3 degree frequencies = 1'
  14. 'grp_week_3 degree frequencies = 1'
  15. 'grp_week_3 degree frequencies = 1'
  16. 'grp_week_3 degree frequencies = 1'
  17. 'grp_week_3 degree frequencies = 1'
gw3HumanDegreeVector
  0   1   2   3   4   5   6   7   8   9  10  11  12  13  22  26  28 
894 223  24   1   1   2   2   3   4   4   2   2   1   1   1   1   1 
'grp_week_3 degree centrality = 0.0236633072976097'
'grp_week_3 betweenness centrality = 0.00244100519713978'
'grp_week_3 connectedness = 0.00510170336042189'
Warning message in sna::gtrans(gw3HumanNetworkStatnet, 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_3 transitivity = 0.0303571428571429'
'grp_week_3 density = 0.000390968912092257'

grp_week_3 (gw3) - 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 [32]:
#==============================================================================#
# 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
gw3HumanNetworkStatnet

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


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

 Vertex attribute names: 
    betweenness degree person_id person_type vertex.names 

No edge attributes

grp_week_3 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_3 a2b"

In [9]:
grpWeek3a2bOutput <- compareMatricesQAP( gw3HumanNetworkMatrix, gw3AutomatedNetworkMatrix, outputPrefix )


==> Start of  compareMatricesQAP  at  2019-07-25 14:06:13
----> grp_week_3 a2b graph correlation = 0.898065381427003 ( @ 2019-07-25 14:06:14 )
----> grp_week_3 a2b QAP correlation analysis complete at 2019-07-25 14:09: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.8980654 
	Replications: 1000 
	Distribution Summary:
		Min:	 -0.0003738666 
		1stQ:	 -0.0003738666 
		Med:	 -0.0003738666 
		Mean:	 -1.229954e-05 
		3rdQ:	 -0.0003738666 
		Max:	 0.0142349 

----> grp_week_3 a2b graph covariance = 0.000361422558020915 ( @ 2019-07-25 14:09:17 )
----> grp_week_3 a2b QAP covariance analysis complete at 2019-07-25 14:12:18.  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.0003614226 
	Replications: 1000 
	Distribution Summary:
		Min:	 -1.50461e-07 
		1stQ:	 -1.50461e-07 
		Med:	 -1.50461e-07 
		Mean:	 -1.376875e-08 
		3rdQ:	 -1.50461e-07 
		Max:	 2.789157e-06 

----> grp_week_3 a2b graph hamming distance = 112 ( @ 2019-07-25 14:12:19 )
----> grp_week_3 a2b QAP hamming distance analysis complete at 2019-07-25 14:15: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)): 112 
	Replications: 1000 
	Distribution Summary:
		Min:	 1048 
		1stQ:	 1056 
		Med:	 1056 
		Mean:	 1055.56 
		3rdQ:	 1056 
		Max:	 1056 

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

In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( grpWeek3a2bOutput, 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