social network analysis using stata · social network analysis using stata 5 sept 2014, aarhus...
TRANSCRIPT
![Page 1: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/1.jpg)
SOCIAL NETWORK ANALYSIS USING STATA
5 Sept 2014, Aarhus
Nordic and Baltic Stata Group Meeting
Thomas Grund Linköping University
www.grund.co.uk
(with contributions from Peter Hedström, Yvonne Aberg, Lorien Jasny)
![Page 2: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/2.jpg)
http://nwcommands.org
Email list https://groups.google.com/forum/#!forum/nwcommands/join
![Page 6: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/6.jpg)
Getting started
![Page 7: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/7.jpg)
![Page 8: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/8.jpg)
![Page 9: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/9.jpg)
![Page 10: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/10.jpg)
![Page 11: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/11.jpg)
![Page 12: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/12.jpg)
Describe networks
![Page 13: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/13.jpg)
![Page 14: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/14.jpg)
![Page 15: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/15.jpg)
![Page 16: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/16.jpg)
1
0
gla
sgo
w1
0 1glasgow2
maximum: 2328
frequency
glasgow1
![Page 17: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/17.jpg)
3
2
1
from
_sm
oke
1
1 2 3to_smoke1
maximum: 71
frequency
glasgow1
![Page 18: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/18.jpg)
Manipulate networks
![Page 19: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/19.jpg)
![Page 20: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/20.jpg)
. nwclear
. nwrandom 7, density(.2) name(first)
. nwrandom 7, density(.3) name(second)
. nwrandom 7, density(.3) name(third)
. gen attr= _n * 2
// replacing networks
. nwreplace first = 1
. nwreplace first = 2 in 3/5
. nwreplace first = exp(second) * attr if first == 1
// replacing subnetworks
. nwreplace first[(2::6),(1::5)] = 55
. nwreplace first[(1::4),(1::4)] = second * 7 if third != 1
// replacing with temporary networks
. nwreplace first = 99 * (_nwrandom 7, prob(.3))
![Page 21: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/21.jpg)
Analyze networks
![Page 22: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/22.jpg)
![Page 23: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/23.jpg)
Network permutation
permutation
- 1 1 0
1 - 0 1
1 0 - 0
0 0 0 -
- 0 0 0
0 - 0 1
1 0 - 1
0 1 1 -
![Page 24: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/24.jpg)
05
10
15
den
sity
-.2 0 .2 .4 .6correlation
based on 50 QAP permutations of network glasgow1
Corr(glasgow1, glasgow2)
![Page 25: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/25.jpg)
05
10
15
den
sity
-.1 -.05 0 .05 .1correlation
based on 50 QAP permutations of network glasgow1
Corr(glasgow1, same_sport1)
![Page 26: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/26.jpg)
![Page 27: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/27.jpg)
Exponential random graph models
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 28: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/28.jpg)
![Page 29: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/29.jpg)
0
.1.2
.3.4
perc
enta
ge o
f nodes
0 2 4 6 8 10 12indegree
0.1
.2.3
.4
perc
enta
ge o
f nodes
0 2 4 6 8 10outdegree
0.2
.4.6
.81
perc
enta
ge o
f nodes
1 1.5 2 2.5 3 3.5 4edge-wise shared partners
0.2
.4.6
.81
perc
enta
ge o
f nodes
1 1.5 2 2.5 3 3.5 4minimum geodesic distance
based on 30 simulations
goodness-of-fit
![Page 30: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/30.jpg)
-5
0
05
0
edg
es
0 500000 1000000step
0
.01
.02
.03
den
sity
-50 0 50edges
-20-1
0 01
020
mutu
al
0 500000 1000000step
0
.02
.04
.06
den
sity
-20 -10 0 10 20mutual
-40-2
0 02
040
nod
em
atc
h.s
mo
ke1
0 500000 1000000step
0
.01
.02
.03
.04
den
sity
-40 -20 0 20 40nodematch.smoke1
MCMC-diagnostics
![Page 31: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/31.jpg)
Visualize networks
![Page 32: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/32.jpg)
![Page 34: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/34.jpg)
. nwuse gomery, nwclear
. nwmovie _all, color(col_t*) scheme(s2network)
http://nwcommands.wordpress.com/nwcmovie
![Page 35: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/35.jpg)
. nwuse gang, nwclear
. nwplot, color(Birthplace) scheme(s2network)
![Page 36: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/36.jpg)
. nwplot, size(Arrests, forcekeys(5 15 30)) color(Birthplace)
symbol(Prison)
![Page 37: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/37.jpg)
. nwuse florentine, nwclear
. nwplot flobusiness, label(_label) edgecolor(flomarriage)
edgecolorpalette(yellow red) title(“Florentine
Businesses”, color(red) size(huge))
![Page 38: SOCIAL NETWORK ANALYSIS USING STATA · SOCIAL NETWORK ANALYSIS USING STATA 5 Sept 2014, Aarhus Nordic and Baltic Stata Group Meeting Thomas Grund Linköping University thomas.u.grund@gmail.com](https://reader034.vdocuments.us/reader034/viewer/2022051509/5b04b6a27f8b9a3c378e0beb/html5/thumbnails/38.jpg)
. nwuse glasgow, nwclear
. nwmovie _all
http://nwcommands.wordpress.com/demo_nwplot