buffering: Use distance (buffer) around records to separate train and...

Description Usage Arguments Details Value See Also Examples

Description

This function generates spatially separated train and test folds by considering buffers of specified distance around each observation point. This approach is a form of leave-one-out cross-validation. Each fold is generated by excluding nearby observations around each testing point within the specified distance (ideally the range of spatial autocorrelation, see spatialAutoRange). In this method the test set never directly abuts a training presence or absence. For more information see the details section.

Usage

1
2
buffering(speciesData, species = NULL, theRange, spDataType = "PA",
  addBG = TRUE, progress = TRUE)

Arguments

speciesData

A SpatialPointsDataFrame, SpatialPoints or sf object containing species data.

species

Character. Indicating the name of the field in which species presence/absence data (0s and 1s) are stored. If speceis = NULL the presence and absence data will be treated the same and only training and testing records will be counted.

theRange

Numeric value of the specified range by which the training and testing datasets are separated (See spatialAutoRange). This distance should be in metres. The range can be explored by spatialAutoRange.

spDataType

Character input indicating the type of data. It can take two values, PA for presence-absence data and PB for presence-background data, when species is not NULL. See the details section for more information on these two approaches.

addBG

Logical. Add background points to the test set when spDataType = "PB".

progress

Logical. If TRUE a progress bar will be shown.

Details

When working with presence-background (presence and pseudo-absence) data (specified by spDataType argument), only presence records are used for specifying the folds. Consider a target presence point. The buffer is defined around this target point, using the specified range (theRange). The testing fold comprises the target presence point and all background points within the buffer (this is the default. If addBG = FALSE the bacground points are ignored). Any non-target presence points inside the buffer are excluded. All points (presence and background) outside of buffer are used for training set. The methods cycles through all the presence data, so the number of folds is equal to the number of presence points in the dataset.

For presence-absence data, folds are created based on all records, both presences and absences. As above, a target observation (presence or absence) forms a test point, all presence and absence points other than the target point within the buffer are ignored, and the training set comprises all presences and absences outside the buffer. Apart from the folds, the number of training-presence, training-absence, testing-presence and testing-absence records is stored and returned in the records table. If species = NULL (no column with 0s and 1s are defined), the procedure is like presence-absence data.

Value

An object of class S3. A list of objects including:

See Also

spatialAutoRange for selecting buffer distance; spatialBlock and envBlock for alternative blocking strategies; foldExplorer for visualisation of the generated folds.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Not run: 

# import presence-absence species data
PA <- read.csv(system.file("extdata", "PA.csv", package = "blockCV"))
# coordinate reference system
Zone55s <- "+proj=utm +zone=55 +south +ellps=GRS80 +units=m +no_defs"
# make a SpatialPointsDataFrame object from data.frame
pa_data <- sp::SpatialPointsDataFrame(PA[,c("x", "y")], PA, proj4string=CRS(Zone55s))

# buffering with presence-absence data
bf1 <- buffering(speciesData= pa_data,
                 species= "Species", # to count the number of presences and absences
                 theRange= 68000,
                 spDataType = "PA",
                 progress = T)


# import presence-background species data
PB <- read.csv(system.file("extdata", "PB.csv", package = "blockCV"))
# make a SpatialPointsDataFrame object from data.frame
pb_data <- sp::SpatialPointsDataFrame(PB[,c("x", "y")], PB, proj4string=CRS(Zone55s))

# buffering with presence-background data
bf2 <- buffering(speciesData= pb_data,
                 species= "Species",
                 theRange= 68000,
                 spDataType = "PB",
                 addBG = TRUE, # add background data to testing folds
                 progress = T)

# buffering with no species attribute
bf3 <- buffering(speciesData= pa_data,
                 theRange= 63300)


## End(Not run)

adamlilith/blockCV documentation built on May 25, 2019, 12:41 a.m.