crossvalid: Cross validation routine for (species distribution)...

Description Usage Arguments Examples

View source: R/func.model.R

Description

repeated k-fold cross-validation. Calculate model preformance metrics, disribution, standard deviation and occurence maps.

Usage

1
2
3
4
5
crossvalid(Ncv, Kfold, data, method, responsetype, response, predictors,
  secondary = NULL, strata = NULL, enviStack = NULL, enviPix = NULL,
  seed, aggregated = NULL, pseudoabsence = NULL, gbm.trees = 2000,
  maxargs = c("outputformat=logistic", "defaultprevalence=0.5"),
  rast = TRUE, flat = FALSE, ...)

Arguments

Ncv

Number of cv repititions.

Kfold

Number of folds. Usually take 10 or 5.

data

SpatialPointsDataFrame containing response and predictors

method

SDM methos used: "gam", "rf", "gbm", "max", or "gbm.step". See details for details

responsetype

Type of the response: "count", "continuous", or "presence". Presence denotes bimodal responses [0|1]

response

Column name of response in data argument

predictors

Column names of predictors to use in data argument

secondary

Column name in data. Use this to calculate model performance metrics from instead of response. Default is NULL.

strata

criterion for fold generation. #FIXME

enviStack

RasterStack of predictors. Used to calculate SD map

enviPix

SpatialPixelsDataFrame of predictors. enviPix<-as(enviStack,"SpatialPixelsDataFrame"). Only for performance.

seed

Integer. You probably want reproduceability. Note that Maxent's pseudoabsence generation can't be seeded this way–so expect those results to vary

aggregated

logical or NULL Default is NULL. This is for ensemble calculations and added to metrics in case of not being NULL

pseudoabsence

logical or NULL Default is NULL. Same as above

gbm.trees

gbm.trees param for dismo::gbm

maxargs

argument to pass tp maxent

rast

return list of metric and raster

flat

return model performance metrics only (as data.frame)

...

ellipsis is used to pass arguments to subsequent functions like threshold.def (see metrics) or moranii() & makefn.free.model() (moParams=c("response","residuals"),moRange=list(c(0,0.5),c(0.5,1)),check.names=TRUE)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data<-get.environ(species,deutschebucht)
cv<-crossvalid(Ncv=1,Kfold=5,data=data,method="rf",responsetype = "continuous", response = "species1", predictors = c("mgs","mud","depth"),enviStack = deutschebucht,seed=23, check.names = FALSE)
 
# aggregated results
cv$metric.agg

# plot result maps
par(mfrow=c(2,2))
plot(cv$rmean,main="cv prediction")
plot(cv$sd,main="standart deviation")
plot(raster(deutschebucht,layer=match("species1",names(deutschebucht))),main="true distribution")
plot(cv$rbin,main="prob. of occurrence")

janhoo/crecs documentation built on May 18, 2019, 12:25 p.m.