sim.gravity: Simulate connectivity values using gravity model

Description Usage Arguments Value Author(s) See Also Examples

View source: R/hmob_funcs.R

Description

This function uses the gravity model formula to simulate a connectivity matrix based on the supplied model parameters. The gravity model formula uses a Gamma distribution as the dispersal kernel in the denominator. A null model (where all model parameters = 1) can be simulated by supplying only population sizes (N) and pairwise distances (D).

θ * ( N_i^ω_1 N_j^ω_2 / f(d_ij) )

Usage

1
2
3
4
5
6
7
8
9
sim.gravity(
  N,
  D,
  theta = 1,
  omega.1 = 1,
  omega.2 = 1,
  gamma = 1,
  counts = FALSE
)

Arguments

N

vector of population sizes

D

matrix of distances among all ij pairs

theta

scalar giving the proportionality constant of gravity formula (default = 1)

omega.1

scalar giving exponential scaling of origin population size (default = 1)

omega.2

scalar giving exponential scaling of destination population size (default = 1)

gamma

scalar giving the dispersal kernel paramater (default = 1)

counts

logical indicating whether or not to return a count variable by scaling the connectivity matrix by origin population size (N_i) (default = FALSE)

Value

a matrix with values between 0 and 1 (if counts = FALSE) or positive integers (if counts = TRUE)

Author(s)

John Giles

See Also

Other simulation: calc.hpd(), calc.prop.inf(), calc.prop.remain(), calc.timing.magnitude(), calc.wait.time(), decay.func(), get.age.beta(), get.beta.params(), sim.TSIR.full(), sim.TSIR(), sim.combine.dual(), sim.combine(), sim.gravity.duration(), sim.lambda(), sim.pi(), sim.rho(), sim.tau()

Other gravity: fit.gravity(), fit.prob.travel(), sim.gravity.duration()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
n <- 10
ids <- LETTERS[1:n]

# Distance matrix
D <- get.distance.matrix(x=rnorm(n, 100, 5), 
                         y=rnorm(n, 20, 2),
                         id=ids)

# Vector of population sizes
N <- rpois(n, 1000)
names(N) <- ids

# Simulate null model connectivity matrix
pi.hat <- sim.gravity(N=N, D=D)

# Simulate connectivity matrix given fitted gravity model parameters
pi.hat <- sim.gravity(N=N,
                      D=D,
                      theta=14,
                      omega.1=13,
                      omega.2=0.7,
                      gamma=1.5)

# Simulate trip counts based on fitted model parameters
M.hat <- sim.gravity(N=N,
                     D=D,
                     theta=14,
                     omega.1=13,
                     omega.2=0.7,
                     gamma=1.5,
                     counts=TRUE)

gilesjohnr/hmob documentation built on Aug. 8, 2020, 1:26 a.m.