predict.movement_model | R Documentation |
movement_model
:
Use a trained movement_model
object to predict population movements
given either a RasterLayer containing a single population layer, or a
location_dataframe
object containing population and location data
with the columns location
(character), population
(numeric),
x
(numeric) and y
(numeric).
## S3 method for class 'movement_model'
predict(object, new_data, go_parallel = FALSE,
number_of_cores = NULL, ...)
object |
A configured prediction model of class |
new_data |
An optional |
go_parallel |
Flag to enable parallel calculations (if set to TRUE). Note that parallel programming will only improve the performance with larger datasets; for smaller datasets the performance will get worse due to the overhead of scheduling the tasks. |
number_of_cores |
Optional parameter to specify the number of cores used for parallel calculations. If no value is specified, the program will automatically detect the number of cores available on the machine when parallel programming is enabled. |
... |
Extra arguments to pass to the flux function |
A movement_predictions
object containing a list with the location
dataframe from the input, the matrix containing the predicted population movements
and the data set of the population.
## Not run:
# get location data
data(kenya)
kenya10 <- raster::aggregate(kenya, 10, sum)
net <- getNetwork(kenya10, min = 50000)
location_data <- data.frame(location = net$locations,
population = net$population,
x = net$coordinate[,1],
y = net$coordinate[,2])
location_data <- as.location_dataframe(location_data)
# simulate movements (note the values of movementmatrix must be integer)
predicted_flux <- predict(originalRadiation(theta = 0.1), location_data, symmetric = TRUE)
movement_matrix <- round(predicted_flux$movement_matrix)
# fit a new model to these data
movement_model <- movement(movement_matrix ~ location_data, originalRadiation(theta = 0.1))
# predict the population movements
predicted_movements <- predict(movement_model, kenya10)
# display the predicted movements
plot(predicted_movements)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.