. * nwsaom tutorial 9: undirected and two-mode networks . * Requires the core nwcommands and the package nwsaom. . . nwwebuse glasgow, nwclear . . * --------------------------------------------------------------- . * Part 1: undirected networks. Make the friendship networks . * undirected: a tie exists if either pupil named the other. . * --------------------------------------------------------------- . nwsym glasgow1, generate(u1) mode(max) . nwsym glasgow2, generate(u2) mode(max) . nwsym glasgow3, generate(u3) mode(max) . nwsaom describe, waves(u1 u2 u3) Network data: 3 waves, 50 actors, undirected ---------------------------------------------------------- wave ties density avg. degree 1 74 0.0604 2.960 2 81 0.0661 3.240 3 77 0.0629 3.080 ---------------------------------------------------------- period kept created dissolved Jaccard Hamming 1->2 43 38 31 0.384 69 2->3 47 30 34 0.423 64 ---------------------------------------------------------- . . * No reciprocity effect: every tie is reciprocated by definition. . * The default model: one pupil proposes a change and imposes it (forcing). . nwsaom, waves(u1 u2 u3) outdegree gwesp(.69) samex(smoke1) seed(4) ---------------------------------------------------------------------------------------------------- SAOM (Method of Moments, conditional), waves: u1 u2 u3 Actors: 50 Periods: 2 ---------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------ u1_to_u3 | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- outdegree | -2.370856 .1885703 -12.57 0.000 -2.740447 -2.001265 samex_smoke1 | .2002612 .188039 1.06 0.287 -.1682885 .568811 gwesp_.69 | 1.625979 .1710248 9.51 0.000 1.290776 1.961181 ------------------------------------------------------------------------------ Rate parameters (estimated, one per inter-wave period): | period1 period2 -------------+--------------------- rate | 2.4826 2.0093 se | 0.4241 0.3160 Overall maximum convergence ratio: 0.094 (criterion: below 0.25; met) Convergence t-ratios (criterion: all below 0.1 in absolute value): met . . * Other rules for how an undirected tie changes . nwsaom, waves(u1 u2 u3) outdegree gwesp(.69) samex(smoke1) symtype(confirmation) seed(4) ---------------------------------------------------------------------------------------------------- SAOM (Method of Moments, conditional), waves: u1 u2 u3 Actors: 50 Periods: 2 ---------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------ u1_to_u3 | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- outdegree | -1.380789 .1185397 -11.65 0.000 -1.613122 -1.148455 samex_smoke1 | .1235281 .12458 0.99 0.321 -.1206443 .3677004 gwesp_.69 | 1.095177 .1085168 10.09 0.000 .8824875 1.307866 ------------------------------------------------------------------------------ Rate parameters (estimated, one per inter-wave period): | period1 period2 -------------+--------------------- rate | 5.0775 4.0687 se | 0.8474 0.6750 Overall maximum convergence ratio: 0.077 (criterion: below 0.25; met) Convergence t-ratios (criterion: all below 0.1 in absolute value): met . nwsaom, waves(u1 u2 u3) outdegree gwesp(.69) samex(smoke1) symtype(joint) seed(4) ---------------------------------------------------------------------------------------------------- SAOM (Method of Moments, conditional), waves: u1 u2 u3 Actors: 50 Periods: 2 ---------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------ u1_to_u3 | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- outdegree | -2.087691 .171507 -12.17 0.000 -2.423838 -1.751543 samex_smoke1 | .153545 .1718964 0.89 0.372 -.1833656 .4904557 gwesp_.69 | 1.343861 .1352783 9.93 0.000 1.078721 1.609002 ------------------------------------------------------------------------------ Rate parameters (estimated, one per inter-wave period): | period1 period2 -------------+--------------------- rate | 0.4712 0.3753 se | 0.0856 0.0660 Overall maximum convergence ratio: 0.030 (criterion: below 0.25; met) Convergence t-ratios (criterion: all below 0.1 in absolute value): met . . * Reciprocity is refused for an undirected network . capture noisily nwsaom, waves(u1 u2 u3) outdegree reciprocity reciprocity is not meaningful under symmetric - every tie is reciprocated by construction once both > directions are forced equal, so this effect's own statistic is a constant (RSiena itself does not > offer recip for a non-directed dependent variable). invalid syntax . display "return code: " _rc return code: 198 . . * --------------------------------------------------------------- . * Part 2: a two-mode network. The Davis "Southern women" data are . * a two-mode network observed once: 18 women, 14 social events. . * --------------------------------------------------------------- . nwwebuse davis, nwclear . nwsummarize -------------------------------------------------- Network name: davis Network id: 1 Directed: false Valued: false Two-mode: true Nodes: 32 Level 1: 18 (woman) Level 2: 14 (event) Selfloop: false Edges: 89 Minimum value: 0 Maximum value: 1 Density: .353 Temporal: false . . * Cut the 18 x 14 attendance matrix out of the full adjacency matrix . nwtomata davis, mat(D) . mata: ------------------------------------------------- mata (type end to exit) -------------------------- : mode = st_sdata(., "_nwmode") : women = selectindex(mode :== "1") : events = selectindex(mode :== "2") : A1 = D[women, events] : rows(A1), cols(A1), sum(A1) 1 2 3 +----------------+ 1 | 18 14 89 | +----------------+ : end ---------------------------------------------------------------------------------------------------- . . * No longitudinal two-mode data ship with the packages, so we create two . * later waves ourselves. A woman is picked at random, looks at every event . * and either keeps things as they are or toggles one attendance. Joining . * an event is more attractive the more women already attend it: the . * effect of indegree popularity is 0.3 and the density effect is -1.5. . mata: ------------------------------------------------- mata (type end to exit) -------------------------- : rseed(20261027) : nw = rows(A1) : ne = cols(A1) : A = A1 : st_matrix("W1", A1) : printf("wave 1: %g attendances\n", sum(A1)) wave 1: 89 attendances : for (w = 2; w <= 3; w++) { > for (s = 1; s <= 200; s++) { > i = ceil(runiform(1, 1) * nw) > deg = colsum(A) > u = J(1, ne + 1, 0) > for (j = 1; j <= ne; j++) { > sgn = A[i, j] ? -1 : 1 > u[j] = sgn * (-1.5) + 0.3 * ((deg[j] + sgn) ^ 1.5 - deg[j] ^ 1.5) > } > p = exp(u) / sum(exp(u)) > r = runiform(1, 1) > k = 1 > while (k < ne + 1 & r > sum(p[1..k])) k++ > if (k <= ne) A[i, k] = 1 - A[i, k] > } > st_matrix("W" + strofreal(w), A) > printf("wave %g: %g attendances\n", w, sum(A)) > } wave 2: 78 attendances wave 3: 82 attendances : end ---------------------------------------------------------------------------------------------------- . mata: mata clear . clear . nwset, mat(W1) bipartite name(women1) . nwset, mat(W2) bipartite name(women2) . nwset, mat(W3) bipartite name(women3) . * The rows (women) are the actors who choose among the columns (events) . nwsaom, waves(women1 women2 women3) outdegree indegpopularity seed(4) (two-mode network: 18 actors (mode 2) choose among 14 events) ---------------------------------------------------------------------------------------------------- SAOM (Method of Moments, conditional), waves: women1 women2 women3 Actors: 32 Periods: 2 Two-mode network: 18 actors choose among 14 events ---------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------- women1_to_wom~3 | Coefficient Std. err. z P>|z| [95% conf. interval] ----------------+---------------------------------------------------------------- outdegree | -1.923622 .2516051 -7.65 0.000 -2.416759 -1.430485 indegpopularity | .5911646 .0942954 6.27 0.000 .406349 .7759801 --------------------------------------------------------------------------------- Rate parameters (estimated, one per inter-wave period): | period1 period2 -------------+--------------------- rate | 11.5125 9.9544 se | 2.4674 2.1855 Overall maximum convergence ratio: 0.082 (criterion: below 0.25; met) Convergence t-ratios (criterion: all below 0.1 in absolute value): met . nwsaom, waves(women1 women2 women3) outdegree indegpopularity outactivity seed(6) (two-mode network: 18 actors (mode 2) choose among 14 events) ---------------------------------------------------------------------------------------------------- SAOM (Method of Moments, conditional), waves: women1 women2 women3 Actors: 32 Periods: 2 Two-mode network: 18 actors choose among 14 events ---------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------- women1_to_wom~3 | Coefficient Std. err. z P>|z| [95% conf. interval] ----------------+---------------------------------------------------------------- outdegree | -1.746669 .4122939 -4.24 0.000 -2.55475 -.9385877 indegpopularity | .5775975 .0940682 6.14 0.000 .3932272 .7619678 outactivity | -.0159469 .0341944 -0.47 0.641 -.0829666 .0510728 --------------------------------------------------------------------------------- Rate parameters (estimated, one per inter-wave period): | period1 period2 -------------+--------------------- rate | 11.4227 10.0482 se | 2.6326 2.1795 Overall maximum convergence ratio: 0.095 (criterion: below 0.25; met) Convergence t-ratios (criterion: all below 0.1 in absolute value): met . . * Let the events be the actors instead (the roles swap) . nwsaom, waves(women1 women2 women3) outdegree indegpopularity actormode(1) seed(7) (two-mode network: 14 actors (mode 1) choose among 18 events) ---------------------------------------------------------------------------------------------------- SAOM (Method of Moments, conditional), waves: women1 women2 women3 Actors: 32 Periods: 2 Two-mode network: 14 actors choose among 18 events ---------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------- women1_to_wom~3 | Coefficient Std. err. z P>|z| [95% conf. interval] ----------------+---------------------------------------------------------------- outdegree | -.1135387 .5292987 -0.21 0.830 -1.150945 .9238677 indegpopularity | -.1428934 .2334045 -0.61 0.540 -.6003578 .3145709 --------------------------------------------------------------------------------- Rate parameters (estimated, one per inter-wave period): | period1 period2 -------------+--------------------- rate | 13.0694 11.1071 se | 2.3102 2.0313 Overall maximum convergence ratio: 0.143 (criterion: below 0.25; met) Convergence t-ratios (criterion: all below 0.1 in absolute value): met .