predict.movement_model: Predict from a movement model object

View source: R/movement.R

predict.movement_modelR Documentation

Predict from a movement model object

Description

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).

Usage

## S3 method for class 'movement_model'
predict(object, new_data, go_parallel = FALSE,
  number_of_cores = NULL, ...)

Arguments

object

A configured prediction model of class movement_model

new_data

An optional location_dataframe object or RasterLayer containing population data

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

Value

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.

Examples

## 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)

SEEG-Oxford/movement documentation built on April 17, 2023, 4:17 p.m.