predict-SDMmodelCV-method: Predict for Cross Validation

Description Usage Arguments Details Value Author(s) References Examples

Description

Predict the output for a new dataset given a trained SDMmodelCV model. The output is given as the provided function applied to the prediction of the k models.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S4 method for signature 'SDMmodelCV'
predict(
  object,
  data,
  fun = "mean",
  type = NULL,
  clamp = TRUE,
  filename = "",
  format = "GTiff",
  extent = NULL,
  ...
)

Arguments

object

SDMmodelCV object.

data

data.frame, SWD or raster stack with the data for the prediction.

fun

character. function used to combine the output of the k models, default is "mean". Note that fun is a character argument, you must use "mean" and not mean. You can also pass a vector of character containing multiple function names, see details.

type

character. Output type, see details, used only for Maxent and Maxnet methods, default is NULL.

clamp

logical for clumping during prediction, used only for Maxent and Maxnet methods, default is TRUE.

filename

character. Output file name for the prediction map, used only when data is a stack object. If provided the output is saved in a file, see details.

format

character. The output format, see writeRaster for all the options, default is "GTiff".

extent

extent object, if provided it restricts the prediction to the given extent, default is NULL.

...

Additional arguments to pass to the writeRaster function.

Details

Value

A vector with the prediction or a raster object if data is a raster stack or a list in the case of multiple functions.

Author(s)

Sergio Vignali

References

Wilson P.D., (2009). Guidelines for computing MaxEnt model output values from a lambdas file.

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
37
38
39
40
41
# Acquire environmental variables
files <- list.files(path = file.path(system.file(package = "dismo"), "ex"),
                    pattern = "grd", full.names = TRUE)
predictors <- raster::stack(files)

# Prepare presence and background locations
p_coords <- virtualSp$presence
bg_coords <- virtualSp$background

# Create SWD object
data <- prepareSWD(species = "Virtual species", p = p_coords, a = bg_coords,
                   env = predictors, categorical = "biome")

# Create 4 random folds splitting only the presence data
folds <- randomFolds(data, k = 4, only_presence = TRUE)
model <- train(method = "Maxnet", data = data, fc = "l", folds = folds)

# Make cloglog prediction for the all study area and get the result as
# average of the k models
predict(model, data = predictors, fun = "mean", type = "cloglog")

# Make cloglog prediction for the all study area, get the average, standard
# deviation, and maximum values of the k models, and save the output in three
# files
## Not run: 
# The following commands save the output in the working directory
maps <- predict(model, data = predictors, fun = c("mean", "sd", "max"),
                type = "cloglog", filename = "prediction")
# In this case three files are created: prediction_mean.tif,
# prediction_sd.tif and prediction_max.tif

plotPred(maps$mean)
plotPred(maps$sd)
plotPred(maps$max)

# Make logistic prediction for the all study area, given as standard
# deviation of the k models, and save it in a file
predict(model, data = predictors, fun = "sd", type = "logistic",
        filename = "my_map")

## End(Not run)

SDMtune documentation built on July 17, 2021, 9:06 a.m.