R - statnet - grp_month - week 1

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 1

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

Files:

  • automated week 1 subset - sourcenet_data-20171206-031358-grp_month-automated-week1_subset.tab
  • human week 1 subset - sourcenet_data-20171206-031319-grp_month-human-week1_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_1 analysis

Look at a single week from the shiny new month of data.


In [6]:
output_prefix <- "grp_week_1"

grp_week_1 (gw1) - 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_1 (gw1) - 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
gw1AutomatedDataFolder <- paste( data_directory, "/network/grp_month", sep = "" )
gw1AutomatedDataFile <- "sourcenet_data-20171206-031358-grp_month-automated-week1_subset.tab"
gw1AutomatedDataPath <- paste( gw1AutomatedDataFolder, "/", gw1AutomatedDataFile, sep = "" )

In [8]:
gw1AutomatedDataPath


'/home/jonathanmorgan/work/django/research/work/phd_work/methods/data/network/grp_month/sourcenet_data-20171206-031358-grp_month-automated-week1_subset.tab'

Load the data file into memory


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

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

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


'grp_week_1 automated row count = 1167'
'grp_week_1 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.
gw1AutomatedNetworkDF <- gw1AutomatedDataDF[ , 1 : gw1AutomatedRowCount ]
#str( gw1AutomatedNetworkDF )

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

grp_week_1 (gw1) - automated - initialize statnet

First, load the statnet package, then load the automated grp_month week 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
gw1AutomatedNetworkAttributeDF <- gw1AutomatedDataDF[ , 1168:1169 ]

# convert matrix to statnet network object instance.
gw1AutomatedNetworkStatnet <- network( gw1AutomatedNetworkMatrix, matrix.type = "adjacency", directed = FALSE, vertex.attr = gw1AutomatedNetworkAttributeDF )

# look at information now.
gw1AutomatedNetworkStatnet

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

 Vertex attribute names: 
    person_id person_type vertex.names 

No edge attributes

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

# calais - include ties Greater than or equal to 1 (GE1)
gw1AutomatedMeanTieWeightGE1Vector <- apply( gw1AutomatedNetworkMatrix, 1, calculateListMean, minValueToIncludeIN = 1 )
gw1AutomatedDataDF$meanTieWeightGE1 <- gw1AutomatedMeanTieWeightGE1Vector

# automated - Max tie weight?
gw1AutomatedMaxTieWeightVector <- apply( gw1AutomatedNetworkMatrix, 1, calculateListMax )
gw1AutomatedDataDF$maxTieWeight <- gw1AutomatedMaxTieWeightVector

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

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

# output the vector
gw1AutomatedDegreeVector

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

# subset vector to get only those that are above mean
gw1AutomatedAboveMeanVector <- gw1AutomatedDegreeVector[ gw1AutomatedDegreeVector > gw1AutomatedAvgDegree ]

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

# also add degree vector to original data frame
gw1AutomatedDataDF$degree <- gw1AutomatedDegreeVector


  1. 5
  2. 0
  3. 14
  4. 0
  5. 11
  6. 1
  7. 1
  8. 10
  9. 9
  10. 0
  11. 15
  12. 1
  13. 24
  14. 0
  15. 0
  16. 17
  17. 23
  18. 6
  19. 15
  20. 18
  21. 1
  22. 3
  23. 0
  24. 1
  25. 1
  26. 0
  27. 15
  28. 0
  29. 2
  30. 2
  31. 2
  32. 2
  33. 1
  34. 1
  35. 1
  36. 1
  37. 1
  38. 12
  39. 1
  40. 0
  41. 1
  42. 1
  43. 0
  44. 1
  45. 3
  46. 0
  47. 0
  48. 1
  49. 10
  50. 0
  51. 0
  52. 6
  53. 0
  54. 1
  55. 1
  56. 1
  57. 1
  58. 0
  59. 1
  60. 1
  61. 1
  62. 1
  63. 1
  64. 1
  65. 0
  66. 0
  67. 0
  68. 1
  69. 1
  70. 1
  71. 1
  72. 17
  73. 0
  74. 1
  75. 1
  76. 1
  77. 1
  78. 1
  79. 1
  80. 1
  81. 1
  82. 1
  83. 1
  84. 1
  85. 1
  86. 1
  87. 1
  88. 1
  89. 1
  90. 1
  91. 1
  92. 1
  93. 3
  94. 1
  95. 1
  96. 1
  97. 9
  98. 1
  99. 1
  100. 1
  101. 1
  102. 1
  103. 1
  104. 2
  105. 4
  106. 0
  107. 0
  108. 0
  109. 0
  110. 1
  111. 1
  112. 1
  113. 0
  114. 1
  115. 1
  116. 2
  117. 0
  118. 2
  119. 2
  120. 1
  121. 1
  122. 1
  123. 1
  124. 1
  125. 1
  126. 1
  127. 1
  128. 1
  129. 1
  130. 1
  131. 0
  132. 1
  133. 1
  134. 2
  135. 1
  136. 1
  137. 1
  138. 1
  139. 1
  140. 1
  141. 0
  142. 1
  143. 1
  144. 5
  145. 1
  146. 1
  147. 1
  148. 1
  149. 1
  150. 1
  151. 6
  152. 1
  153. 1
  154. 1
  155. 0
  156. 1
  157. 1
  158. 1
  159. 1
  160. 1
  161. 2
  162. 1
  163. 1
  164. 1
  165. 1
  166. 1
  167. 1
  168. 1
  169. 1
  170. 1
  171. 1
  172. 1
  173. 0
  174. 1
  175. 1
  176. 6
  177. 0
  178. 0
  179. 0
  180. 0
  181. 1
  182. 1
  183. 4
  184. 1
  185. 1
  186. 1
  187. 1
  188. 1
  189. 1
  190. 1
  191. 1
  192. 1
  193. 1
  194. 1
  195. 1
  196. 1
  197. 1
  198. 0
  199. 1
  200. 1
  201. 1
  202. 1
  203. 1
  204. 1
  205. 1
  206. 1
  207. 1
  208. 1
  209. 1
  210. 1
  211. 1
  212. 2
  213. 2
  214. 0
  215. 2
  216. 2
  217. 1
  218. 0
  219. 1
  220. 1
  221. 1
  222. 1
  223. 1
  224. 1
  225. 1
  226. 0
  227. 1
  228. 1
  229. 1
  230. 1
  231. 1
  232. 1
  233. 3
  234. 1
  235. 0
  236. 1
  237. 1
  238. 2
  239. 2
  240. 2
  241. 0
  242. 2
  243. 2
  244. 1
  245. 1
  246. 0
  247. 1
  248. 1
  249. 1
  250. 1
  251. 1
  252. 1
  253. 1
  254. 1
  255. 1
  256. 1
  257. 1
  258. 1
  259. 1
  260. 1
  261. 1
  262. 1
  263. 1
  264. 1
  265. 1
  266. 1
  267. 1
  268. 1
  269. 1
  270. 1
  271. 1
  272. 1
  273. 1
  274. 0
  275. 0
  276. 0
  277. 2
  278. 2
  279. 2
  280. 2
  281. 1
  282. 1
  283. 1
  284. 1
  285. 1
  286. 1
  287. 1
  288. 1
  289. 1
  290. 1
  291. 2
  292. 1
  293. 0
  294. 1
  295. 0
  296. 1
  297. 1
  298. 1
  299. 1
  300. 1
  301. 1
  302. 1
  303. 0
  304. 1
  305. 1
  306. 1
  307. 0
  308. 1
  309. 21
  310. 0
  311. 8
  312. 0
  313. 0
  314. 0
  315. 0
  316. 0
  317. 0
  318. 0
  319. 0
  320. 0
  321. 0
  322. 0
  323. 0
  324. 0
  325. 0
  326. 0
  327. 0
  328. 1
  329. 1
  330. 1
  331. 1
  332. 0
  333. 0
  334. 0
  335. 1
  336. 1
  337. 1
  338. 1
  339. 1
  340. 1
  341. 1
  342. 1
  343. 2
  344. 1
  345. 0
  346. 1
  347. 1
  348. 1
  349. 1
  350. 1
  351. 1
  352. 0
  353. 1
  354. 1
  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. 3
  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. 0
  399. 0
  400. 0
  401. 0
  402. 0
  403. 0
  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. 0
  443. 0
  444. 0
  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. 1
  480. 1
  481. 1
  482. 1
  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. 0
  521. 0
  522. 0
  523. 0
  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. 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. 0
  577. 0
  578. 0
  579. 0
  580. 1
  581. 1
  582. 0
  583. 0
  584. 0
  585. 0
  586. 0
  587. 0
  588. 0
  589. 0
  590. 0
  591. 0
  592. 0
  593. 0
  594. 0
  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. 2
  612. 1
  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. 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. 0
  667. 0
  668. 0
  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. 1
  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. 0
  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. 0
  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. 0
  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. 0
  917. 0
  918. 0
  919. 0
  920. 0
  921. 0
  922. 0
  923. 0
  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. 0
  940. 0
  941. 0
  942. 0
  943. 0
  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. 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. 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_1 average degree = 0.510711225364182'

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

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

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

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


'grp_week_1 average author degree (2 and 4) = 9.46875'
'grp_week_1 average author degree (only 2) = 9.46875'
'grp_week_1 average source degree (3 and 4) = 1.11406844106464'
'grp_week_1 average source degree (only 3) = 1.11406844106464'

grp_week_1 (gw1) - 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?
gw1AutomatedDegreeSd <- sd( gw1AutomatedDegreeVector )
paste( output_prefix, "degree SD =", gw1AutomatedDegreeSd, sep = " " )

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

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

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

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

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

# also add degree vector to original data frame
gw1AutomatedDataDF$betweenness <- gw1AutomatedBetweenness

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

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

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

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

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

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


'grp_week_1 degree SD = 1.92474544655479'
'grp_week_1 degree variance = 3.7046450340334'
'grp_week_1 degree max = 24'
  1. 'grp_week_1 degree frequencies = 872'
  2. 'grp_week_1 degree frequencies = 239'
  3. 'grp_week_1 degree frequencies = 26'
  4. 'grp_week_1 degree frequencies = 5'
  5. 'grp_week_1 degree frequencies = 2'
  6. 'grp_week_1 degree frequencies = 2'
  7. 'grp_week_1 degree frequencies = 4'
  8. 'grp_week_1 degree frequencies = 1'
  9. 'grp_week_1 degree frequencies = 2'
  10. 'grp_week_1 degree frequencies = 2'
  11. 'grp_week_1 degree frequencies = 1'
  12. 'grp_week_1 degree frequencies = 1'
  13. 'grp_week_1 degree frequencies = 1'
  14. 'grp_week_1 degree frequencies = 3'
  15. 'grp_week_1 degree frequencies = 2'
  16. 'grp_week_1 degree frequencies = 1'
  17. 'grp_week_1 degree frequencies = 1'
  18. 'grp_week_1 degree frequencies = 1'
  19. 'grp_week_1 degree frequencies = 1'
gw1AutomatedDegreeVector
  0   1   2   3   4   5   6   8   9  10  11  12  14  15  17  18  21  23  24 
872 239  26   5   2   2   4   1   2   2   1   1   1   3   2   1   1   1   1 
'grp_week_1 degree centrality = 0.0201797716414285'
'grp_week_1 betweenness centrality = 0.00454678734613902'
'grp_week_1 connectedness = 0.00801192308201087'
Warning message in sna::gtrans(gw1AutomatedNetworkStatnet, 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_1 transitivity = 0.0372393247269116'
'grp_week_1 density = 0.000438002766178543'

grp_week_1 (gw1) - 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
gw1AutomatedNetworkStatnet

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


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

 Vertex attribute names: 
    betweenness degree person_id person_type vertex.names 

No edge attributes

grp_week_1 (gw1) - 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_1 (gw1) - 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
gw1HumanDataFolder <- paste( data_directory, "/network/grp_month", sep = "" )
gw1HumanDataFile <- "sourcenet_data-20171206-031319-grp_month-human-week1_subset.tab"
gw1HumanDataPath <- paste( gw1HumanDataFolder, "/", gw1HumanDataFile, sep = "" )

In [21]:
gw1HumanDataPath


'/home/jonathanmorgan/work/django/research/work/phd_work/methods/data/network/grp_month/sourcenet_data-20171206-031319-grp_month-human-week1_subset.tab'

Load the data file into memory


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

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

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


'grp_week_1 automated row count = 1167'
'grp_week_1 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.
gw1HumanNetworkDF <- gw1HumanDataDF[ , 1 : gw1HumanRowCount ]
#str( gw1HumanNetworkDF )

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

grp_week_1 (gw1) - 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 [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
#gw1HumanNetworkAttributeDF <- gw1HumanDataDF[ , 1169:1170 ]
gw1HumanNetworkAttributeDF <- gw1HumanDataDF[ , 1168:1169 ]

# convert matrix to statnet network object instance.
gw1HumanNetworkStatnet <- network( gw1HumanNetworkMatrix, matrix.type = "adjacency", directed = FALSE, vertex.attr = gw1HumanNetworkAttributeDF )

# look at information now.
gw1HumanNetworkStatnet

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

 Vertex attribute names: 
    person_id person_type vertex.names 

No edge attributes

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

# human - include ties Greater than or equal to 1 (GE1)
gw1HumanMeanTieWeightGE1Vector <- apply( gw1HumanNetworkMatrix, 1, calculateListMean, minValueToIncludeIN = 1 )
gw1HumanDataDF$meanTieWeightGE1 <- gw1HumanMeanTieWeightGE1Vector

# human - Max tie weight?
gw1HumanMaxTieWeightVector <- apply( gw1HumanNetworkMatrix, 1, calculateListMax )
gw1HumanDataDF$maxTieWeight <- gw1HumanMaxTieWeightVector

grp_week_1 (gw1) - 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:
gw1HumanDegreeVector <- sna::degree( gw1HumanNetworkStatnet, gmode = "graph" )

# output the vector
gw1HumanDegreeVector

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

# subset vector to get only those that are above mean
gw1HumanAboveMeanVector <- gw1HumanDegreeVector[ gw1HumanDegreeVector > gw1HumanAvgDegree ]

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

# also add degree vector to original data frame
gw1HumanDataDF$degree <- gw1HumanDegreeVector


  1. 6
  2. 0
  3. 14
  4. 0
  5. 13
  6. 0
  7. 1
  8. 11
  9. 10
  10. 1
  11. 18
  12. 1
  13. 36
  14. 0
  15. 0
  16. 21
  17. 23
  18. 6
  19. 16
  20. 20
  21. 1
  22. 3
  23. 0
  24. 1
  25. 1
  26. 0
  27. 17
  28. 2
  29. 2
  30. 2
  31. 2
  32. 2
  33. 1
  34. 1
  35. 1
  36. 1
  37. 1
  38. 13
  39. 1
  40. 1
  41. 1
  42. 1
  43. 0
  44. 1
  45. 5
  46. 0
  47. 0
  48. 1
  49. 11
  50. 0
  51. 0
  52. 8
  53. 2
  54. 1
  55. 1
  56. 1
  57. 1
  58. 0
  59. 1
  60. 1
  61. 0
  62. 1
  63. 1
  64. 1
  65. 1
  66. 0
  67. 0
  68. 1
  69. 1
  70. 1
  71. 1
  72. 16
  73. 0
  74. 1
  75. 1
  76. 1
  77. 1
  78. 1
  79. 1
  80. 1
  81. 1
  82. 1
  83. 1
  84. 1
  85. 1
  86. 1
  87. 1
  88. 1
  89. 1
  90. 1
  91. 1
  92. 1
  93. 3
  94. 1
  95. 1
  96. 1
  97. 9
  98. 1
  99. 1
  100. 1
  101. 1
  102. 1
  103. 1
  104. 2
  105. 6
  106. 1
  107. 0
  108. 0
  109. 0
  110. 1
  111. 1
  112. 1
  113. 1
  114. 1
  115. 1
  116. 2
  117. 2
  118. 2
  119. 2
  120. 1
  121. 1
  122. 1
  123. 1
  124. 1
  125. 1
  126. 1
  127. 1
  128. 1
  129. 1
  130. 1
  131. 1
  132. 1
  133. 1
  134. 2
  135. 1
  136. 1
  137. 1
  138. 1
  139. 1
  140. 2
  141. 1
  142. 1
  143. 1
  144. 5
  145. 1
  146. 1
  147. 1
  148. 1
  149. 1
  150. 1
  151. 7
  152. 1
  153. 1
  154. 1
  155. 1
  156. 1
  157. 1
  158. 1
  159. 1
  160. 1
  161. 2
  162. 1
  163. 1
  164. 1
  165. 1
  166. 1
  167. 1
  168. 1
  169. 1
  170. 1
  171. 1
  172. 1
  173. 0
  174. 1
  175. 1
  176. 6
  177. 0
  178. 0
  179. 0
  180. 0
  181. 1
  182. 1
  183. 4
  184. 1
  185. 1
  186. 1
  187. 1
  188. 1
  189. 1
  190. 1
  191. 1
  192. 1
  193. 1
  194. 1
  195. 1
  196. 1
  197. 0
  198. 0
  199. 1
  200. 1
  201. 1
  202. 1
  203. 1
  204. 1
  205. 1
  206. 1
  207. 1
  208. 1
  209. 1
  210. 1
  211. 1
  212. 4
  213. 4
  214. 4
  215. 4
  216. 4
  217. 1
  218. 0
  219. 1
  220. 1
  221. 1
  222. 1
  223. 1
  224. 1
  225. 1
  226. 1
  227. 1
  228. 1
  229. 1
  230. 1
  231. 1
  232. 1
  233. 4
  234. 1
  235. 1
  236. 1
  237. 1
  238. 2
  239. 2
  240. 2
  241. 2
  242. 2
  243. 2
  244. 1
  245. 1
  246. 0
  247. 1
  248. 1
  249. 1
  250. 1
  251. 1
  252. 1
  253. 1
  254. 1
  255. 1
  256. 1
  257. 1
  258. 1
  259. 1
  260. 1
  261. 2
  262. 1
  263. 1
  264. 1
  265. 1
  266. 1
  267. 1
  268. 1
  269. 1
  270. 1
  271. 1
  272. 1
  273. 1
  274. 1
  275. 1
  276. 2
  277. 2
  278. 2
  279. 2
  280. 3
  281. 1
  282. 1
  283. 1
  284. 1
  285. 1
  286. 1
  287. 1
  288. 1
  289. 1
  290. 1
  291. 4
  292. 1
  293. 1
  294. 1
  295. 1
  296. 1
  297. 1
  298. 1
  299. 1
  300. 1
  301. 1
  302. 1
  303. 1
  304. 1
  305. 1
  306. 1
  307. 1
  308. 1
  309. 23
  310. 0
  311. 8
  312. 0
  313. 0
  314. 0
  315. 0
  316. 0
  317. 0
  318. 0
  319. 0
  320. 0
  321. 0
  322. 0
  323. 0
  324. 0
  325. 0
  326. 0
  327. 0
  328. 1
  329. 0
  330. 1
  331. 0
  332. 0
  333. 0
  334. 0
  335. 1
  336. 0
  337. 0
  338. 1
  339. 0
  340. 0
  341. 1
  342. 0
  343. 2
  344. 0
  345. 1
  346. 1
  347. 1
  348. 0
  349. 0
  350. 1
  351. 1
  352. 0
  353. 0
  354. 1
  355. 0
  356. 0
  357. 0
  358. 0
  359. 10
  360. 0
  361. 0
  362. 1
  363. 0
  364. 0
  365. 0
  366. 0
  367. 0
  368. 0
  369. 3
  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. 0
  399. 0
  400. 0
  401. 0
  402. 0
  403. 0
  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. 0
  443. 0
  444. 0
  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. 1
  480. 1
  481. 1
  482. 1
  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. 0
  521. 0
  522. 0
  523. 0
  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. 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. 0
  577. 0
  578. 1
  579. 0
  580. 1
  581. 1
  582. 1
  583. 0
  584. 0
  585. 0
  586. 0
  587. 0
  588. 0
  589. 0
  590. 0
  591. 0
  592. 0
  593. 0
  594. 0
  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. 2
  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. 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. 0
  667. 0
  668. 0
  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. 1
  738. 1
  739. 1
  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. 0
  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. 0
  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. 0
  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. 0
  917. 0
  918. 0
  919. 0
  920. 0
  921. 0
  922. 0
  923. 0
  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. 0
  940. 0
  941. 0
  942. 0
  943. 0
  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. 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. 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_1 average degree = 0.582690659811482'

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

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

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

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


'grp_week_1 average author degree (2 and 4) = 10.6060606060606'
'grp_week_1 average author degree (only 2) = 10.6060606060606'
'grp_week_1 average source degree (3 and 4) = 1.1913357400722'
'grp_week_1 average source degree (only 3) = 1.1913357400722'

grp_week_1 (gw1) - 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?
gw1HumanDegreeSd <- sd( gw1HumanDegreeVector )
paste( output_prefix, "degree SD =", gw1HumanDegreeSd, sep = " " )

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

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

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

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

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

# also add degree vector to original data frame
gw1HumanDataDF$betweenness <- gw1HumanBetweenness

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

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

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

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

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

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


'grp_week_1 degree SD = 2.24329960040874'
'grp_week_1 degree variance = 5.03239309719399'
'grp_week_1 degree max = 36'
  1. 'grp_week_1 degree frequencies = 858'
  2. 'grp_week_1 degree frequencies = 244'
  3. 'grp_week_1 degree frequencies = 27'
  4. 'grp_week_1 degree frequencies = 4'
  5. 'grp_week_1 degree frequencies = 8'
  6. 'grp_week_1 degree frequencies = 2'
  7. 'grp_week_1 degree frequencies = 4'
  8. 'grp_week_1 degree frequencies = 1'
  9. 'grp_week_1 degree frequencies = 2'
  10. 'grp_week_1 degree frequencies = 1'
  11. 'grp_week_1 degree frequencies = 2'
  12. 'grp_week_1 degree frequencies = 2'
  13. 'grp_week_1 degree frequencies = 2'
  14. 'grp_week_1 degree frequencies = 1'
  15. 'grp_week_1 degree frequencies = 2'
  16. 'grp_week_1 degree frequencies = 1'
  17. 'grp_week_1 degree frequencies = 1'
  18. 'grp_week_1 degree frequencies = 1'
  19. 'grp_week_1 degree frequencies = 1'
  20. 'grp_week_1 degree frequencies = 2'
  21. 'grp_week_1 degree frequencies = 1'
gw1HumanDegreeVector
  0   1   2   3   4   5   6   7   8   9  10  11  13  14  16  17  18  20  21  23 
858 244  27   4   8   2   4   1   2   1   2   2   2   1   2   1   1   1   1   2 
 36 
  1 
'grp_week_1 degree centrality = 0.0304271969022151'
'grp_week_1 betweenness centrality = 0.0134361252020462'
'grp_week_1 connectedness = 0.0198541656561737'
Warning message in sna::gtrans(gw1HumanNetworkStatnet, 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_1 transitivity = 0.0752148997134671'
'grp_week_1 density = 0.000499734699666794'

grp_week_1 (gw1) - 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
gw1HumanNetworkStatnet

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


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

 Vertex attribute names: 
    betweenness degree person_id person_type vertex.names 

No edge attributes

grp_week_1 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_1 a2b"

In [9]:
grpWeek1a2bOutput <- compareMatricesQAP( gw1HumanNetworkMatrix, gw1AutomatedNetworkMatrix, outputPrefix )


==> Start of  compareMatricesQAP  at  2019-07-25 11:44:51
----> grp_week_1 a2b graph correlation = 0.90223000784894 ( @ 2019-07-25 11:44:57 )
----> grp_week_1 a2b QAP correlation analysis complete at 2019-07-25 11:48:25.  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.90223 
	Replications: 1000 
	Distribution Summary:
		Min:	 -0.0004507131 
		1stQ:	 -0.0004507131 
		Med:	 -0.0004507131 
		Mean:	 4.367823e-05 
		3rdQ:	 -0.0004507131 
		Max:	 0.007881724 

----> grp_week_1 a2b graph covariance = 0.000477449419615562 ( @ 2019-07-25 11:48:25 )
----> grp_week_1 a2b QAP covariance analysis complete at 2019-07-25 11:52:00.  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.0004774494 
	Replications: 1000 
	Distribution Summary:
		Min:	 -2.38512e-07 
		1stQ:	 -2.38512e-07 
		Med:	 -2.38512e-07 
		Mean:	 2.536676e-09 
		3rdQ:	 -2.38512e-07 
		Max:	 5.640724e-06 

----> grp_week_1 a2b graph hamming distance = 144 ( @ 2019-07-25 11:52:01 )
----> grp_week_1 a2b QAP hamming distance analysis complete at 2019-07-25 11:54:40.  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)): 144 
	Replications: 1000 
	Distribution Summary:
		Min:	 1324 
		1stQ:	 1332 
		Med:	 1332 
		Mean:	 1331.432 
		3rdQ:	 1332 
		Max:	 1332 

==> End of  compareMatricesQAP  at  2019-07-25 11:54:40

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

In [ ]: