These functions allow learning games to be played upon networks.

  • play_learning() plays a learning model upon a network.

  • play_segregation() plays a Schelling segregation model upon a network.

play_learning(.data, beliefs, closeness = Inf, steps, epsilon = 5e-04)

play_segregation(
  .data,
  attribute,
  heterophily = 0,
  who_moves = c("ordered", "random", "most_dissatisfied"),
  choice_function = c("satisficing", "optimising", "minimising"),
  steps
)

Arguments

.data

An object of a manynet-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

beliefs

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

closeness

A threshold at which beliefs are too different to influence each other. By default Inf, i.e. there is no threshold.

steps

The number of steps forward in learning. By default the number of nodes in the network.

epsilon

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

attribute

A string naming some nodal attribute in the network. Currently only tested for binary attributes.

heterophily

A score ranging between -1 and 1 as a threshold for how heterophilous nodes will accept their neighbours to be. A single proportion means this threshold is shared by all nodes, but it can also be a vector the same length of the nodes in the network for issuing different thresholds to different nodes. By default this is 0, meaning nodes will be dissatisfied if more than half of their neighbours differ on the given attribute.

who_moves

One of the following options: "ordered" (the default) checks each node in turn for whether they are dissatisfied and there is an available space that they can move to, "random" will check a node at random, and "most_dissatisfied" will check (one of) the most dissatisfied nodes first.

choice_function

One of the following options: "satisficing" (the default) will move the node to any coordinates that satisfy their heterophily threshold, "optimising" will move the node to coordinates that are most homophilous, and "minimising" distance will move the node to the next nearest unoccupied coordinates.

Learning models

The default is a Degroot learning model, but if closeness is defined as anything less than infinity, this becomes a Deffuant model. A Deffuant model is similar to a Degroot model, however nodes only learn from other nodes whose beliefs are not too dissimilar from their own.

References

DeGroot, Morris H. 1974. "Reaching a consensus", Journal of the American Statistical Association, 69(345): 118–21. doi:10.1080/01621459.1974.10480137

Deffuant, Guillaume, David Neau, Frederic Amblard, and Gérard Weisbuch. 2000. "Mixing beliefs among interacting agents", Advances in Complex Systems, 3(1): 87-98. doi:10.1142/S0219525900000078

Golub, Benjamin, and Matthew O. Jackson 2010. "Naive learning in social networks and the wisdom of crowds", American Economic Journal, 2(1): 112-49. doi:10.1257/mic.2.1.112

Examples

  play_learning(ison_networkers, 
      rbinom(net_nodes(ison_networkers),1,prob = 0.25))
#> # A tibble: 9 × 32
#>   `Lin Freeman` `Doug White` `Ev Rogers` `Richard Alba` `Phipps Arabie`
#>           <dbl>        <dbl>       <dbl>          <dbl>           <dbl>
#> 1         0           1            0              0               0    
#> 2         0.248       0.0642       0.357          0.221           0.103
#> 3         0.138       0.199        0.154          0.162           0.155
#> 4         0.176       0.158        0.166          0.170           0.172
#> 5         0.163       0.169        0.168          0.167           0.163
#> 6         0.167       0.165        0.165          0.166           0.167
#> 7         0.166       0.166        0.166          0.166           0.166
#> 8         0.166       0.166        0.166          0.166           0.166
#> 9         0.166       0.166        0.166          0.166           0.166
#> # ℹ 27 more variables: `Carol Barner-Barry` <dbl>, `Gary Coombs` <dbl>,
#> #   `Russ Bernard` <dbl>, `John Boyd` <dbl>, `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>, …
  startValues <- rbinom(100,1,prob = 0.5)
  startValues[sample(seq_len(100), round(100*0.2))] <- NA
  latticeEg <- create_lattice(100)
  latticeEg <- add_node_attribute(latticeEg, "startValues", startValues)
  latticeEg
#> 
#> ── # Lattice network ───────────────────────────────────────────────────────────
#> # A undirected network of 100 nodes and 342 ties
#> 
#> ── Nodes 
#> # A tibble: 100 × 1
#>   startValues
#>         <int>
#> 1           0
#> 2           1
#> 3           0
#> 4          NA
#> 5           1
#> 6           1
#> # ℹ 94 more rows
#> 
#> ── Ties 
#> # A tibble: 342 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     1    11
#> 3     1    12
#> 4     2     3
#> 5     2    11
#> 6     2    12
#> # ℹ 336 more rows
#> 
  play_segregation(latticeEg, "startValues", 0.5)
#> [1] "Moving node 1 to node 59"
#> [1] "Moving node 9 to node 53"
#> [1] "Moving node 13 to node 41"
#> [1] "Moving node 3 to node 38"
#> [1] "Moving node 21 to node 34"
#> [1] "Moving node 29 to node 1"
#> [1] "Moving node 49 to node 13"
#> [1] "Moving node 50 to node 35"
#> [1] "Moving node 64 to node 9"
#> [1] "Moving node 97 to node 45"
#> [1] "Moving node 98 to node 92"
#> ── # Lattice network ───────────────────────────────────────────────────────────
#> # A undirected network of 100 nodes and 342 ties
#> 
#> ── Nodes 
#> # A tibble: 100 × 1
#>   startValues
#>   <node_msr> 
#> 1  1         
#> 2  1         
#> 3 NA         
#> 4 NA         
#> 5  1         
#> 6  1         
#> # ℹ 94 more rows
#> 
#> ── Ties 
#> # A tibble: 342 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     1    11
#> 3     1    12
#> 4     2     3
#> 5     2    11
#> 6     2    12
#> # ℹ 336 more rows
#> 
  # graphr(latticeEg, node_color = "startValues", node_size = 5) + 
  # graphr(play_segregation(latticeEg, "startValues", 0.2), 
  #            node_color = "startValues", node_size = 5)