. * nwsaom tutorial 11: simulation and what-if analysis . * Requires the core nwcommands and the package nwsaom. . . nwwebuse glasgow, nwclear . . * A fitted model over one period . nwsaom, wave1(glasgow1) wave2(glasgow2) outdegree reciprocity transtrip seed(4) ---------------------------------------------------------------------------------------------------- SAOM (Method of Moments, conditional), waves: glasgow1 -> glasgow2 Actors: 50 Estimated rate: 6.206 (1.029) ---------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------ glasgow1_t~2 | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- outdegree | -2.530242 .1427265 -17.73 0.000 -2.809981 -2.250503 reciprocity | 2.157208 .2343807 9.20 0.000 1.69783 2.616586 transtrip | .5941483 .105325 5.64 0.000 .3877151 .8005816 ------------------------------------------------------------------------------ Overall maximum convergence ratio: 0.045 (criterion: below 0.25; met) Convergence t-ratios (criterion: all below 0.1 in absolute value): met . matrix b = e(b) . matrix list b b[1,3] outdegree reciprocity transtrip y1 -2.5302421 2.157208 .59414831 . . * Simulate the fitted model 100 times, starting from the observed first wave . estat simulate, nsim(100) seed(5) Simulation from the fitted model: 100 replication(s) of 1 period(s). Mean over replications (observed end wave in brackets): period ties mutual transitive behavior 1 115.4 ( 116) 35.6 ( 35) 90.3 ( 88) . matrix list r(obs) r(obs)[1,6] sim period ties mutual transitive behmean r1 . 1 116 35 88 . . matrix S = r(sim) . mata: ------------------------------------------------- mata (type end to exit) -------------------------- : S = st_matrix("S") : printf("ties: mean %5.1f, sd %5.1f\n", mean(S[., 3]), sqrt(variance(S[., 3]))) ties: mean 115.4, sd 17.1 : printf("mutual: mean %5.1f, sd %5.1f\n", mean(S[., 4]), sqrt(variance(S[., 4]))) mutual: mean 35.6, sd 7.9 : printf("transitive: mean %5.1f, sd %5.1f\n", mean(S[., 5]), sqrt(variance(S[., 5]))) transitive: mean 90.3, sd 50.1 : end ---------------------------------------------------------------------------------------------------- . . * Save the simulated end networks and compare one with the observed . * second wave . estat simulate, nsim(3) seed(5) generate(sim) Simulation from the fitted model: 3 replication(s) of 1 period(s). Mean over replications (observed end wave in brackets): period ties mutual transitive behavior 1 121.0 ( 116) 35.3 ( 35) 108.3 ( 88) . nwsaom describe, waves(glasgow2 sim_1_p1) Network data: 2 waves, 50 actors, directed ---------------------------------------------------------- wave ties density avg. degree 1 116 0.0473 2.320 2 97 0.0396 1.940 ---------------------------------------------------------- period kept created dissolved Jaccard Hamming 1->2 31 66 85 0.170 151 (Jaccard below 0.3: few ties stay, so the data say little about the change process; see the SAOM l > iterature) ---------------------------------------------------------- . . * --------------------------------------------------------------- . * Simulation at chosen coefficients, without any estimation. . * theta() is in the order of the coefficient table: outdegree, . * reciprocity, transtrip; rates() has one rate per period. . * --------------------------------------------------------------- . nwsaom simulate, wave1(glasgow1) wave2(glasgow2) outdegree reciprocity transtrip theta(-2.7 2.4 0. > 6) rates(6) nsim(100) seed(5) Simulation from the fitted model: 100 replication(s) of 1 period(s). Mean over replications (observed end wave in brackets): period ties mutual transitive behavior 1 105.4 ( 116) 33.9 ( 35) 72.6 ( 88) . . * The same world without any tendency to reciprocate . nwsaom simulate, wave1(glasgow1) wave2(glasgow2) outdegree reciprocity transtrip theta(-2.7 0 0.6) > rates(6) nsim(100) seed(5) Simulation from the fitted model: 100 replication(s) of 1 period(s). Mean over replications (observed end wave in brackets): period ties mutual transitive behavior 1 39.8 ( 116) 0.6 ( 35) 1.2 ( 88) . . * --------------------------------------------------------------- . * What if an effect did not operate? 'estat mems' switches one . * coefficient off and compares a network summary that you define. . * --------------------------------------------------------------- . capture program drop mutualties . program define mutualties, rclass 1. args netname 2. nwtomata `netname', mat(MM) 3. mata: st_numscalar("__mut", sum(MM :* MM') / 2) 4. return scalar stat = scalar(__mut) 5. end . quietly nwsaom, wave1(glasgow1) wave2(glasgow2) outdegree reciprocity transtrip seed(4) . estat mems, effect(reciprocity) macro(mutualties) nsim(100) seed(1) interval 0: .. interval 1: .. ---------------------------------------------------------------------------------------------------- MEMs (Micro Effects on Macro Structure) - Duxbury, via mutualties Micro process: reciprocity Interval: 0 1 nsim: 100 ---------------------------------------------------------------------------------------------------- | Estimate Std. Dev. [95% CI] MC p-val ---------------------------------------------------------------------------------------------------- MEMS 37.1800 11.4216 14.4250 , 59.0000 0.0000 Prop. Change in M 0.9742 ---------------------------------------------------------------------------------------------------- (MEMS = mean difference in mutualties between interval=1 and interval=0; Prop. Change in M = that di > fference as a proportion of the interval=1 value; MC p-val = proportion of draws with the opposite > sign - a real, disclosed simplification vs real netmediate/RSiena: independent simulation randomn > ess per draw, no common-random-numbers pairing, and the VanderWeele E-value sensitivity bound is n > ot yet implemented) .