Learn R Programming

TDLM (version 1.0.0)

run_law: Estimate mobility flows based on different trip distribution laws

Description

This function estimates mobility flows using different distribution laws. As described in Lenormand2016;textualTDLM, we propose a two-step approach to generate mobility flows by separating the trip distribution law, gravity or intervening opportunities, from the modeling approach used to generate the flows from this law. This function only uses the first step to generate a probability distribution based on the different laws.

Usage

run_law(
  law = "Unif",
  mass_origin,
  mass_destination = mass_origin,
  distance = NULL,
  opportunity = NULL,
  param = NULL,
  check_names = FALSE
)

Value

An object of class TDLM. A list of list of matrices containing for each parameter value the matrix of probabilities (called proba). If length(param) = 1 or law = "Rad" or law = "Unif only a list of matrices will be returned.

Arguments

law

a character indicating which law to use (see Details).

mass_origin

a numeric vector representing the mass at origin (i.e. demand).

mass_destination

a numeric vector representing the mass at destination (i.e. attractiveness).

distance

a squared matrix representing the distance between locations (see Details).

opportunity

a squared matrix representing the number of opportunities between locations (see Details). Can be easily computed with extract_opportunities().

param

a vector of numeric value(s) used to adjust the importance of distance or opportunity associated with the chosen law. A single value or a vector of several parameter values can be used (see Return). Not necessary for the original radiation law or the uniform law (see Details).

check_names

a boolean indicating if the ID location are used as vector names, matrix rownames and colnames and if they should be checked (see Note).

Author

Maxime Lenormand (maxime.lenormand@inrae.fr)

Details

We compute the matrix proba estimating the probability p_ijp_ij to observe a trip from location ii to another location jj (_i_j p_ij=1_i_j p_ij=1). This probability is based on the demand m_im_i (argument mass_origin) and the attractiveness m_jm_j (argument mass_destination). Note that the population is typically used as a surrogate for both quantities (this is why mass_destination = mass_origin by default). It also depends on the distance d_ijd_ij between locations (argument distance) OR the number of opportunities s_ijs_ij between locations (argument opportunity) depending on the chosen law. Both the effect of the distance and the number of opportunities can be adjusted with a parameter (argument param) except for the original radiation law or the uniform law.

In this package we consider eight probabilistic laws described in details in Lenormand2016;textualTDLM. Four gravity laws Carey1858,Zipf1946,Barthelemy2011,Lenormand2016TDLM, three intervening opportunity laws Schneider1959,Simini2012,Yang2014TDLM and a uniform law.

  1. Gravity law with an exponential distance decay function (law = "GravExp"). The arguments mass_origin, mass_destination (optional), distance and param will be used.

  2. Normalized gravity law with an exponential distance decay function (law = "NGravExp"). The arguments mass_origin, mass_destination (optional), distance and param will be used.

  3. Gravity law with a power distance decay function (law = "GravPow"). The arguments mass_origin, mass_destination (optional), distance and param will be used.

  4. Normalized gravity law with a power distance decay function (law = "NGravPow"). The arguments mass_origin, mass_destination (optional), distance and param will be used.

  5. Schneider's intervening opportunities law (law = "Schneider"). The arguments mass_origin, mass_destination (optional), opportunity and param will be used.

  6. Radiation law (law = "Rad"). The arguments mass_origin, mass_destination (optional) and opportunity will be used.

  7. Extended radiation law (law = "RadExt"). The arguments mass_origin, mass_destination (optional), opportunity and param will be used.

  8. Uniform law (law = "Unif"). The argument mass_origin will be used to extract the number of locations.

References

Lenormand2016TDLM

Carey1858TDLM

Zipf1946TDLM

Barthelemy2011TDLM

Schneider1959TDLM

Simini2012TDLM

Yang2014TDLM

See Also

gof() run_law_model() run_model() extract_opportunities() check_format_names()

Examples

Run this code
data(mass)
data(distance)

mi <- as.numeric(mass[, 1])
mj <- mi

res <- run_law(
  law = "GravExp", mass_origin = mi, mass_destination = mj,
  distance = distance, opportunity = NULL, param = 0.01,
  check_names = FALSE
)

# print(res)

Run the code above in your browser using DataLab