Functions to play games on networks

play_diffusion(
  object,
  seeds = 1,
  thresholds = 1,
  transmissibility = 1,
  latency = 0,
  recovery = 0,
  waning = 0,
  immune = NULL,
  steps
)

play_diffusions(
  object,
  seeds = 1,
  thresholds = 1,
  transmissibility = 1,
  latency = 0,
  recovery = 0,
  waning = 0,
  immune = NULL,
  steps,
  times = 5,
  strategy = "sequential",
  verbose = FALSE
)

play_learning(object, beliefs, steps, epsilon = 5e-04)

Arguments

object

An object of a migraph-consistent class:

  • matrix (adjacency or incidence) from {base} R

  • edgelist, a data frame from {base} R or tibble from {tibble}

  • igraph, from the {igraph} package

  • network, from the {network} package

  • tbl_graph, from the {tidygraph} package

seeds

A valid mark vector the length of the number of nodes in the network.

thresholds

A numeric vector indicating the thresholds each node has. By default 1. A single number means a generic threshold; for thresholds that vary among the population please use a vector the length of the number of nodes in the network. If 1 or larger, the threshold is interpreted as a simple count of the number of contacts/exposures sufficient for infection. If less than 1, the threshold is interpreted as complex, where the threshold concerns the proportion of contacts.

transmissibility

A proportion indicating the transmission rate, \(\beta\). By default 1, which means any node for which the threshold is met or exceeded will become infected. Anything lower means a correspondingly lower probability of adoption, even when the threshold is met or exceeded.

latency

A proportion indicating the rate at which those exposed become infectious (infected), \(\sigma\). For example, if exposed individuals take, on average, four days to become infectious, then \(\sigma = 0.25\). By default 0, which means those exposed become immediately infectious (i.e. an SI model). Anything higher results in e.g. a SEI model.

recovery

A proportion indicating the rate of recovery, \(\gamma\). For example, if infected individuals take, on average, four days to recover, then \(\gamma = 0.25\). By default 0, which means there is no recovery (i.e. an SI model). Anything higher results in an SIR model.

waning

A proportion indicating the rate at which those who are recovered become susceptible again, \(\xi\). For example, if recovered individuals take, on average, four days to lose their immunity, then \(\xi = 0.25\). By default 0, which means any recovered individuals retain lifelong immunity (i.e. an SIR model). Anything higher results in e.g. a SIRS model. \(\xi = 1\) would mean there is no period of immunity, e.g. an SIS model.

immune

A logical or numeric vector identifying nodes that begin the diffusion process as already recovered. This could be interpreted as those who are vaccinated or equivalent. Note however that a waning parameter will affect these nodes too. By default NULL, indicating that no nodes begin immune.

steps

The number of steps forward in the diffusion to play. By default the number of nodes in the network. If steps = Inf then the diffusion process will continue until there are no new infections or all nodes are infected.

times

Integer indicating number of simulations used for quantile estimation. (Relevant to the null hypothesis test only - the analysis itself is unaffected by this parameter.) Note that, as for all Monte Carlo procedures, convergence is slower for more extreme quantiles. By default, times=1000. 1,000 - 10,000 repetitions recommended for publication-ready results.

strategy

If {furrr} is installed, then multiple cores can be used to accelerate the function. By default "sequential", but if multiple cores available, then "multisession" or "multicore" may be useful. Generally this is useful only when times > 1000. See {furrr} for more.

verbose

Whether the function should report on its progress. By default FALSE. See {progressr} for more.

beliefs

A vector indicating the probabilities nodes put on some outcome being 'true'.

epsilon

The maximum difference in beliefs accepted for convergence to a consensus.

Functions

  • play_diffusion(): Playing compartmental diffusion on networks.

  • play_diffusions(): Playing multiple compartmental diffusions on networks.

  • play_learning(): Playing DeGroot learning on networks.

See also

Other models: regression, tests

Examples

plot(play_diffusion(generate_smallworld(15, 0.025)))

plot(play_diffusion(generate_smallworld(15, 0.025), thresholds = 0.4))

plot(play_diffusion(generate_smallworld(15, 0.025), recovery = 0.4))

plot(play_diffusions(generate_smallworld(15, 0.025), times = 20))
#> Warning: Removed 24 rows containing missing values (`geom_smooth()`).
#> Warning: Removed 48 rows containing missing values (`geom_smooth()`).

play_learning(ison_networkers, 
      rbinom(network_nodes(ison_networkers),1,prob = 0.25))
#> # A tibble: 9 × 32
#>   `LIN FREEMAN` DOUG W…¹ EV RO…² RICHA…³ PHIPP…⁴ CAROL…⁵ GARY …⁶ RUSS …⁷ JOHN …⁸
#>           <dbl>    <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#> 1         1        0       0       0       1       0       1       0       0    
#> 2         0.273    0.634   0.286   0.299   0.452   0.531   1       0.357   0.447
#> 3         0.469    0.382   0.432   0.383   0.418   0.401   0.299   0.392   0.446
#> 4         0.393    0.426   0.411   0.405   0.402   0.420   0.465   0.404   0.413
#> 5         0.416    0.406   0.408   0.409   0.412   0.407   0.393   0.412   0.413
#> 6         0.408    0.411   0.411   0.409   0.408   0.411   0.416   0.408   0.409
#> 7         0.410    0.409   0.409   0.410   0.410   0.409   0.408   0.410   0.410
#> 8         0.409    0.410   0.410   0.410   0.410   0.410   0.410   0.409   0.410
#> 9         0.410    0.410   0.410   0.410   0.410   0.410   0.409   0.410   0.410
#> # … with 23 more variables: `RON BURT` <dbl>, `PAT DOREIAN` <dbl>,
#> #   `CLAUDE FISCHER` <dbl>, `BRIAN FOSTER` <dbl>, `MARK GRANOVETTER` <dbl>,
#> #   `MAUREEN HALLINAN` <dbl>, `PAUL HOLLAND` <dbl>, `JACK HUNTER` <dbl>,
#> #   `DAVOR JEDLICKA` <dbl>, `CHARLES KADUSHIN` <dbl>, `ED LAUMANN` <dbl>,
#> #   `SAM LEINHARDT` <dbl>, `JOEL LEVINE` <dbl>, `NAN LIN` <dbl>,
#> #   `NICK MULLINS` <dbl>, `DON PLOCH` <dbl>, `NICK POUSHINSKY` <dbl>,
#> #   `STEVE SEIDMAN` <dbl>, `JOHN SONQUIST` <dbl>, `BARRY WELLMAN` <dbl>, …