Learn R Programming

rsMove (version 0.1)

moveModel: moveModel

Description

Spatially stratified predictive modeling.

Usage

moveModel(pxy = pxy, axy = axy, label = NULL, method = NULL,
  control = NULL, nruns = 1)

Arguments

pxy

Object of class SpatialPoinsDataFrame with presence environmental variables.

axy

Object of class SpatialPoinsDataFrame with background environmental variables.

label

Region labels. If missing, "pxy" is assumed as one region.

method

Classification algorithm (see http://topepo.github.io/caret/index.html. Default is rf (Radom Forest).

control

Object derived by trainControl (see trainControl). Default used out-of-bag (oob) accuracies.

nruns

Number of runs. Default is 1.

Value

A list.

Details

For n iterations, where n is the number of unique sample regions, the function uses one sample region for validation while the remaining ones are used for training. The background samples are split randomly at each iteration. The final accuracy, provided as a F1-score for both presence and background sampels, is derived from the total of true and false positives ($f1). Additionaly, for each run, the function returns a model ($model) which is trained using all the samples. This output can be passed to modelApply().

See Also

sampleMove labelSample backSample modelApply train

Examples

Run this code
# NOT RUN {
 
 require(rgdal)
 require(raster)
 require(sp)
 
 # read example data
 file <- system.file('extdata', 'konstanz_20130805-20130811.shp', package="rsMove")
 moveData <- shapefile(file)

 # extract samples
 ot = as.Date(moveData@data$date)
 samples <- sampleMove(xy=moveData, ot=ot, error=10, method='m')

 # read remote sensing data
 file <- list.files(system.file('extdata', '', package="rsMove"), 'tc.*tif', full.names=TRUE)
 rsStk <- stack(file)
 
 # retrieve remote sensing data for samples
 rsQuery <- dataQuery(xy=samples,img=rsStk, rd=TRUE)
 
 # identify unique sample regions
 label <- labelSample(xy=rsQuery, rad=90, npx=1, pxr=rsStack)
 
 # select background samples
 ind <- which(label>0) # selected samples
 bSamples <- backSample(xy=moveData[ind,], rid=label[ind], img=rsStk, method='pca')
 
 # derive model predictions
 out <- moveModel(pxy=rsQuery, axy=bSamples, label=label)

# }

Run the code above in your browser using DataLab