Learn R Programming

rsMove (version 0.2.8)

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 being 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 the method of Remelgado et al (2017). Each unique label in z is kept for validation while the remaining samples are used 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 cases for both presences and absences. Once all sample regions are used for validation, the reported values are summed and used to derive a 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 informing 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 the function is a list object consisting of:

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

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

  • sample.validation -:Logical vector with the validation of each observation in x.

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

See Also

sampleMove labelSample backSample train

Examples

Run this code
# NOT RUN {
 require(raster)

 # 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, r.stk, obs.time)$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