social network analysis using stata · 2016. 6. 13. · social networks, 34(4), 682-690. social...

110
SOCIAL NETWORK ANALYSIS USING STATA 10 June 2016 German Stata User Meeting GESIS, Cologne Thomas Grund University College Dublin [email protected] www.grund.co.uk

Upload: others

Post on 26-Sep-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

SOCIAL NETWORK ANALYSIS

USING STATA

10 June 2016

German Stata User Meeting

GESIS, Cologne

Thomas Grund

University College Dublin

[email protected]

www.grund.co.uk

Page 2: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 3: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

NETWORK DYNAMICS

International art fairs

Changes 2005 - 2006

Yogev, T. and Grund, T. (2012) Structural Dynamics and the Market for Contemporary Art: The Case

of International Art Fairs. Sociological Focus, 54(1), 23-40.

Page 4: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

CO-OFFENDING

IN YOUTH GANG

Grund, T. and Densley, J. (2012) Ethnic Heterogeneity in the Activity and Structure of a Black Street

Gang. European Journal of Criminology, 9(3), 388-406.

Grund, T. and Densley, J. (2015). Ethnic homophily and triad closure: Mapping internal gang structure

using exponential random graph models. Journal of Contemporary Criminal Justice, 31(3), 354–370

Caribbean East Africa UK West Africa

Page 5: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

MANCHESTER UTD –

TOTTENHAM

9/9/2006, Old Trafford

Grund, T. (2012) Network Structure and Team Performance: The Case of English

Premier League Soccer Teams. Social Networks, 34(4), 682-690.

Page 6: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

SOCIAL NETWORKS

• Social

• Friendship, kinship, romantic relationships

• Government

• Political alliances, government agencies

• Markets

• Trade: flow of goods, supply chains, auctions

• Labor markets: vacancy chains, getting jobs

• Organizations and teams

• Interlocking directorates

• Within-team communication, email exchange

Page 7: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

DEFINITION

Mathematically, a (binary) network is defined as 𝐺 = 𝑉, 𝐸where 𝑉 = 1,2, . . , 𝑛 is a set of “vertices” (or “nodes”) and 𝐸 ⊆𝑖, 𝑗 | 𝑖, 𝑗 ∈ 𝑉 is a set of “edges” (or “ties”, “arcs”). Edges are

simply pairs of vertices, e.g. 𝐸 ⊆ 1,2 , 2,5 … .

We write 𝑦𝑖𝑗 = 1 if actors 𝑖 and 𝑗 are related to each other (i.e.,

if 𝑖, 𝑗 ∈ 𝐸), and 𝑦𝑖𝑗 = 0 otherwise.

In digraphs (or directed networks) it is possible that 𝑦𝑖𝑗 ≠ 𝑦𝑗𝑖.

Page 8: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

ADJACENCY MATRIX

Page 9: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

ADJACENCY MATRIX

Page 10: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

ADJACENCY LIST

Page 11: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

ADJACENCY LIST

Page 12: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

NETWORK ANALYSIS

- Simple description/characterization of networks

- Calculation of node-level characteristics (e.g. centrality)

- Components, blocks, cliques, equivalences…

- Visualization of networks

- Statistical modeling of networks, network dynamics

- ….

Page 13: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

. findit nwcommands

http://nwcommands.org

Page 14: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

http://nwcommands.org

Page 15: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

Twitter: nwcommands

GoogleGroup: nwcommands

Search “nwcommands” to find a

channel with video tutorials.

Page 16: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

NWCOMMANDS

• Software package for Stata. Almost 100 new Stata commands

for handling, manipulating, plotting and analyzing networks.

• Ideal for existing Stata users. Corresponds to the R packages

“network”, “sna”, “igraph”, “networkDynamic”.

• Designed for small to medium-sized networks (< 10000).

• Almost all commands have menus. Can be used like Ucinet

or Pajek. Ideal for beginners and teaching.

• Not just specialized commands, but whole infrastructure for

handling/dealing with networks in Stata.

• Writing own network commands that build on the

nwcommands is very easy.

Page 17: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

LINES OF CODE

Type Files LoC

.ado 94 14548

.dlg 57 5707

.sthlp 97 9954

DownloadsOver 13 000 (since Jan

2015)

Page 18: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

. nwinstall, all

Page 19: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 20: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

. help nwcommands

Page 21: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

INTUITION

• Software introduces netname and netlist.

• Networks are dealt with like normal variables.

• Many normal Stata commands have their network counterpart

that accept a netname, e.g. nwdrop, nwkeep, nwclear,

nwtabulate, nwcorrelate, nwcollapse, nwexpand, nwreplace,

nwrecode, nwunab and more.

• Stata intuition just works.

Page 22: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

SETTING NETWORKS

• “Setting” a network creates a network quasi-object that has a

netname.

• After that you can refer to the network simply by its netname,

just like when refer to a variable with its varname.

Syntax:

Page 23: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 24: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 25: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

LIST ALL NETWORKS

Check out the return vector. Both

commands populate it as well.

These are the names of the

networks in memory. You can

refer to these networks by

their name.

Page 26: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

LOAD NETWORK

FROM THE INTERNET

. help netexample

Page 27: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

IMPORT NETWORK

• A wide array of popular network file-formats are supported, e.g. Pajek, Ucinet, by nwimport.

• Files can be imported directly from the internet as well.

• Similarly, networks can be exported to other formats with nwexport.

Page 28: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

DROP/KEEP NETWORKS

• Dropping and keeping networks works almost exactly like

dropping and keeping variables.

Page 29: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 30: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

DROP/KEEP NODES

You can also drop/keep nodes of a specific network.

Page 31: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

NODE ATTRIBUTES

• Every node of a network has a nodeid, which is matched with the

observation number in a normal dataset.

• In this case, the node with nodeid == 1 is the “acciaiuoli” family and they

have a wealth of 10.

Page 32: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

nwset nwdrop

nwds nwkeep

nwcurrent

nwimport

webnwuse

Page 33: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 34: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 35: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

. webnwuse gang

. nwplot gang, color(Birthplace) scheme(s2network)

Page 36: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

nwplot gang, color(Birthplace) symbol(Prison) size(Arrests)

Page 37: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

acciaiuoli

albizzi

barbadori

bischeri

castellani

ginori

guadagni

lamberteschi

medici

pazzi

peruzzi

pucci

ridolfi

salviati

strozzi

tornabuoni

. webnwuse florentine

. nwplot flomarriage, lab

Page 38: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

. nwplotmatrix flomarriage, lab

Page 39: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

. nwplotmatrix flomarriage, sortby(wealth) label(wealth)

Page 40: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

. webnwuse klas12

. nwmovie klas12_wave1-klas12_wave4

Page 41: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 42: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

. nwmovie _all, colors(col_t*) sizes(siz_t*) edgecolors(edge_t*)

Page 43: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

nwplot

nwplotmatrix

nwmovie

Page 44: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 45: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

SUMMARIZE

Page 46: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

SUMMARIZE

Page 47: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

TABULATE NETWORK

Page 48: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

TABULATE TWO NETWORKS

Page 49: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

TABULATE NETWORK

AND ATTRIBUTE

Page 50: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

DYAD CENSUS

M: mutual

A: asymmetric

N: null

Page 51: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 52: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

nwsummarize

nwtabulate

nwdyads

nwtriads

Page 53: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 54: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

TABULATE NETWORK

Page 55: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

RECODE TIE VALUES

Page 56: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

FLORENTINE FAMILIES

Marriage ties Business ties

Page 57: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

REPLACE TIE VALUES

Page 58: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

. help nwreplace

Page 59: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

GENERATE NETWORKS

Page 60: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

. help nwgen

Page 61: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

nwrecode

nwreplace

nwsync

nwtranspose

nwsym

nwgen

Page 62: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 63: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

FLORENTINE FAMILIES

Who are the

neighbors?

Page 64: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

NEIGHBORS

Page 65: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

NEIGHBORS

Page 66: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

CONTEXT

Page 67: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

CONTEXT

What is the average wealth of the “albizzi’s” network neighbors?

Page 68: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

CONTEXT

Page 69: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

CONTEXT

Page 70: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

nwneighbor

nwcontext

Page 71: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 72: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

DISTANCE

Length of a shortest connecting path defines the (geodesic)

distance between two nodes.

Page 73: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

DISTANCE

𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒𝑠 =

0 1 11 0 21 2 0

2 21 13 3

1 2 22 1 3

0 31 0

3

1 2

4

5

𝑎𝑣𝑔𝑒𝑟𝑎𝑔𝑒 𝑠ℎ𝑜𝑟𝑡𝑒𝑠𝑡 𝑝𝑎𝑡ℎ 𝑙𝑒𝑛𝑔𝑡ℎ = 1.8

Page 74: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

DISTANCE

Page 75: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

DISTANCE

Page 76: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

PATHS

How can one get from

the “peruzzi” to the

“medici”?

Page 77: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

PATHS

Page 78: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

PATHS

Page 79: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

PATHS

Page 80: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

nwgeodesic

nwpath

nwplot

Page 81: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 82: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

CENTRALITY

Well connected actors are in a

structurally advantageous position.

• Getting jobs

• Better informed

• Higher status

• …

What is “well-connected?”

Page 83: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

DEGREE CENTRALITY

Degree centrality

• Simply the number of incoming/outgoing ties => indegree

centrality, outdegree centrality

• How many ties does an individual have?

𝐶𝑜𝑑𝑒𝑔𝑟𝑒𝑒 𝑖 =

𝑗=1

𝑁

𝑦𝑖𝑗 𝐶𝑖𝑑𝑒𝑔𝑟𝑒𝑒 𝑖 =

𝑗=1

𝑁

𝑦𝑗𝑖

Page 84: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

BETWEENNESS CENTRALITY

Betweeness centrality

• How many shortest paths go through an individual?

a

e

b

c

d

𝐶𝑏𝑒𝑡𝑤𝑒𝑒𝑛𝑛𝑒𝑠𝑠 𝑎 = 6

𝐶𝑏𝑒𝑡𝑤𝑒𝑒𝑛𝑛𝑒𝑠𝑠 𝑏 = 0

Page 85: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

BETWEENNESS CENTRALITY

Betweeness centrality

• How many shortest paths go through an individual?

a

e

b

c

d

e

What about multiple shortest paths?

E.g. there are two shortest paths

from c to d (one via a and another

one via e)

Give each shortest path a weight inverse to

how many shortest paths there are

between two nodes.

Page 86: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 87: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

nwdegree

nwbetween

nwevcent

nwcloseness

nwkatz

Page 88: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 89: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

RANDOM NETWORK

nwrandom 15, prob(.1)

Each tie has the same probability to exist, regardless of any other ties.

nwrandom 15, prob(.5)

Page 90: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

LATTICE RING LATTICE

nwlattice 5 5 nwring 15, k(2) undirected

Page 91: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

SMALL WORLD NETWORK

nwsmall 10, k(2) shortcuts(3) undirected

Page 92: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

PREFERENTIAL

ATTACHMENT NETWORK

nwpref 10, prob(.5)

Page 93: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

HOMOPHILY NETWORK

nwhomophily gender, density(0.05) homophily(5)

Page 94: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

nwrandom nwlattice

nwsmall nwpref

nwring

nwhomophily

nwdyadprob

Page 95: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 96: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

Is a particular

network pattern

more (or less)

prominent than

expected?

Page 97: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

Question: Is there more or less correlation

between these two networks than expected?

𝑐𝑜𝑟𝑟𝑜𝑏𝑠 = 0.372

Page 98: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

Test-statistic

𝑐𝑜𝑟𝑟𝑜𝑏𝑠 = 0.372

Distribution of test-

statistic under null

hypothesis

𝑐𝑜𝑟𝑟𝑟𝑎𝑛𝑑𝑜𝑚 =? ?

1

2

Page 99: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

QUADRATIC ASSIGNMENT

PROCEDURE

Scramble the network by permuting the actors

(randomly re-label the nodes), i.e. the actual

network does not change, however, the position

each node takes does.

Re-calculate the test-static on the

permuted networks and compare

it with test-statistic on the

unscrambled network.

Network structure is

‘controlled’ for. Keeps

dependencies.

Page 100: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

PERMUTATION TEST

permutation

- 1 0 1

1 - 1 1

0 0 - 0

0 0 0 -

1

2

3

4

43

1

2

- 1 1 1

0 - 0 0

1 1 - 0

0 0 0 -

Page 101: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

GRAPH CORRELATION

nwcorrelate flobusiness flomarriage, permutations(100)

01

23

4

de

nsity

-.2 0 .2 .4correlation

based on 100 QAP permutations of network flobusiness

Corr(flobusiness, flomarriage)

Page 102: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

nwcorrelate

nwpermute

nwqap

nwergm

Page 103: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

SOCIAL NETWORK ANALYSIS

USING STATA

10 June 2016

German Stata User Meeting

GESIS, Cologne

Thomas Grund

University College Dublin

[email protected]

www.grund.co.uk

Page 104: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 105: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

ERGM

logit 𝑃 𝑌𝑖𝑗 = 1 𝑛 𝑎𝑐𝑡𝑜𝑟𝑠, 𝑌𝑖𝑗𝑐 =

𝑘=1

𝐾

𝜃𝑘𝛿𝑠𝑘 𝒚

Probability that

there is a tie from i

to j. Given, n actors AND the rest

of the network, excluding the

dyad in question!

𝑌𝑖𝑗𝑐 = all dyads other than 𝑌𝑖𝑗

Amount by which the feature

𝑠𝑘 𝑦 changes when 𝑌𝑖𝑗 is

toggled from 0 to 1.

Page 106: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

ERGM

𝑃 𝒀 = 𝒚 𝜃 =𝑒

𝜃𝑇𝑠 𝒚

𝑐 𝜃

𝒀 = 𝒓𝒂𝒏𝒅𝒐𝒎 𝒗𝒂𝒓𝒊𝒂𝒃𝒍𝒆, a randomly selected network from

the pool of all potential networks

𝒚 = 𝒐𝒃𝒔𝒆𝒓𝒗𝒆𝒅 𝒗𝒂𝒓𝒊𝒂𝒃𝒍𝒆, here observed network

Probability to draw

‘our’ observed

network y from all

potential networks

A score given to our

network y using some

parameters 𝜃 and the

network features s of y

𝜽 = 𝒑𝒂𝒓𝒂𝒎𝒆𝒕𝒆𝒓𝒔, to be estimated

A score given to all

other networks we

could have observed

Page 107: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

ERGM: INTEPRETATION

ERGM’s ultimately give you an estimate for various

parameters 𝜃𝑘, which mean…

If a potential tie 𝑌𝑖𝑗 = 1

(between i and j) would

change the network

statistic 𝑠𝑘 by one unit.

This changes the log-

odds for the tie 𝑌𝑖𝑗 to

actually exist by 𝜃𝑘.

Page 108: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

EXAMPLE

Consider an ERGM for an undirected network with parameters for these

three statistics:

𝑠𝑒𝑑𝑔𝑒𝑠 𝑦 =𝑦𝑖𝑗

𝑠2𝑠𝑡𝑎𝑟𝑠 𝑦 =𝑦𝑖𝑗 𝑦𝑖𝑘

𝑠𝑡𝑟𝑖𝑎𝑛𝑔𝑙𝑒𝑠 𝑦 = 𝑦𝑖𝑗 𝑦𝑗𝑘𝑦𝑖𝑘

1) number of edges

2) number of 2-stars

3) number of triangles

𝑃 𝒀 = 𝒚 𝜃 ∝ 𝑒𝜃𝑒𝑑𝑔𝑒𝑠𝑠𝑒𝑑𝑔𝑒𝑠 𝑦 + 𝜃2𝑠𝑡𝑎𝑟𝑠𝑠2𝑠𝑡𝑎𝑟𝑠 𝑦 + 𝜃𝑡𝑟𝑖𝑎𝑛𝑔𝑙𝑒𝑠𝑠𝑡𝑟𝑖𝑎𝑛𝑔𝑙𝑒𝑠 𝑦

Then the 3-parameter ERG distribution function is:

Page 109: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but
Page 110: SOCIAL NETWORK ANALYSIS USING STATA · 2016. 6. 13. · Social Networks, 34(4), 682-690. SOCIAL NETWORKS ... Ideal for beginners and teaching. • Not just specialized commands, but

SOCIAL NETWORK ANALYSIS

USING STATA

10 June 2016

German Stata User Meeting

GESIS, Cologne

Thomas Grund

University College Dublin

[email protected]

www.grund.co.uk