This function fits gravity model parameters to a supplied movement matrix using Bayesian MCMC inference. The function defines the model and serves as a wrapper for the fit_jags
function.
fit_gravity( M, D, N = NULL, N_orig = NULL, N_dest = NULL, n_chain = 2, n_burn = 1000, n_samp = 1000, n_thin = 1, prior = NULL, DIC = FALSE, parallel = FALSE )
M | named matrix of trip counts among all \(ij\) location pairs |
---|---|
D | named matrix of distances among 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 |
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 |
prior | a list object containing shape and rate parameters to be used as priors |
DIC | logical indicating whether or not to calculate the Deviance Information Criterion (DIC) (default = |
parallel | logical indicating whether or not to run MCMC chains in parallel or sequentially (default = |
a runjags model object containing fitted gravity model paramters
Other model:
check_mobility()
,
fit_jags()
,
fit_mobility()
,
fit_prob_travel()
,
summarize_mobility()
Other gravity:
sim_gravity()
M <- mobility_matrices$M D <- mobility_matrices$D N <- mobility_matrices$N mod <- fit_gravity(M, D, N)#>#>#> Compiling model graph #> Resolving undeclared variables #> Allocating nodes #> Graph information: #> Observed stochastic nodes: 74 #> Unobserved stochastic nodes: 30 #> Total graph size: 1196 #> #> Initializing model #> #> NOTE: Stopping adaptation #> #>