predict: Prediction and simulation method for 'mobility.model' class

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/predict.R

Description

This function uses a fitted mobility.model object to simulate a connectivity matrix based on estimated parameters.

Usage

1
predict(object, newdata, nsim, seed, ...)

Arguments

object

a mobility.model object containing a fitted mobility model and its associated data

newdata

a list containing new data to used in model prediction. If NULL (the default) the function will simulate the model with the data used for fitting.

D

a named matrix of distances between all ij location pairs

N

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

N_orig

a named vector of population sizes for each origin

N_dest

a named vector of population sizes for each destination

nsim

number of simulations (default = 1).

seed

optional integer specifying the call to set.seed prior to model simulation (default = NULL)

...

further arguments passed to or from other methods

Details

When nsim = 1, the prediction matrix is calculated using the mean point estimate of parameter values. If nsim > 1 then returns and array that contains nsim number of simulated replications based on the posterior distributions of each parameter.

Value

a vector, matrix, or array containing predited or simulated mobility values.

Author(s)

John Giles

See Also

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

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
mod <- mobility(data=mobility_matrices,
                model='gravity',
                type='transport')

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

predict(object=mod)

n <- 5
ids <- letters[1:n]

# Distance matrix
D <- get_distance_matrix(x=rnorm(n, -100, 2),
                         y=rnorm(n, 20, 1),
                         id=ids)*111.35

# Vector of population sizes
N <- rnbinom(n, size=5, mu=5000)
names(N) <- ids

# Predict mobility model using new data
predict(object=mod, newdata=list(D=D, N=N))

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