Repository navigation
Expand file tree
/
Copy pathnw2fromedge.sthlp
More file actions
184 lines (135 loc) · 6.71 KB
/
Copy pathnw2fromedge.sthlp
File metadata and controls
184 lines (135 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
{smcl}
{* *! version 1.0.1 3sept2014 author: Thomas Grund}{...}
{marker topic}
{helpb nw_topical##import:[NW-2.2] Import/Export}
{title:Title}
{p2colset 9 19 22 2}{...}
{p2col :nw2fromedge {hline 2} Import two-mode network data from edgelist}
{p2colreset}{...}
{title:Syntax}
{p 8 17 2}
{cmdab: nw2fromedge}
{it:{help varname:level1}}
{it:{help varname:level2}}
[{it:{help varname:tievalue}}]
[{it:{help if}}]
[{cmd:,}
{opth generate(newvarname)}
{opt project}({it:{help nw2fromedge##project_level:project_level}})
{opt stat}({it:{help nw2fromedge##project_stat:project_stat}})
{it:{help nwfromedge:nwfromedge_options}}
]
{synoptset 30 tabbed}{...}
{synopthdr}
{synoptline}
{synopt:{opth generate(newvarname)}}name of variable identifying two-mode membership; default = {it:_modeid}{p_end}
{synopt:{opt project}({it:{help nw2fromedge##project_level:project_level}})}make one-mode projection to either level {bf:1} or level {bf:2} {p_end}
{synopt:{opt stat}({it:{help nw2fromedge##project_stat:project_stat}})}logic for dealing with tie values in one-mode projection{p_end}
{p2colreset}{...}
{title:Description}
{pstd}
{cmd:nw2fromedge} imports a two-mode network from a dataset in edgelist format. It is very similar to {help nwfromedge}.
{pstd}
A two-mode network consists of two sets of units (e. g. people and events) and relations connect the two sets, e. g. participation
of people in social events. Some examples are:
{pmore}
- Membership in institutions - people, institutions, is a member, e.g. directors and commissioners on the boards of corporations.
{pmore}
- Voting for suggestions - polititians, suggestions, votes for.
{pmore}
- Citation network, where first set consists of authors,
the second set consists of articles/papers,
connection is a relation author cites a paper.
{pmore}
- Co-autorship networks - authors, papers, is a (co)author.
A corresponding graph is called bipartite graph Ð lines
connect only vertices from one to vertices from another set Ð
inside sets there are no connections.
{marker edgelist}{...}
{pstd}
An edgelist is a set of two (or three in the case of a valued network) variables representing
relations. Nodes are identified by entries in the cells. For example, the data
{com}. use "http://nwcommands.org/data/institutions.dta", clear
{com}. list _all
{txt}
{c TLC}{hline 10}{c -}{hline 11}{c -}{hline 7}{c TRC}
{c |} {res} person institu~n years {txt}{c |}
{c LT}{hline 10}{c -}{hline 11}{c -}{hline 7}{c RT}
1. {c |} {res} Thomas Oxford 5 {txt}{c |}
2. {c |} {res} Peter Oxford 7 {txt}{c |}
3. {c |} {res} Tim Oxford 4 {txt}{c |}
4. {c |} {res} Peter LiU 1 {txt}{c |}
5. {c |} {res} Tim LiU 1 {txt}{c |}
{c LT}{hline 10}{c -}{hline 11}{c -}{hline 7}{c RT}
6. {c |} {res} Thomas LiU 1 {txt}{c |}
7. {c |} {res}Mathilde UdeM 5 {txt}{c |}
8. {c |} {res} Thomas UdeM 1 {txt}{c |}
9. {c |} {res} Michael ETH 3 {txt}{c |}
10. {c |} {res} Michael Groningen 5 {txt}{c |}
{c LT}{hline 10}{c -}{hline 11}{c -}{hline 7}{c RT}
11. {c |} {res} Thomas ETH 1 {txt}{c |}
{c BLC}{hline 10}{c -}{hline 11}{c -}{hline 7}{c BRC}
{pstd}
stores information about the affiliation of individual researchers.
{pstd}
The following command declares such data as two-mode network data:
{cmd:. nw2fromedge person institution, name(mynet)}
{pstd}
Essentially, this does exactly the same as {help nwfromedge}, but also generates a variable {it:_modeid}, which has the value 1 for persons (Peter, Tim,
Thomas, Michael, Mathilde) and value 2 for institutions (LiU, UdeM, Oxford, ETH, Groningen).
{pstd}
For example, one can plot this two-mode network and color the two levels differently:
{cmd:. nwplot mynet, color(_modeid)}
{marker project_stat}{...}
{marker project_level}{...}
{title:One-mode projection}
{pstd}
Sometimes one wants to collapse a two-mode network to a one-mode network. This is called a one-mode projection. Such a projection is a simplification of the network to nodes
of one level only. For example, in our example one can either collapse to the level of persons or to the level of institutions. The level to which one wants to collapse is
specified in option {bf:project()}.
{pstd}
For example, this loads the data above as a one-mode projection on level 1 (persons):
{cmd: nw2fromedge person institution, project(1)}
{pstd}
It generates a network with five unique actors (Peter, Tim, Thomas, Michael and Mathilde). By default, a one-mode projection on one level generates ties between nodes (on this level) when they have at least one network neighbor on the other level in common. In our case,
projecting to the level of persons creates ties between persons when they share at least one institution.
{pstd}
When ties are valued there are several ways how the value of projected ties is generated. Option {opt stat()} can
be one of the following: {bf:min, max, minmax, sum, mean}. To illustrate what each one of them calculates tie values for
the projection, let us consider the relationship between Peter and Thomas. They share two institutions: Oxford and LiU.
{pmore}
Thomas - LiU - 1 year
Peter - LiU - 1 year
Thomas - Oxford - 5 years
Peter - Oxford - 7 years
{pstd}
The option {bf:stat(min)} takes the overall minimum from all these ties and generates the projection:
{pmore}
Peter - Thomas - 1 year
{pstd}
The option {bf:stat(max)} takes the overall maximum from all these ties and generates the projection:
{pmore}
Peter - Thomas - 7 years
{pstd}
The option {bf:stat(sum)} takes the sum over all these ties and generates the projection:
{pmore}
Peter - Thomas - 14 years
{pstd}
The option {bf:stat(mean)} takes the sum over all these ties and generates the projection:
{pmore}
Peter - Thomas - 3.5 years
{pstd}
The option {bf:stat(minmax)} takes for each institution Peter and Thomas share the minimum (Oxford = 5, LiU = 1) and
and takes the maximum out of these scores as tie value. Substantially, this corresponds to the
longest time that Peter and Thomas were at the same institution. This is the default option.
{pmore}
Peter - Thomas - 5 years
{pstd}
In contrast, the next command generates a one-mode projection on level 2 (institutions).
{cmd: nw2fromedge person institution, project(2)}
{pstd}
This projection
has only two nodes (LiU and UdeM). And there is exactly one undirected tie in this network (because Thomas went to both UdeM and LiU).
LiU <=> UdeM
{title:Also see}
{help nwfromedge}