Learn R Programming

blvim (version 0.1.1)

quantile.sim_list: Compute quantiles of the flows in a collection of spatial interaction models

Description

The function computes the specified quantiles for individual or aggregated flows in a collection of spatial interaction models.

Usage

# S3 method for sim_list
quantile(
  x,
  flows = c("full", "destination", "attractiveness"),
  probs = seq(0, 1, 0.25),
  normalisation = c("none", "origin", "full"),
  ...
)

Value

a date frame, see details

Arguments

x

a collection of spatial interaction models, a sim_list

flows

"full" (default), "destination" or "attractiveness", see details.

probs

numeric vector of probabilities with values in \([0,1]\).

normalisation

when flows="full", the flows are used as is, that without normalisation (normalisation="none", default case) or they can be normalised prior the calculation of the quantiles, either to sum to one for each origin location (normalisation="origin") or to sum to one globally (normalisation="full"). This is useful for autoplot.sim_list().

...

additional parameters, not used currently

Details

The exact behaviour depends on the value of flows. In all cases, the function returns a data frame. The data frame has one column per quantile, named after the quantile using a percentage based named, as in the default stats::quantile(). For a graphical representation of those quantiles, see autoplot.sim_list().

  • if flows="full": this is the default case in which the function computes for each pair of origin \(o\) and destination \(d\) locations the quantiles of the distribution of the flow from \(o\) to \(d\) in the collection of models (the flows maybe normalised before quantile calculations, depending on the value of normalisation). In addition to the quantiles, the data frame has two columns:

    • origin_idx: identifies the origin location by its index from 1 to the number of origin locations;

    • destination_idx: identifies the destination location by its index from 1 to the number of destination locations.

  • if flows="destination", the function computes quantiles for each destination \(d\) location of the distribution of its incoming flow (destination_flow()) in the collection of models. In addition to the quantiles, the data frame has one column destination that identifies the destination location by its index from 1 to the number of destination locations.

  • if flows="attractiveness", the function computes quantiles for each destination \(d\) location of the distribution of its attractiveness (attractiveness()) in the collection of models. In addition to the quantiles, the data frame has one column destination that identifies the destination location by its index from 1 to the number of destination locations.

See Also

fortify.sim_list() autoplot.sim_list()

Examples

Run this code
distances <- french_cities_distances[1:10, 1:10] / 1000 ## convert to km
production <- rep(1, 10)
attractiveness <- log(french_cities$area[1:10])
all_flows <- grid_blvim(distances, production, seq(1.05, 1.45, by = 0.1),
  seq(1, 3, by = 0.5) / 400,
  attractiveness,
  bipartite = FALSE,
  epsilon = 0.1, iter_max = 1000
)
head(quantile(all_flows))
head(quantile(all_flows, flows = "destination"))
head(quantile(all_flows,
  flows = "attractiveness",
  probs = c(0.1, 0.3, 0.6, 0.9)
))

Run the code above in your browser using DataLab