. * nwsaom tutorial 6: maximum likelihood, Bayesian estimation, two networks . * Requires the core nwcommands and the package nwsaom. . . nwwebuse glasgow, nwclear . . * Method of moments, for comparison . nwsaom, waves(glasgow1 glasgow2 glasgow3) outdegree reciprocity transtrip seed(1) ------------------------------------------------------------------------------------------------------------------------- SAOM (Method of Moments, conditional), waves: glasgow1 glasgow2 glasgow3 Actors: 50 Periods: 2 ------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------- glasgow1_t~3 | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- outdegree | -2.687867 .1214406 -22.13 0.000 -2.925886 -2.449847 reciprocity | 2.457453 .2035477 12.07 0.000 2.058507 2.8564 transtrip | .6202674 .0789534 7.86 0.000 .4655217 .7750132 ------------------------------------------------------------------------------------------------------------------------- Rate parameters (estimated, one per inter-wave period): | period1 period2 -------------+--------------------- rate | 6.5292 5.2435 se | 1.0759 0.9023 Overall maximum convergence ratio: 0.142 (criterion: below 0.25; met) Convergence t-ratios (criterion: all below 0.1 in absolute value): not met for outdegree (-0.139) reciprocity (-0.130) Convergence is good only if both criteria are met. Refit starting from these estimates with theta0(); see nwsaom. . . * Maximum likelihood . nwsaom, waves(glasgow1 glasgow2 glasgow3) outdegree reciprocity transtrip seed(1) ml ------------------------------------------------------------------------------------------------------------------------- SAOM (Method of Moments, conditional), waves: glasgow1 glasgow2 glasgow3 Actors: 50 Periods: 2 ------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------- glasgow1_t~3 | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- outdegree | -2.687867 .1214406 -22.13 0.000 -2.925886 -2.449847 reciprocity | 2.457453 .2035477 12.07 0.000 2.058507 2.8564 transtrip | .6202674 .0789534 7.86 0.000 .4655217 .7750132 ------------------------------------------------------------------------------------------------------------------------- Rate parameters (estimated, one per inter-wave period): | period1 period2 -------------+--------------------- rate | 6.5292 5.2435 se | 1.0759 0.9023 Overall maximum convergence ratio: 0.142 (criterion: below 0.25; met) Convergence t-ratios (criterion: all below 0.1 in absolute value): not met for outdegree (-0.139) reciprocity (-0.130) Convergence is good only if both criteria are met. Refit starting from these estimates with theta0(); see nwsaom. Maximum likelihood: phase 1 50 iterations, phase 2 4 subphases from 100 iterations, phase 3 1000 iterations ... Maximum likelihood estimates (Robbins-Monro on the score of the augmented data) ------------------------------------------------------------------------------------------------------------------------- glasgow1_t~3 | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- outdegree | -2.646338 .1095288 -24.16 0.000 -2.86101 -2.431665 reciprocity | 2.265619 .1803705 12.56 0.000 1.912099 2.619139 transtrip | .6837719 .0654852 10.44 0.000 .5554233 .8121205 ------------------------------------------------------------------------------------------------------------------------- Rate parameters (one per inter-wave period): period1 period2 rate 6.4886 5.4048 se 0.8839 0.7473 tconv -0.0540 -0.0422 Overall maximum t-ratio of the scores: 0.234 (acceptable) . . * Bayesian estimation: a short run, after a method-of-moments fit . quietly nwsaom, waves(glasgow1 glasgow2 glasgow3) outdegree reciprocity transtrip seed(1) . nwsaom bayes, nprewarm(20) nwarm(20) nmain(100) nrunmh(5) seed(7) Sampling: 20 pre-warming + 20 warming + 100 main iterations of 5 batches ... Bayesian SAOM (data augmentation) Number of actors = 50 Waves: glasgow1 glasgow2 glasgow3 Saved draws = 100 Pre-warm 20, warm 20, main 100 x 5 Mean chain length = 570.3 Acceptance: effects 0.462, rates 0.270; chain steps: diagonal 0.728, permute 0.619, insert-permute 0.370, delete-permute > 0.329 ------------------------------------------------------------------------------------------------------------------------- Effect |Post. mean Post. sd[95% interval] Median ESS -------------+--------------------------------------------------------------- outdegree | -2.6935 0.1232 -2.9096 -2.4620 -2.6920 9 reciprocity | 2.2710 0.1989 1.9126 2.6400 2.2763 8 transtrip | 0.7051 0.0669 0.5824 0.8292 0.6930 27 rate_period1 | 6.0542 0.6211 5.1038 7.1997 6.0441 13 rate_period2 | 5.3817 0.7525 4.0248 6.9119 5.2871 6 ------------------------------------------------------------------------------------------------------------------------- Draws (one per main iteration) are in frame nwsaom_bayes_draws (b1..b3 effects, rate1..rate2, nchain, loglik); flat prio > rs unless priormean()/priorsd()/priorrate() are given. . . * Two networks that change together. The Glasgow data have only one network, . * so we SIMULATE a second one ("advice") that overlaps with friendship. . nwtomata glasgow1, mat(F1) . nwtomata glasgow2, mat(F2) . set seed 20261001 . mata: A1 = (F1 :* (runiform(50, 50) :< 0.7) + (runiform(50, 50) :< 0.005)) :> 0 . mata: _diag(A1, 0) . mata: A2 = (A1 :* (runiform(50, 50) :< 0.8) + F2 :* (1 :- A1) :* (runiform(50, 50) :< 0.4)) :> 0 . mata: _diag(A2, 0) . nwset, mat(A1) directed name(advice1) . nwset, mat(A2) directed name(advice2) . nwsaom multinet, net1(glasgow1 glasgow2) net2(advice1 advice2) cross1(crprod) cross2(crprod) seed(1) ------------------------------------------------------------------------------------------------------------------------- Several co-evolving networks (Method of Moments), 2 waves, 50 actors ------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------- | Coefficient Std. err. z P>|z| [95% conf. interval] -----------------+---------------------------------------------------------------- net1_outdegree | -2.297847 .1393271 -16.49 0.000 -2.570923 -2.024771 net1_reciprocity | 2.299379 .2197 10.47 0.000 1.868775 2.729983 net1_x_crprod | .6369573 .3438109 1.85 0.064 -.0368996 1.310814 net2_outdegree | -2.039054 .3099247 -6.58 0.000 -2.646495 -1.431613 net2_reciprocity | 2.017523 .4941018 4.08 0.000 1.049101 2.985944 net2_x_crprod | .87247 .9096327 0.96 0.337 -.9103773 2.655317 ------------------------------------------------------------------------------------------------------------------------- Rates (estimated): period1 rate_net1 6.744 rate_net2 1.590 se_net1 1.001 se_net2 0.224 Overall maximum convergence ratio: 0.260 (criterion: below 0.25; not met) . . * The overall maximum convergence ratio is above 0.25: restart from the estimates . matrix b = e(b) . local th . forvalues j = 1/`=colsof(b)' { 2. local th `th' `=b[1,`j']' 3. } . nwsaom multinet, net1(glasgow1 glasgow2) net2(advice1 advice2) cross1(crprod) cross2(crprod) theta0(`th') seed(2) ------------------------------------------------------------------------------------------------------------------------- Several co-evolving networks (Method of Moments), 2 waves, 50 actors ------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------- | Coefficient Std. err. z P>|z| [95% conf. interval] -----------------+---------------------------------------------------------------- net1_outdegree | -2.311336 .1234978 -18.72 0.000 -2.553388 -2.069285 net1_reciprocity | 2.314326 .2774067 8.34 0.000 1.770619 2.858033 net1_x_crprod | .6479287 .3880397 1.67 0.095 -.1126152 1.408473 net2_outdegree | -2.021367 .208823 -9.68 0.000 -2.430652 -1.612081 net2_reciprocity | 2.032402 .4654263 4.37 0.000 1.120184 2.944621 net2_x_crprod | .8226323 .6930513 1.19 0.235 -.5357232 2.180988 ------------------------------------------------------------------------------------------------------------------------- Rates (estimated): period1 rate_net1 6.775 rate_net2 1.596 se_net1 1.401 se_net2 0.275 Overall maximum convergence ratio: 0.179 (criterion: below 0.25; met) .