mobility: Fit mobility model to data

Description Usage Arguments Value Author(s) See Also Examples

View source: R/models.R

Description

This function fits a variety of mobility models to a supplied movement matrix (M) and covariates (D and N) using Bayesian MCMC inference. The function specifies the type of mobility model and serves as a wrapper for the fit_jags function.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
mobility(
  data,
  model,
  type,
  hierarchical = FALSE,
  n_chain = 2,
  n_burn = 1000,
  n_samp = 1000,
  n_thin = 1,
  DIC = FALSE,
  parallel = FALSE
)

Arguments

data

a list containing mobility data and covariates. The list object must include EITHER M, D, and N OR M, D, N_orig, and N_dest. Details about each item are as follows:

M

named matrix of trip counts between all ij location pairs

D

named matrix of distances between all ij location pairs

N

named vector of population sizes for all locations (either N or both N_orig and N_dest must be supplied)

N_orig

named vector of population sizes for each origin

N_dest

named vector of population sizes for each destination

model

character vector indicating which mobility model to fit to the data. Mobility models include: 'gravity', 'radiation', and 'departure-diffusion'.

type

character vector indicating the particular sub-type of mobility model to fit.

Gravity model types include:

basic, transport, power, exp, power_norm, exp_norm, and Marshall

Radiation model types include:

basic and finite

Departure-diffusion model types include:

power, exp, and radiation

See model list vignette for more detailed description of each model type.

hierarchical

Applies only to the 'departure-diffusion' model. A logical argument indicating whether or not to fit τ as a single parameter or hierarchically (as τ_{pop} and τ_i).

n_chain

number of MCMC sampling chains

n_burn

number of iterations to discard before sampling of chains begins (burn in)

n_samp

number of iterations to sample each chain

n_thin

interval to thin samples

DIC

logical indicating whether or not to calculate the Deviance Information Criterion (DIC) (default = FALSE)

parallel

logical indicating whether or not to run MCMC chains in parallel or sequentially (default = FALSE)

Value

An object of class mobility.model containing model information, data, and fitted model parameters

Author(s)

John Giles

See Also

Other model: check(), compare(), fit_jags(), fit_prob_travel(), predict(), residuals(), summary()

Examples

1
2
3
4
5
mod <- mobility(data=mobility_matrices, model='gravity', type='transport')

mod <- mobility(data=mobility_matrices, model='radiation', type='finite')

mod <- mobility(data=mobility_matrices, model='departure-diffusion', type='power')

COVID-19-Mobility-Data-Network/mobility documentation built on Nov. 22, 2021, 12:17 a.m.