Learn R Programming

rsMove (version 0.2.4)

predictResources: predictResources

Description

Spatially stratified predictive modeling of resource suitability based on presence/absence samples.

Usage

predictResources(x, y, z, env.data = NULL)

Arguments

x

Object of class data.frame with environmental variables for presence samples.

y

Object of class data.frame with environmental variables for background samples.

z

Numeric or character vector with sample region labels. If missing, "x" is assumed as one region.

env.data

Object of class RasterStack or RasterBrick with environmental variables in x and y.

Value

A list.

Details

Modeling of resource suitability using animal movement data following a recent paper (Remelgado et al, 2017). For each unique label in z, the function keeps it for validation and uses the remaining samples for training. Then, the function evaluates the performance of this model reporting (internally) on the number of true positives, false positives and the number of validation and predicted cases for both presences and absences. Once all sample regions are used for validation, the reported values are summed and used to derive the F1-measure. The F1-measure is estimated as 2 * (P * R) / (P + R) where P is the Precision (ratio of true positives within the number of predicted values) and R is the Recall (ratio of true positives within the number of validation samples). As a consequence, rather than reporting on an average performance, the final performance assessment reported by predictResources depicts an objective picture on how the model performed among the different sets sample regions. This metric is provided for presences (x) and absences (y) separately offering an overview on the stability of the model. This analysis is performed using a Random Forest model as provided within the train function of the caret package. The final predictive model is then derived with all samples. The output of predictResources is a list object consisting of:

  • f1 - data.frame with final F1-measure for presences and absences.

  • validation - data.frame with region identifiers and validation sample count at each iteration.

  • iteration.models - List of models estimated at each iteration.

  • final.model - Final predictive model based on all samples.

  • probabilities - Predicted probability image. Given if env.data is set.

References

Remelgado, R., Leutner, B., Safi, K., Sonnenschein, R., Kuebert, C. and Wegmann, M. (2017), Linking animal movement and remote sensing - mapping resource suitability from a remote sensing perspective. Remote Sens Ecol Conserv.

See Also

sampleMove labelSample backSample train

Examples

Run this code
# NOT RUN {
 require(rgdal)
 require(raster)
 require(sp)

 # read remote sensing data
 file <- list.files(system.file('extdata', '', package="rsMove"), 'ndvi.tif', full.names=TRUE)
 r.stk <- stack(file)

 # read movement data
 data(shortMove)

 # observation time
 obs.time <- strptime(paste0(shortMove@data$date, ' ', shortMove@data$time),
 format="%Y/%m/%d %H:%M:%S")

 # remove redundant samples
 shortMove <- moveReduce(shortMove, obs.time, r.stk)$points

 # retrieve remote sensing data for samples
 rsQuery <- extract(r.stk, shortMove)

 # identify unique sample regions
 label <- labelSample(shortMove, r.stk, agg.radius=30)

 # select background samples
 bSamples <- backSample(shortMove, r.stk, label, sampling.method='pca')

 # derive model predictions
 out <- predictResources(rsQuery, bSamples@data, label, env.data=r.stk)

# }

Run the code above in your browser using DataLab