Skip to contents

This vignette demonstrates how to track network statistics of interest across simulations using EpiModelMpox.

We fit a layered network of size 100,000 (representing main, casual, and instantaneous partnerships among men and women). Here, we run network diagnostics using the EpiModel package to demonstrate the fit of networks to the target statistics (drawn from behavioral parameters estimated from the National Survey of Family Growth). For main and casual networks we use dynamic diagnostics, and for the one-time network we use a static diagnostic.

library(EpiModel)
data("nw_100000", package = "EpiModelSTI")
data("mixmats", package = "EpiModelSTI")

main_mixmat_race <- mixmats[[1]]
main_mixmat_ag <- mixmats[[2]]
cas_mixmat_race <- mixmats[[3]]
cas_mixmat_ag <- mixmats[[4]]

Main Network (Marriages & Cohabitations)

main_dynamic <- netdx(
  nw_100000[[1]],
  dynamic = TRUE, nsims = 10, nsteps = 500, ncores = 2
)

Network Diagnostics
-----------------------
- Simulating 10 networks
- Calculating formation statistics
main_dynamic
EpiModel Network Diagnostics
=======================
Diagnostic Method: Dynamic
Simulations: 10
Time Steps per Sim: 500

Formation Diagnostics
-----------------------
                                       Target     Sim Mean Pct Diff    Sim SE
edges                               27473.090    27389.956   -0.303    13.933
nodematch.race.B                     2169.121     2105.852   -2.917     3.246
nodematch.race.H                     4089.055     4147.292    1.424     5.059
nodematch.race.W                    14397.240    14318.004   -0.550     7.193
nodefactor.race.B                    5516.648     5538.930    0.404    10.555
nodefactor.race.H                   10354.139    10267.183   -0.840     8.984
nodefactor.race.W                   33094.490    33095.073    0.002    23.850
nodecov.age                       1967244.828  1959133.841   -0.412   770.509
nodecov.agesq                    74129346.357 73732355.734   -0.536 23556.868
absdiff.sqrt(age_adj)                7076.843     6956.135   -1.706     4.517
nodefactor.deg_casual>0.TRUE          317.420      301.644   -4.970     2.075
offset(nodefactor.floor(age).15)           NA        0.000       NA       NaN
offset(nodefactor.floor(age).16)           NA        0.000       NA       NaN
                                 Z Score SD(Sim Means) SD(Statistic)
edges                             -5.967        51.106        72.694
nodematch.race.B                 -19.491        10.264        16.574
nodematch.race.H                  11.511        17.453        26.869
nodematch.race.W                 -11.016        36.828        44.730
nodefactor.race.B                  2.111        14.739        49.065
nodefactor.race.H                 -9.679        43.602        50.958
nodefactor.race.W                  0.024        71.419       113.036
nodecov.age                      -10.527      3071.695      4566.189
nodecov.agesq                    -16.852    110053.968    158105.474
absdiff.sqrt(age_adj)            -26.720        26.209        28.131
nodefactor.deg_casual>0.TRUE      -7.602        11.708        11.940
offset(nodefactor.floor(age).15)      NA         0.000         0.000
offset(nodefactor.floor(age).16)      NA         0.000         0.000

Duration Diagnostics
-----------------------
        Target Sim Mean Pct Diff Sim SE Z Score SD(Sim Means) SD(Statistic)
edges 2835.426  2831.86   -0.126  2.285  -1.561        12.126         13.06

Dissolution Diagnostics
-----------------------
      Target Sim Mean Pct Diff Sim SE Z Score SD(Sim Means) SD(Statistic)
edges      0        0   -0.196      0  -0.441             0             0

Casual Network

casual_dynamic <- netdx(
  nw_100000[[2]],
  dynamic = TRUE, nsims = 10, nsteps = 500, ncores = 2
)

Network Diagnostics
-----------------------
- Simulating 10 networks
- Calculating formation statistics
casual_dynamic
EpiModel Network Diagnostics
=======================
Diagnostic Method: Dynamic
Simulations: 10
Time Steps per Sim: 500

Formation Diagnostics
-----------------------
                         Target Sim Mean Pct Diff Sim SE Z Score SD(Sim Means)
edges                  8102.937 7778.366   -4.006 22.476 -14.441        41.935
nodefactor.age_group.1 3677.577 3610.092   -1.835  8.406  -8.028        38.743
nodefactor.age_group.2 3366.224 3223.147   -4.250 10.485 -13.646        32.991
nodefactor.age_group.3 2708.317 2547.147   -5.951 13.001 -12.397        39.646
nodefactor.age_group.4 1788.003 1660.740   -7.118  5.424 -23.464        14.127
nodefactor.age_group.5 1751.400 1655.908   -5.452  8.472 -11.272        26.869
nodefactor.age_group.6 1533.364 1457.137   -4.971  5.954 -12.803        15.846
nodefactor.race.B      2431.117 2377.285   -2.214  9.070  -5.935        35.853
nodefactor.race.H      2836.619 2701.456   -4.765 10.055 -13.442        20.880
nodefactor.race.W      8680.129 8404.846   -3.171 18.575 -14.820        42.132
nodematch.race.B        841.279  849.468    0.973  3.020   2.711        13.630
nodematch.race.O        380.772  344.914   -9.417  2.371 -15.126        12.682
nodematch.race.W       3446.499 3402.777   -1.269  5.469  -7.995        18.687
concurrent              607.770  585.561   -3.654  2.892  -7.679        15.190
nodefactor.deg_main.1   317.420  324.550    2.246  2.209   3.228        12.063
                       SD(Statistic)
edges                        125.114
nodefactor.age_group.1        59.293
nodefactor.age_group.2        65.333
nodefactor.age_group.3        71.954
nodefactor.age_group.4        34.029
nodefactor.age_group.5        51.390
nodefactor.age_group.6        37.567
nodefactor.race.B             58.583
nodefactor.race.H             59.716
nodefactor.race.W            121.807
nodematch.race.B              22.039
nodematch.race.O              17.788
nodematch.race.W              42.012
concurrent                    22.250
nodefactor.deg_main.1         15.862

Duration Diagnostics
-----------------------
       Target Sim Mean Pct Diff Sim SE Z Score SD(Sim Means) SD(Statistic)
edges 217.236   222.25    2.308  0.382  13.127         0.906         2.302

Dissolution Diagnostics
-----------------------
      Target Sim Mean Pct Diff Sim SE Z Score SD(Sim Means) SD(Statistic)
edges  0.005    0.005   -0.115      0   -0.51             0         0.001

One-Time Network

inst_dynamic <- netdx(nw_100000[[3]], dynamic = FALSE, nsims = 1000)

Network Diagnostics
-----------------------
- Simulating 1000 networks

- Calculating formation statistics
inst_dynamic
EpiModel Network Diagnostics
=======================
Diagnostic Method: Static
Simulations: 1000

Formation Diagnostics
-----------------------
                       Target Sim Mean Pct Diff Sim SE Z Score SD(Sim Means)
edges                  14.853   15.388    3.599  0.123   4.343            NA
nodefactor.race.B       5.799    6.079    4.834  0.094   2.968            NA
nodefactor.race.H       4.649    4.716    1.447  0.077   0.878            NA
nodefactor.race.W      17.501   18.052    3.151  0.171   3.229            NA
nodefactor.age_group.1  5.945    6.019    1.241  0.108   0.681            NA
nodefactor.age_group.2  6.766    6.845    1.170  0.108   0.732            NA
nodefactor.age_group.3  5.821    6.110    4.961  0.098   2.951            NA
absdiff.sqrt(age_adj)   2.489    2.619    5.197  0.030   4.369            NA
                       SD(Statistic)
edges                          3.892
nodefactor.race.B              2.636
nodefactor.race.H              2.250
nodefactor.race.W              5.401
nodefactor.age_group.1         3.159
nodefactor.age_group.2         3.144
nodefactor.age_group.3         3.094
absdiff.sqrt(age_adj)          0.937