. * nwergm tutorial 2: terms and model specification . * Requires the core nwcommands and the package nwergm. . . nwergm version nwergm version 1.3.1, 26oct2026 core package nwcommands : installed (development copy, no distribution date) native plugin : .../nwergm/lib/plugins/macos/ergm_mcmc_macos.plugin (ships with the package, no separate version number) compared with : R ergm 4.12.0 license : GNU GPL-3 . . * ---- dyad-independent terms: the mesa high school friendship network . nwwebuse mesa, nwclear . describe Contains data from https://raw.githubusercontent.com/thomas-u-grund/nwcommands/main/data/mesa.nwdta Observations: 205 Variables: 5 1 Sep 2026 21:41 ------------------------------------------------------------------------------------------------------------------------- Variable Storage Display Value name type format label Variable label ------------------------------------------------------------------------------------------------------------------------- _nwnode str40 %40s _nwinclude float %9.0g grade byte %8.0g race str5 %9s sex str1 %9s ------------------------------------------------------------------------------------------------------------------------- Sorted by: Note: Dataset has changed since last saved. . tabulate race race | Freq. Percent Cum. ------------+----------------------------------- Black | 6 2.93 2.93 Hisp | 109 53.17 56.10 NatAm | 68 33.17 89.27 Other | 4 1.95 91.22 White | 18 8.78 100.00 ------------+----------------------------------- Total | 205 100.00 . tabulate sex sex | Freq. Percent Cum. ------------+----------------------------------- F | 99 48.29 48.29 M | 106 51.71 100.00 ------------+----------------------------------- Total | 205 100.00 . tabulate grade grade | Freq. Percent Cum. ------------+----------------------------------- 7 | 62 30.24 30.24 8 | 40 19.51 49.76 9 | 42 20.49 70.24 10 | 25 12.20 82.44 11 | 24 11.71 94.15 12 | 12 5.85 100.00 ------------+----------------------------------- Total | 205 100.00 . . * node attributes in nwergm must be numeric: encode the string variables . encode race, generate(race_n) . encode sex, generate(sex_n) . . nwergm mesa, edges Exponential-family random graph model Network: = mesa Nodes: = 205 Ties: = 203 Directed: = No Estimation: = MPLE ------------------------------------------------------------------------------ mesa | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- edges | -4.625021 .0705294 -65.58 0.000 -4.763256 -4.486786 ------------------------------------------------------------------------------ Maximum pseudolikelihood estimate (not full ERGM maximum likelihood unless the model is dyad-independent). Null Deviance: 28987.4 on 20910 degrees of freedom Residual Deviance: 2285.7 on 20909 degrees of freedom Log-likelihood: -1142.8711 (df = 1) AIC: 2287.7 BIC: 2295.7 (MC std. err. = 0) . nwergm mesa, edges nodematch(grade) Exponential-family random graph model Network: = mesa Nodes: = 205 Ties: = 203 Directed: = No Estimation: = MPLE --------------------------------------------------------------------------------- mesa | Coefficient Std. err. z P>|z| [95% conf. interval] ----------------+---------------------------------------------------------------- edges | -6.034045 .1583032 -38.12 0.000 -6.344314 -5.723776 nodematch_grade | 2.830999 .1773251 15.97 0.000 2.483449 3.17855 --------------------------------------------------------------------------------- Maximum pseudolikelihood estimate (not full ERGM maximum likelihood unless the model is dyad-independent). Null Deviance: 28987.4 on 20910 degrees of freedom Residual Deviance: 1939.5 on 20908 degrees of freedom Log-likelihood: -969.7742 (df = 2) AIC: 1943.5 BIC: 1959.4 (MC std. err. = 0) . nwergm mesa, edges nodematch(grade race_n sex_n) Exponential-family random graph model Network: = mesa Nodes: = 205 Ties: = 203 Directed: = No Estimation: = MPLE ---------------------------------------------------------------------------------- mesa | Coefficient Std. err. z P>|z| [95% conf. interval] -----------------+---------------------------------------------------------------- edges | -6.600575 .1998753 -33.02 0.000 -6.992324 -6.208827 nodematch_grade | 2.830693 .177456 15.95 0.000 2.482886 3.178501 nodematch_race_n | .4331562 .1429951 3.03 0.002 .1528911 .7134214 nodematch_sex_n | .6447389 .149475 4.31 0.000 .3517733 .9377045 ---------------------------------------------------------------------------------- Maximum pseudolikelihood estimate (not full ERGM maximum likelihood unless the model is dyad-independent). Null Deviance: 28987.4 on 20910 degrees of freedom Residual Deviance: 1911.2 on 20906 degrees of freedom Log-likelihood: -955.5870 (df = 4) AIC: 1919.2 BIC: 1951.0 (MC std. err. = 0) . nwergm mesa, edges nodematch(grade) nodematchdiff(sex_n) Exponential-family random graph model Network: = mesa Nodes: = 205 Ties: = 203 Directed: = No Estimation: = MPLE ----------------------------------------------------------------------------------- mesa | Coefficient Std. err. z P>|z| [95% conf. interval] ------------------+---------------------------------------------------------------- edges | -6.392904 .1856467 -34.44 0.000 -6.756765 -6.029043 nodematch_grade | 2.820284 .1774895 15.89 0.000 2.472411 3.168157 nodematch_sex_n_1 | .8880277 .1651607 5.38 0.000 .5643186 1.211737 nodematch_sex_n_2 | .333064 .1871779 1.78 0.075 -.033798 .699926 ----------------------------------------------------------------------------------- Maximum pseudolikelihood estimate (not full ERGM maximum likelihood unless the model is dyad-independent). Null Deviance: 28987.4 on 20910 degrees of freedom Residual Deviance: 1910.8 on 20906 degrees of freedom Log-likelihood: -955.4147 (df = 4) AIC: 1918.8 BIC: 1950.6 (MC std. err. = 0) . nwergm mesa, edges nodematch(grade) nodefactor(race_n) nodemix(sex_n) Exponential-family random graph model Network: = mesa Nodes: = 205 Ties: = 203 Directed: = No Estimation: = MPLE ------------------------------------------------------------------------------------- mesa | Coefficient Std. err. z P>|z| [95% conf. interval] --------------------+---------------------------------------------------------------- edges | -3.303633 .4342755 -7.61 0.000 -4.154797 -2.452468 nodematch_grade | 2.874633 .1785757 16.10 0.000 2.524631 3.224635 nodefactor_race_n_2 | -1.335929 .2233276 -5.98 0.000 -1.773643 -.8982147 nodefactor_race_n_3 | -.924473 .2260387 -4.09 0.000 -1.367501 -.4814453 nodefactor_race_n_4 | -3.214314 1.025584 -3.13 0.002 -5.224422 -1.204206 nodefactor_race_n_5 | -.8606332 .2582152 -3.33 0.001 -1.366726 -.3545407 nodemix_sex_n_1_2 | -.9352662 .1663521 -5.62 0.000 -1.26131 -.6092221 nodemix_sex_n_2_2 | -.6284435 .1849762 -3.40 0.001 -.9909901 -.2658968 ------------------------------------------------------------------------------------- Maximum pseudolikelihood estimate (not full ERGM maximum likelihood unless the model is dyad-independent). Null Deviance: 28987.4 on 20910 degrees of freedom Residual Deviance: 1863.4 on 20902 degrees of freedom Log-likelihood: -931.6931 (df = 8) AIC: 1879.4 BIC: 1943.0 (MC std. err. = 0) . . * ---- dyad-dependent terms: the Lazega lawyers' friendship network (directed) . nwwebuse lazega, nwclear . encode practice, generate(prac) . nwergm lazega_fr, edges mutual nodematch(prac) nodeicov(seniority) Exponential-family random graph model Network: = lazega_fr Nodes: = 71 Ties: = 575 Directed: = Yes Estimation: = MCMLE MCMC sample size: = 486 ------------------------------------------------------------------------------------ lazega_fr | Coefficient Std. err. z P>|z| [95% conf. interval] -------------------+---------------------------------------------------------------- edges | -2.514152 .1074062 -23.41 0.000 -2.724665 -2.30364 mutual | .9874129 .1527646 6.46 0.000 .6879997 1.286826 nodematch_prac | .9147415 .0937094 9.76 0.000 .7310745 1.098409 nodeicov_seniority | -.006675 .0022217 -3.00 0.003 -.0110295 -.0023205 ------------------------------------------------------------------------------------ MCMLE converged after 1 iteration(s). Evaluating log-likelihood at the estimate (bridge sampling with 16 bridges) ... Null Deviance: 6889.9 on 4970 degrees of freedom Residual Deviance: 3395.4 on 4966 degrees of freedom Log-likelihood: -1697.6808 (df = 4) AIC: 3403.4 BIC: 3429.4 (MC std. err. = .14486) . nwergm lazega_fr, edges mutual nodematch(prac) nodeicov(seniority) gwesp(0.5) seed(1) Exponential-family random graph model Network: = lazega_fr Nodes: = 71 Ties: = 575 Directed: = Yes Estimation: = MCMLE MCMC sample size: = 486 ------------------------------------------------------------------------------------ lazega_fr | Coefficient Std. err. z P>|z| [95% conf. interval] -------------------+---------------------------------------------------------------- edges | -3.32184 .131386 -25.28 0.000 -3.579352 -3.064328 mutual | .7969492 .1553399 5.13 0.000 .4924887 1.10141 nodematch_prac | .7214706 .080024 9.02 0.000 .5646264 .8783149 nodeicov_seniority | -.0046162 .0018014 -2.56 0.010 -.0081468 -.0010856 gwesp_0.5 | .4935235 .061269 8.06 0.000 .3734384 .6136085 ------------------------------------------------------------------------------------ MCMLE converged after 2 iteration(s). Evaluating log-likelihood at the estimate (bridge sampling with 16 bridges) ... Null Deviance: 6889.9 on 4970 degrees of freedom Residual Deviance: 3334.9 on 4965 degrees of freedom Log-likelihood: -1667.4731 (df = 5) AIC: 3344.9 BIC: 3377.5 (MC std. err. = .15171) . nwergm lazega_fr, edges mutual nodematch(prac) nodeicov(seniority) gwesp(1) seed(1) Exponential-family random graph model Network: = lazega_fr Nodes: = 71 Ties: = 575 Directed: = Yes Estimation: = MCMLE MCMC sample size: = 406 ------------------------------------------------------------------------------------ lazega_fr | Coefficient Std. err. z P>|z| [95% conf. interval] -------------------+---------------------------------------------------------------- edges | -3.167451 .1101029 -28.77 0.000 -3.383249 -2.951653 mutual | .8028 .1607891 4.99 0.000 .4876591 1.117941 nodematch_prac | .6901202 .0781094 8.84 0.000 .5370286 .8432119 nodeicov_seniority | -.0043719 .0016676 -2.62 0.009 -.0076403 -.0011035 gwesp_1 | .3242339 .0380017 8.53 0.000 .2497519 .3987159 ------------------------------------------------------------------------------------ MCMLE converged after 5 iteration(s). Evaluating log-likelihood at the estimate (bridge sampling with 16 bridges) ... Null Deviance: 6889.9 on 4970 degrees of freedom Residual Deviance: 3332.2 on 4965 degrees of freedom Log-likelihood: -1666.0944 (df = 5) AIC: 3342.2 BIC: 3374.7 (MC std. err. = .11364) . nwergm lazega_fr, edges mutual nodematch(prac) nodeicov(seniority) gwesp(0.5) gwidegree(0.5) seed(1) Exponential-family random graph model Network: = lazega_fr Nodes: = 71 Ties: = 575 Directed: = Yes Estimation: = MCMLE MCMC sample size: = 430 ------------------------------------------------------------------------------------ lazega_fr | Coefficient Std. err. z P>|z| [95% conf. interval] -------------------+---------------------------------------------------------------- edges | -3.360077 .1502866 -22.36 0.000 -3.654633 -3.06552 mutual | .8002415 .1747992 4.58 0.000 .4576415 1.142842 nodematch_prac | .7077244 .080161 8.83 0.000 .5506118 .864837 nodeicov_seniority | -.0046583 .0018977 -2.45 0.014 -.0083778 -.0009389 gwesp_0.5 | .5075481 .0700989 7.24 0.000 .3701568 .6449395 gwidegree_0.5 | 1.78157 2.037619 0.87 0.382 -2.212089 5.77523 ------------------------------------------------------------------------------------ MCMLE converged after 6 iteration(s). Evaluating log-likelihood at the estimate (bridge sampling with 16 bridges) ... Null Deviance: 6889.9 on 4970 degrees of freedom Residual Deviance: 3331.4 on 4964 degrees of freedom Log-likelihood: -1665.6798 (df = 6) AIC: 3343.4 BIC: 3382.4 (MC std. err. = .12044) .