This function uses a fitted mobility.model
object to simulate a connectivity matrix based on estimated parameters.
predict(object, newdata, nsim, seed, ...)
object | a |
---|---|
newdata | a list containing new data to used in model prediction. If
|
nsim | number of simulations (default = 1). |
seed | optional integer specifying the call to |
... | further arguments passed to or from other methods |
a vector, matrix, or array containing predited or simulated mobility values.
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.
John Giles
#>#> Compiling model graph #> Resolving undeclared variables #> Allocating nodes #> Graph information: #> Observed stochastic nodes: 70 #> Unobserved stochastic nodes: 32 #> Total graph size: 417 #> #> Initializing model #> #> NOTE: Stopping adaptation #> #>mod <- mobility(data=mobility_matrices, model='departure-diffusion', type='power', hierarchical=TRUE)#>#> Compiling model graph #> Resolving undeclared variables #> Allocating nodes #> Graph information: #> Observed stochastic nodes: 70 #> Unobserved stochastic nodes: 46 #> Total graph size: 994 #> #> Initializing model #> #> NOTE: Stopping adaptation #> #>predict(object=mod)#> destination #> origin A B C D E F #> A 4612.33342 348.37077 125.368853 509.947769 336.41805 238.15704 #> B 31.78730 8974.50837 51.627433 13.305170 71.53423 132.24174 #> C 13.52665 61.04770 5283.612608 7.233958 49.45510 68.34040 #> D 1926.71267 550.93429 253.318307 2270.236594 636.69850 417.66652 #> E 267.36113 623.04722 364.275050 133.924965 8604.64752 1273.56705 #> F 44.56248 271.18309 118.517585 20.684467 299.85325 6408.55208 #> G 200.69147 118.50892 31.293662 41.993366 89.10860 71.80827 #> H 150.10473 113.30474 27.701293 34.133658 67.80793 59.57853 #> I 33.00185 22.61175 5.647168 7.216220 14.22255 12.26176 #> J 731.95688 434.33209 215.208769 507.052971 862.45931 415.97965 #> destination #> origin G H I J #> A 1320.30306 1307.65149 785.70147 272.417172 #> B 71.13898 90.06532 49.12078 14.749687 #> C 22.21272 26.03744 14.50610 8.641907 #> D 1043.79846 1123.49652 649.11292 713.006632 #> E 465.88992 469.45837 269.10124 255.097714 #> F 88.39448 97.11658 54.62331 28.968566 #> G 7283.78274 1262.68985 977.93772 41.552495 #> H 953.55064 4125.38938 6495.92529 29.643308 #> I 270.23193 2376.94654 2849.07131 6.354144 #> J 734.50175 693.86556 406.46893 1584.602553 #> attr(,"model") #> [1] "departure-diffusion" #> attr(,"type") #> [1] "power" #> attr(,"hierarchical") #> [1] TRUEn <- 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))#> destination #> origin a b c d e #> a 3459.71747 626.90386 1712.31675 390.48386 1204.07873 #> b 33.88195 2872.29560 45.18656 71.13985 18.00077 #> c 74.68437 36.46594 5419.47965 25.02005 141.80039 #> d 342.24054 1153.64941 502.77192 687.26941 215.73305 #> e 247.35776 68.42177 667.88622 50.56604 2159.09725 #> attr(,"model") #> [1] "departure-diffusion" #> attr(,"type") #> [1] "power" #> attr(,"hierarchical") #> [1] TRUE