Network Analysis using Stata...Introduction nwcommands Contribution Application Conclusion...
Transcript of Network Analysis using Stata...Introduction nwcommands Contribution Application Conclusion...
Introduction nwcommands Contribution Application Conclusion References
Network Analysis using StataNwcommands, extensions and applications.
Charlie JoyezUniversité Cote d’Azur (UCA), GREDEG, Université de Nice
Sept 2018, KU Leuven, BrusselStata User Group Meeting
Introduction nwcommands Contribution Application Conclusion References
MotivationNetworks are everywhere. flexible mathematical object
I Complex systems, interactions, interdependence’s.I Two type of use in (Social) Sciences
I Theoretical modeling with complex micro-foundationsI Empirical analysis of existing networks.
I Booming in several fields with data availability and computingcapabilities.
I Increasing interest (See Stata news january 2018 (33-1))ObjectiveHow to easily proceed to network analysis using Stata?
I Node level and network wide analysis
Introduction nwcommands Contribution Application Conclusion References
Outline
I- Introduction
II - nwcommands
III - Contribution
IV - Application
V - Conclusion and discussion
Introduction nwcommands Contribution Application Conclusion References
nwcommands - Presentation
I Developed (maintained) by Thomas Grund - Univ. College Dublin
I http://nwcommands.orgI install nwcommands-ado, from(http://www.nwcommands.org)
I Entire suite of commands, close to Stata commands (nw prefix)I declare, use, save network dataI Manipulate (keep, drop, permute, etc.) nodes or entire networksI Compute network metrics
I At the node level (centrality, etc)I At the entire network level (density, overall clustering coeff ).
Introduction nwcommands Contribution Application Conclusion References
Declare DataI From a Mata Matrix (Adjacency matrix)
I mata A=(0,10,1 \5,0,0 \0,2,0)mata A
nwset, mat(A) name(netA)
I From an edge list
I nwfromedge _fromid _toid link, name(Net1) undirected
Introduction nwcommands Contribution Application Conclusion References
Node-level metrics
I nwdegreeI _degree: Number of direct neighborsI di =
∑j
mi,j , M = A : /A Unweighted adjacency matrixI returns Freeman (1979) index
Cx =∑N
i=1 Cx(p∗) − Cx(pi)max
∑N
i=1 Cx(p∗) − Cx(pi)I nwdegree, valued
I _strength: Sum of edges weightsI si =
∑j
aij
I Other node centrality metrics : Betweeness & closeness, Katz,Eigenvector.
Introduction nwcommands Contribution Application Conclusion References
Network-wide information
I tnwsummarize
I nwgeodesicI Longest past, diameter, avg shortest path (unweighted)
I nwclustering Overall clustering coefficient (nb triads / nb possibletriads)
Introduction nwcommands Contribution Application Conclusion References
Outline
I- Introduction
II - nwcommands
III - Contribution
IV - Application
V - Conclusion and discussion
Introduction nwcommands Contribution Application Conclusion References
Node-level metrics 1/2
I Average Nearest Neighbors Degree (Strength)I nwannd : Average nearest neighbor degree.
I mataneighbor = mymat:>0Z=st_data(.,"_degree")mata: totdegreemat = neighbor*Zmata: ANNDmat=totdegreemat:/Zend mata
I nwdisparity (Barthélemy et al., 2005) : distribution of edge’s weight(concentration)disparityi =
∑j(wij/si)2
I nw_harmonic centrality (suited for disconnected graphs)I H(x) =
∑y 6=x
1d(y,x)
Introduction nwcommands Contribution Application Conclusion References
Node-level metrics 2/2
Weighted / directed extension of existing commandsI nwcluster : directions and/or weighted generalization (Onnela
et al., 2005)
I nw_wcc : Weighted Clustering Coefficients (Fagiolo, 2006)
I nw_geodesic (weights as distance)
Introduction nwcommands Contribution Application Conclusion References
Network level
I nwreciprocity (Barrat et al., 2004)I mata
s=sum(W)Z = W :* (W :< W’) + W’ :* (W’ :< W) /*min of symmetricselements = reciprocated ties*/E=sum(Z)r=E/send mata
I Compares reciprocity with N random draws (same size, density).I nwstrengthcent : (Freeman, 1979) index based on Strength.
Introduction nwcommands Contribution Application Conclusion References
Declaration
I From neigbor lists (only existing ties). A variable may indicate thesequence.
I nw_fromneighbor nw_fromlist test,node(NODE) id(ID)direction(year)
Initial data
Final data
Introduction nwcommands Contribution Application Conclusion References
Outline
I- Introduction
II - nwcommands
III - Contribution
IV - Application
V - Conclusion and discussion
Introduction nwcommands Contribution Application Conclusion References
Application to international economics
I World Trade Web on 2016
I Declare to be weighted directed network : 192*192 tablemkmat flow_*, matrix(M)mata A=st_matrix("M")nwset , mat(A) name(TradeNet‘v’)
Introduction nwcommands Contribution Application Conclusion References
Application - 2
I Most central nodes?I Eigenvector centrality
Degree centralization Strength Centralization0.364 0.176
Introduction nwcommands Contribution Application Conclusion References
Application - 3
Econometrics of networksI Use of network metrics (e.g. centrality indexes of nodes) into
traditional analysis. (Hidalgo et al., 2007)I Regress network structure (dyadic data)
I Individuals in networks not iidI OLS biased unless FE or clusteringI QAP : unit = dyadic value + random permutations of rows and columns.
I nwqap MNEnet_2011 GVCnet_2010 , mode(dist) type(reg)permutation(500)
Introduction nwcommands Contribution Application Conclusion References
Outline
I- Introduction
II - nwcommands
III - Contribution
IV - Application
V - Conclusion and discussion
Introduction nwcommands Contribution Application Conclusion References
Conclusion
I Network analysis made easy through StataI easy to learn and contributeI suited to a wide range of issues
Next stepsI generalize metrics to weighted, directed, unconnected graphs.
I Fit to complex networks.I improve network graphs & plots vizualizationI Incorporate nwcommands into Stata 16?I Promote network analysis to colleague/students already familiar with
Stata.
Introduction nwcommands Contribution Application Conclusion References
Thank [email protected]
Many thanks to Thomas Grund for its nwcommands: Network Analysis with StataAdditional Stata commands used for this paper are available on my RePEc Ideas page or
directy from SSC (e.g. ssc install nwannd)
Introduction nwcommands Contribution Application Conclusion References
References
Barrat, A., Barthelemy, M., Pastor-Satorras, R., and Vespignani, A. The architecture ofcomplex weighted networks. Proceedings of the National Academy of Sciences of the UnitedStates of America, 101(11):3747–3752, 2004.
Barthélemy, M., Barrat, A., Pastor-Satorras, R., and Vespignani, A. Characterization andmodeling of weighted networks. Physica a: Statistical mechanics and its applications, 346(1):34–43, 2005.
Fagiolo, G. Directed or undirected? a new index to check for directionality of relations insocio-economic networks. Economics Bulletin, 3(34):1–12, 2006.
Freeman, L. C. Centrality in social networks conceptual clarification. Social networks, 1(3):215–239, 1979.
Hidalgo, C. A., Klinger, B., Barabasi, A.-L., and Hausmann, R. The product spaceconditions the development of nations. Paper 0708.2090, arXiv.org, 2007. 00468.
Joyez, C. On the topological structure of multinationals network. Physica A: StatisticalMechanics and its Applications, 473:578 – 588, 2017.
Onnela, J.-P., Saramäki, J., Kertész, J., and Kaski, K. Intensity and coherence of motifs inweighted complex networks. Physical Review E, 71(6):065103, 2005.