Skip to contents

The function computes for each spatial interaction model of its sim_list parameter the diversity() of the corresponding destination flows and returns the values as a vector. The type of diversity and the associated parameters are identical for all models.

Usage

grid_diversity(
  sim,
  definition = c("shannon", "renyi", "ND", "RW"),
  order = 1L,
  ...
)

Arguments

sim

a collection of spatial interaction models, an object of class sim_list

definition

diversity definition "shannon" (default), "renyi" (see details) or a definition supported by terminals()

order

order of the Rényi entropy, used only when definition="renyi"

...

additional parameters

Value

a vector of diversities, one per spatial interaction model

Details

See diversity() for the definition of the diversities. Notice that diversity() is generic and can be applied directly to sim_list objects. The current function is provided to be explicit in R code about what is a unique model and what is a collection of models (using function names that start with "grid_")

See also

Examples

positions <- matrix(rnorm(15 * 2), ncol = 2)
distances <- as.matrix(dist(positions))
production <- rep(1, 15)
attractiveness <- rep(1, 15)
all_flows <- grid_blvim(distances,
  production,
  c(1.1, 1.25, 1.5),
  c(1, 2, 3),
  attractiveness,
  bipartite = FALSE,
  epsilon = 0.1
)
diversities <- grid_diversity(all_flows)
diversities ## should be a length 9 vector
#> [1] 1.907339 1.000000 1.000000 3.827119 2.996306 2.995303 9.304470 5.319047
#> [9] 3.884801
grid_diversity(all_flows, "renyi", 3)
#> [1] 1.767699 1.000000 1.000000 3.350572 2.988988 2.986056 5.401126 4.029167
#> [9] 3.404350