R statnet - grp month - compare graphs
2017.12.02 - work log - prelim - R - statnet - grp month
grp_week_1
and grp_week_2
using QAPgrp_week_1
and grp_week_3
using QAPgrp_week_2
and grp_week_3
using QAPgrp_month
and grp_week_1
using QAPgrp_month
and grp_week_2
using QAPgrp_month
and grp_week_3
using QAPRelated 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 densityR 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.
R scripts:
context_text/R/sna/statnet/sna-igraph-init.r
context_text/R/sna/statnet/sna-igraph-network-stats.r
Store important directories and file names in variables:
In [1]:
getwd()
In [2]:
# code files (in particular SNA and statnet function libraries, modest though they may be)
researchDirectory <- "/home/jonathanmorgan/work/django/research/"
contextAnalysisDirectory <- paste( researchDirectory, "/", 'context_analysis', sep = "" )
codeDirectory <- paste( contextAnalysisDirectory, "/", "R/sna", sep = "" )
# basic SNA functions
# - /home/jonathanmorgan/work/django/research/context_analysis/R/sna/functions-sna.r
#snaFunctionFilePath <- paste( codeDirectory, "/", 'functions-sna.r', sep = "" )
# statnet/sna functions
# - /home/jonathanmorgan/work/django/research/context_analysis/R/sna/stanet/functions-statnet.r
#statnetFunctionFilePath <- paste( codeDirectory, "/statnet/", 'functions-statnet.r', sep = "" )
# home directory
#homeDirectory <- getwd()
homeDirectory <- "/home/jonathanmorgan/work/django/research/work/phd_work/methods"
# data directories
dataDirectory <- paste( homeDirectory, "/data", sep = "" )
workspaceFileName <- "statnet-grp_month.RData"
workspaceFilePath <- paste( dataDirectory, "/", workspaceFileName )
In [3]:
# set working directory to data directory for now.
setwd( dataDirectory )
getwd()
In [4]:
# basic SNA functions
# - /home/jonathanmorgan/work/django/research/context_analysis/R/sna/functions-sna.r
snaFunctionFilePath <- paste( codeDirectory, "/", 'functions-sna.r', sep = "" )
In [5]:
source( snaFunctionFilePath )
source the file statnet/functions-statnet.r
. This file includes:
compareMatricesQAP()
, used extensively below.
In [6]:
# statnet/sna functions
# - /home/jonathanmorgan/work/django/research/context_analysis/R/sna/stanet/functions-statnet.r
statnetFunctionFilePath <- paste( codeDirectory, "/statnet/", 'functions-statnet.r', sep = "" )
In [7]:
source( statnetFunctionFilePath )
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:
person_id
and person_type
)Files and their location on server:
This is data from the Grand Rapids Press articles from December of 2009, coded by both humans and OpenCalais.
Files:
sourcenet_data-20171205-022551-grp_month-automated.tab
sourcenet_data-20171115-043102-grp_month-human.tab
sourcenet_data-20171206-031358-grp_month-automated-week1_subset.tab
sourcenet_data-20171206-031319-grp_month-human-week1_subset.tab
sourcenet_data-20180326-040445-grp_month-automated-week2_subset.tab
sourcenet_data-20180326-034401-grp_month-human-week2_subset.tab
sourcenet_data-20180326-040736-grp_month-automated-week3_subset.tab
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
You must load this file's workspace, from a previous run:
In [8]:
# assumes that you've already set working directory above to the
# working directory.
setwd( dataDirectory )
load( workspaceFileName )
grp_week_1
and grp_week_2
using QAPNow, compare the automated and human-coded networks from a week 1 and week 2 to each other, to look at similarity of weeks over time (I'd expect it to be small).
Based on: context_text/R/sna/statnet/sna-qap.r
In [9]:
outputPrefix <- "week_1-to-week_2 automated"
In [10]:
w1w2aOutput <- compareMatricesQAP( gw1AutomatedNetworkMatrix, gw2AutomatedNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( w1w2aOutput, outputPrefix, TRUE )
In [11]:
outputPrefix <- "week_1-to-week_2 human"
In [12]:
w1w2hOutput <- compareMatricesQAP( gw1HumanNetworkMatrix, gw2HumanNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( w1w2hOutput, outputPrefix, TRUE )
grp_week_1
and grp_week_3
using QAPNow, compare the automated and human-coded networks from a week 1 and week 3 to each other, to look at similarity of weeks over time (I'd expect it to be small).
Based on: context_text/R/sna/statnet/sna-qap.r
In [13]:
outputPrefix <- "week_1-to-week_3 automated"
In [14]:
w1w3aOutput <- compareMatricesQAP( gw1AutomatedNetworkMatrix, gw3AutomatedNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( w1w3aOutput, outputPrefix, TRUE )
In [15]:
outputPrefix <- "week_1-to-week_3 human"
In [16]:
w1w3hOutput <- compareMatricesQAP( gw1HumanNetworkMatrix, gw3HumanNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( w1w3hOutput, outputPrefix, TRUE )
grp_week_2
and grp_week_3
using QAPNow, compare the automated and human-coded networks from a week 2 and week 3 to each other, to look at similarity of weeks over time (I'd expect it to be small).
Based on: context_text/R/sna/statnet/sna-qap.r
In [17]:
outputPrefix <- "week_2-to-week_3 automated"
In [18]:
w2w3aOutput <- compareMatricesQAP( gw2AutomatedNetworkMatrix, gw3AutomatedNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( w2w3aOutput, outputPrefix, TRUE )
In [19]:
outputPrefix <- "week_2-to-week_3 human"
In [20]:
w2w3hOutput <- compareMatricesQAP( gw2HumanNetworkMatrix, gw3HumanNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( w2w3hOutput, outputPrefix, TRUE )
grp_month
and grp_week_1
using QAPNow, compare the automated and human-coded networks from the full month and week 1 against each other, to see what more time gets you.
Based on: context_text/R/sna/statnet/sna-qap.r
In [21]:
outputPrefix <- "month-to-week_1 automated"
In [22]:
mw1aOutput <- compareMatricesQAP( gmAutomatedNetworkMatrix, gw1AutomatedNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( mw1aOutput, outputPrefix, TRUE )
In [23]:
outputPrefix <- "month-to-week_1 human"
In [24]:
mw1hOutput <- compareMatricesQAP( gmHumanNetworkMatrix, gw1HumanNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( mw1hOutput, outputPrefix, TRUE )
grp_month
and grp_week_2
using QAPNow, compare the automated and human-coded networks from the full month and week 2 against each other, to see what more time gets you.
Based on: context_text/R/sna/statnet/sna-qap.r
In [25]:
outputPrefix <- "month-to-week_2 automated"
In [26]:
mw2aOutput <- compareMatricesQAP( gmAutomatedNetworkMatrix, gw2AutomatedNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( mw2aOutput, outputPrefix, TRUE )
In [27]:
outputPrefix <- "month-to-week_2 human"
In [28]:
mw2hOutput <- compareMatricesQAP( gmHumanNetworkMatrix, gw2HumanNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( mw2hOutput, outputPrefix, TRUE )
grp_month
and grp_week_3
using QAPNow, compare the automated and human-coded networks from the full month and week 3 against each other, to see what more time gets you.
Based on: context_text/R/sna/statnet/sna-qap.r
In [29]:
outputPrefix <- "month-to-week_3 automated"
In [30]:
mw3aOutput <- compareMatricesQAP( gmAutomatedNetworkMatrix, gw3AutomatedNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( mw3aOutput, outputPrefix, TRUE )
In [31]:
outputPrefix <- "month-to-week_3 human"
In [32]:
mw3hOutput <- compareMatricesQAP( gmHumanNetworkMatrix, gw3HumanNetworkMatrix, outputPrefix )
In [ ]:
# also output plots of distributions of QAP values?
displayCompareMatricesQAPOutput( mw3hOutput, outputPrefix, TRUE )
Save all the information in the current image, in case we need/want it later.
In [33]:
# help( save.image )
save.image( file = workspace_file_name )