Introduction to Network Analysis Using R
2019-04-29
Chapter 1 Introduction
Here I provide a tutorial on basic network analysis using R. This tutorial is suitable for people who are familiar with R.
The documents are based on the lab materials of STAT650 Social Network at Duke University.
The webpage is built using bookdown
1.1 Outline
- Basic introduction on network objects. R packages including
igraph
,statnet
(includingsna
,network
). - Collect network data.
- Web API requesting (Twitter, Reddit, IMDB, or more).
- Useful websites (SNAP, or more)
- Visualization (static and dynamic networks).
- Network analysis using package
amen
.
1.2 Detailed Outline
igraph
package- Create networks and basics concepts
- Create simple networks, specific graphs, graph models
- Adjustments on graphs, rewiring graphs
- Edge, vertex and network attributes
- Built networks from external sources, basic visualization and network descriptions
- Get network from files (edgelist, matrix, dataframe)
- Visualization
- Plotting parameters
- Layouts
- Network and node descriptions
- Paths, communitites and related visualization
- Paths
- Paths, distances and diameter
- Components
- Transitivity and reciprocity
- Max-flow and min-cut
- Communities
- Pre-defined clusters
- Different algorithms
- Visualization
- Color the paths
- Plotting clusters
- Plotting dendrograms
- Mark groups
- Paths
- References:
- Tutorial: http://kateto.net/networks-r-igraph
- Handbook: http://igraph.org/r/
- Book: https://sites.fas.harvard.edu/~airoldi/pub/books/BookDraft-CsardiNepuszAiroldi2016.pdf
- Datasets: https://github.com/mathbeveridge/asoiaf https://networkofthrones.wordpress.com/data/ https://www.macalester.edu/~abeverid/thrones.html
- Create networks and basics concepts
- ERGM (
statnet
)summary
network statisticsergm
model fitting and interpretation:simulate
network simulations based on specified model.gof
,mcmc.diagnostics
: Goodness of fit and MCMC diagnostics- References:
- Collect network data and API requests
- Several useful websites:
- Awesome website for papers, reviews, datasets and softwares: https://github.com/briatte/awesome-network-analysis
- Katherine’s webpage: http://kateto.net/2016/05/network-datasets/
- Data analysis competition: https://www.kaggle.com/datasets https://data.world/search?q=network+dataset
- twitter API request:
rtweet
- Official website: https://rtweet.info/index.html
- API authorization;
create_token
search_tweets
stream_tweets
- Other functions
- Examples: retweet networks, friendship networks
- Other available R packages for API request:
rtweet
,Rfacebook
,RedditExtractoR
,imdbapi
,omdbapi
- Direct API request from R.
rjson
,jsonlite
- References:
- Several useful websites:
- Advanced Visualization
- Visualization for static network:
- Graph: hairball plot
- Matrix:
heatmap
in R basic package;geom_tile
in pkgggplot2
- Other static networks:
- Two-mode networks (node-specific attribute)
- Multiple networks (edge-specific attribute)
- … (
ggtree
,ggalluvial
, etc.)
ggplot2
version for network visualization:- Comparison between
ggnet2
,geomnet
,ggnetwork
- Extension to interactive (
plotly
) , dynamic network (ggnetwork
)
- Comparison between
- Other interactive network visualizations:
visNetwork
(good documentation)networkD3
threejs
ggigraph
- Visualization for dynamic networks
- Snapshots for the evolving networks:
ggnetwork
(common) - Animation for the evolving networks:
ggplot2
+gganimate
ndtv
pkg (good documentation)
- Snapshots for the evolving networks:
- References:
- Visualization for static network:
amen
packages- Gaussian AME model:
ame
- Different relation:
ame(...,model=,...)
- ordinal data
- censored and fixed rank nomination data
- sampled or missing data
- symmetric relation:
ame(...,symmetric=TRUE,...)
- repeated measures data: longitudal data
ame_rep(Y,Xdyad,Xrow,Xcol)
- References:
- Gaussian AME model: