Upload
lamcong
View
219
Download
1
Embed Size (px)
Citation preview
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)
http://nwcommands.org
Email list https://groups.google.com/forum/#!forum/nwcommands/join
http://nwcommands.org
GitHub https://github.com/ThomasGrund/nwcommands
http://nwcommands.org
Getting started
Describe networks
1
0
gla
sgo
w1
0 1glasgow2
maximum: 2328
frequency
glasgow1
3
2
1
from
_sm
oke
1
1 2 3to_smoke1
maximum: 71
frequency
glasgow1
Manipulate networks
. 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))
Analyze networks
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 -
05
10
15
den
sity
-.2 0 .2 .4 .6correlation
based on 50 QAP permutations of network glasgow1
Corr(glasgow1, glasgow2)
05
10
15
den
sity
-.1 -.05 0 .05 .1correlation
based on 50 QAP permutations of network glasgow1
Corr(glasgow1, same_sport1)
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.
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
-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
Visualize networks
http://nwcommands.wordpress.com/nwcmovie
. nwuse gomery, nwclear
. nwmovie _all, color(col_t*) scheme(s2network)
http://nwcommands.wordpress.com/nwcmovie
. nwuse gang, nwclear
. nwplot, color(Birthplace) scheme(s2network)
. nwplot, size(Arrests, forcekeys(5 15 30)) color(Birthplace)
symbol(Prison)
. nwuse florentine, nwclear
. nwplot flobusiness, label(_label) edgecolor(flomarriage)
edgecolorpalette(yellow red) title(“Florentine
Businesses”, color(red) size(huge))
. nwuse glasgow, nwclear
. nwmovie _all
http://nwcommands.wordpress.com/demo_nwplot
http://nwcommands.org
Thomas Grund Linköping University [email protected] www.grund.co.uk