Assignments with other data
Each assignment applies the methods of some chapters to a data set that ships with nwcommands but is not the main
example of those chapters. Students who have worked through the chapters on the lawyers or the Glasgow girls then
have to make the decisions themselves: which version of a relation, which baseline, which rule for unreachable
pairs. All data sets load with nwwebuse and are described on the Data sets page; help netexample
in Stata gives their variable codings.
The questions do not give the results. Every assignment ends with an open question that has no single answer.
- 1. Factions in a monastery
- 2. A karate club that split
- 3. Borders between US states
- 4. Interlocking boards in Sweden
- 5. Friendship in a Dutch school class
- 6. Support among the characters of the Harry Potter books
- 7. Nineteen Dutch schools compared
- 8. The full US airport network
- 9. A tailor shop before and after a dispute
1. Factions in a monastery
- Data: Sampson’s monastery,
nwwebuse sampson. Eighteen novice monks; ranked choices at three times (samplk1tosamplk3) and a liking ranking (samplike), directed and valued with values 1 to 3. Attributes:faction(Loyal, Turks, Outcasts) andcloisterville. - Draws on: Chapters 6, 9, 10, 13 and 19.
- Questions:
- Run
nwsummarizeon the four networks andnwtabulate samplike. Read the coding of the values inhelp netexample. Is a higher value a stronger tie? Decide whether to use the values or to dichotomize, and state the rule. A binary version isnwrecode samplike (1/3 = 1), generate(like01). - Report the dyad census and reciprocity of the liking network with
nwdyads. - Run
nwmixing samplike, attribute(faction) permutations(1000)afterset seed 12345. Compute from the faction sizes (tab faction) the E-I index that random labels would give, and read the observed index against it, not against zero. - Find positions with
nwconcor like01, splits(2) generate(block)and withnwhierarchy like01, groups(3) linkage(wardslinkage) generate(h3). Cross-tabulate each withfaction. Repeat the hierarchical clustering with the default single linkage. Which method recovers the factions, and why might a block differ from a faction? - Run
nwcommunity like01, algorithm(louvain) seed(12345) symmetrize generate(com)and cross-tabulate the communities withfaction. Say what a community and a block each claim about the monks. - Open: the factions were revealed after the liking ranking was collected. Does a partition that matches them show that the liking ties produced the split? Name a rival account.
- Run
2. A karate club that split
- Data: Zachary’s karate club,
nwwebuse zachary. Thirty-four members, undirected;zachary_bin(binary) andzachary_val(the same 78 ties, valued up to 7 by the number of contexts in which two members interacted). Attribute:group, the faction each member joined after the split. The instructor isMr Hi; the club’s president is node 34. - Draws on: Chapters 8, 9 and 13.
- Questions:
- Run Louvain (
nwcommunity zachary_bin, algorithm(louvain) seed(12345) generate(lv)) and label propagation under four seeds (algorithm(labelprop)withseed(1)toseed(4)). Report the number of communities, the modularity and the cross-tabulation withgroupfor each run. - Compute the modularity of the observed split with
nwmodularity zachary_bin, group(group). Compare it with the modularity of the detected partitions. Why is this comparison unfair to the observed split? - Run
nwkcoreandnwkcomponentswithk(2). Is either faction a cohesive group by these stricter tests? - Compute betweenness on
zachary_binand onzachary_val, and with the optionbinaryonzachary_val. Which members change rank? The weighted version treats a high value as a short step; say what that assumes about the values. - Open: a method that “finds” a split known in advance looks impressive. What would it take to predict the split from data collected before it?
- Run Louvain (
3. Borders between US states
- Data: US state borders,
nwwebuse usstates. Fifty states, undirected, 107 ties; a tie means a shared land border. Node labels are the two-letter abbreviations. - Draws on: Chapters 7, 8, 15 and 18.
- Questions:
- Run
nwsummarizeandnwcomponents usstates, generate(comp). Which states are not in the main component, and why? - Run
nwgeodesic usstates, then again withunconnected(50)(give the second callname(), since the network_geodesicexists already). Which numbers change with the penalty, and which do not? What would you report? - Find the shortest paths from Maine to California with
nwpath usstates, ego(ME) alter(CA). Report the length and the number of shortest paths. - Compute betweenness and closeness (
nwcloseness usstates, unconnected(max) generate(clo far near)). Which states score highest on each? Name the flow for which border betweenness would be a sensible measure, and one for which it would not. - Report the transitivity with
nwtriads usstates. Draw ten undirected random graphs with 50 nodes and the same density withnwrandomandset seed 1, and compare their transitivity and average distance with the observed values. - Open: a random graph of the same density is an easy baseline to beat for a map. Which features of geography would a fairer baseline have to hold fixed?
- Run
4. Interlocking boards in Sweden
- Data: Swedish company directors,
nwwebuse ftdirectors_se. A two-mode network of 5,092 directors and 455 listed companies (5,669 ties); mode 1director, mode 2company. Directors havegenderandage; companies havesector,industryandemployees. Some values are missing. - Draws on: Chapters 9 and 12, and Appendix A of the book on network size.
- Questions:
- Run
nwsummarize ftdirectors_seandnwdegree ftdirectors_se, generate(deg). The two-mode degree is divided by the size of the other mode; turn it back into the number of boards per director and the number of directors per board. How many directors sit on more than one board? - Project onto the companies:
nw2project ftdirectors_se, project(2) name(boards) stat(count). What does a tie inboardsmean, and what does its value count? Why is the projection onto the 5,092 directors a poor first step here? - Run
nwcomponents boards, generate(bcomp). Report the size of the largest component and the number of companies with no shared director. - Run
nwmixing boards, attribute(sector). Do interlocks stay within sectors more than the sector sizes alone would produce? Say how you treat the companies without a sector. - Run
nwcommunity boards, algorithm(louvain) seed(12345) generate(bcom)and report the partition sizes, singletons included. - Open: an interlock can carry information between companies, or merely record that a few people are in demand. Which data would separate the two readings?
- Run
5. Friendship in a Dutch school class
- Data: the Knecht classroom,
nwwebuse klas12b. Twenty-six pupils in their first year of secondary school, friendship at four waves three months apart (klas12b_wave1toklas12b_wave4), andklas12b_primary(same primary school). Attributes includesex,age,ethnicity,religion, delinquency at four waves (delinq1todelinq4) and alcohol use at waves 2 to 4. In the delinquency and alcohol variables 0 means missing. In the loaded networks, a missing answer and a pupil who was not in the class at a wave are both coded as no tie (help netexample). - Draws on: Chapters 3, 6, 14, 25 and 26.
- Questions:
- Run
nwsaom describe, waves(klas12b_wave1 klas12b_wave2 klas12b_wave3 klas12b_wave4)andnwturnover(withgenerate(), as in Chapter 14) for each pair of consecutive waves. Is there enough change, and not too much, for an SAOM? - Run
nwmixingwithattribute(sex)andpermutations(1000)at each wave. Read each E-I index against its chance value. - Fit
nwsaom, waves(klas12b_wave1 klas12b_wave2 klas12b_wave3 klas12b_wave4) outdegree reciprocity transtrip nodematch(sex) seed(12345). Check both convergence criteria and restart withnwsaom refitif needed. Interpretnodematch_sexas a statement about the pupils’ choices. - Run
estat gof, nsim(100) seed(1). Where does the model fail? - Hold two candidate effects at 0 with
fix(), as Chapter 26 does, and runestat score. Which effect would you free first? - Open: no tie and no answer are coded alike here. Which of your results could that affect, and in which direction?
- Run
6. Support among the characters of the Harry Potter books
- Data: Harry Potter support networks,
nwwebuse hpotter. Sixty-four characters; directed support ties in each of six books (hpbook1tohpbook6). Attributes:schoolyear,genderandhouse(coded 1 to 4). - Draws on: Chapters 3, 6, 14, 19 and 20.
- Questions:
- Run
nwsummarizeon all six networks. The number of ties differs a lot between books. Using the reporting checklist of Chapter 3, say what a “wave” is in these data and what the book-to-book differences may reflect besides change in support. - Run
nwturnover(withgenerate(), as in Chapter 14) for each pair of consecutive books and report the Jaccard index and persistence. - Report the reciprocity of each book with
nwdyads. - Look at the mixing table of
hpbook1byhousebefore testing anything. Then runnwmixing hpbook5, attribute(house) permutations(1000)and the same withattribute(gender). Compute the chance values from the group sizes (tab house,tab gender). - After
set seed 12345, fitnwqap hpbook2 hpbook1 house gender, permutations(200). Read the coefficients of the earlier book and of shared house. Fit the same model for a later pair of books. - Open: the ties were coded from novels by readers. What is a tie here, and which conclusions about real support networks could such data support?
- Run
7. Nineteen Dutch schools compared
- Data: the Dutch Social Behavior study,
nwwebuse baerveldt19. Nineteen schools, two waves; for each school k the networksschoolk_w1andschoolk_w2(directed) andschoolk_ethn(whether the parents of two pupils were born in the same country). Chapter 26 uses these data for a joint SAOM; this assignment compares the schools descriptively and with permutation methods. - Draws on: Chapters 6, 14, 18, 19, 20 and 30; Chapter 26 for the last question.
- Questions:
- In a loop over the schools, collect size, density, mean degree, reciprocity (
nwdyads) and the Jaccard index between the waves (nwturnover) into a results data set withpostfile, using stored results instead of retyped numbers (as in Chapter 30, Ex. 5). Which schools are dense? Does the ranking change with mean degree? - Check whether the waves contain missing ties, and how the measures you use treat them.
- Test the reciprocity of the first wave in each school with
nwcug, stat(nwdyads) rname(reciprocity) condition(density), with a modestreps(). Then repeat the test for one school withcondition(census)in place ofcondition(density), and say why that condition cannot test reciprocity. - For three schools, run
nwcorrelate schoolk_w1 schoolk_ethn, permutations(1000)andnwqap schoolk_w2 schoolk_w1 schoolk_ethn, permutations(500). Is friendship sorted by ethnic background, once the earlier friendships are held fixed? - Open: on the evidence of your table, would you pool the schools in one model or analyze them separately and combine the results? Compare your answer with the reasoning of Chapter 26.
- In a loop over the schools, collect size, density, mean degree, reciprocity (
8. The full US airport network
- Data: US airports,
nwwebuse usair_full. Every US airport with a scheduled non-stop domestic route: 549 airports, 5,450 directed routes. Attributes:iata,name,city,lat,lonand the degrees_outdegree,_indegreeand_degree. Chapters 5 and 7 useusair, the 50 busiest airports. - Draws on: Chapters 3, 5, 7 and 8, and Appendix A of the book.
- Questions:
- Run
nwcomponents usair_full, generate(comp)and list the airports outside the main component with their cities. What are they? - Run
nwgeodesic usair_full. Report the share of connected pairs and the average distance over them. Compare withusair, and say what the boundary of the 50 busiest airports hides (Chapter 3). - Compute betweenness and list the five highest airports with their cities. The highest is not the busiest hub; explain why, from the routes it connects.
- Compute closeness with
unconnected(max)and once without the option. How do the rankings differ, and which would you report? - Optional: draw the network on the map of the states as Chapter 5 draws
usair, withnodexy(lon lat)andbasemap(usmap), restricted to the contiguous states with anifcondition. - Open: betweenness counts shortest paths in the number of flights. Which question about air travel does that answer, and which does it not?
- Run
9. A tailor shop before and after a dispute
- Data: Kapferer’s tailor shop,
nwwebuse kapferer. Interaction among workers at two times around a labor dispute, undirected:kapferer_t1(39 nodes, 158 ties) andkapferer_t2(43 nodes, 190 ties). The two networks do not share a node set, so they are not a panel on the same actors. No attributes. - Draws on: Chapters 6, 9, 14, 21 and 22.
- Questions:
- Describe both networks: density, mean degree, transitivity (
nwtriads), components and k-cores (nwkcore). Which comparisons between the two are fair, given that the node sets differ? - Try
nwturnover kapferer_t1 kapferer_t2, generate(_turnover). Why does it not apply here? - Fit
nwergm kapferer_t2, edges gwesp(.5) seed(12345). Runestat mcmcdiagandestat gof, gof(model distance degree espartners) seed(12345). Where does the model fit and where does it fail? - Fit
nwergm kapferer_t2, edges triangle seed(12345)withcapture noisily. What happens, and why doesgwespavoid it? - Fit the gwesp model to
kapferer_t1as well. What would you need to know before reading a difference between the two coefficients as a change caused by the dispute? - Open: design a study of the same shop that could show whether the dispute changed who interacts with whom.
- Describe both networks: density, mean degree, transitivity (