Learn R Programming

mopa (version 1.0.1)

extractFromModel: Extrac objects from lists returned by function mopaTrain

Description

Extract values returned by function mopaTrain

Usage

extractFromModel(models, value = c("model", "auc", "kappa", "tss",
  "fold.models", "ObsPred"))

Arguments

models

Object returned by mopaTrain.

value

Any character of the following: "model", "auc", "kappa", "tss", "fold.models", "ObsPred"

Value

Depending on the specified value:

"model"

fitted model using all data for training

"auc"

AUC statistic in the cross validation

"kappa"

kappa statistic in the cross validation

"tss"

true skill statistic in the cross validation

"fold.models"

fitted model with partitioned data

"ObsPred"

Observed and prediced (cross model prediction) values

Details

ObsPred allows to calculate further accuracy measures.

Examples

Run this code
# NOT RUN {
## Load presence data
data(Oak_phylo2)

## Load Climate data
destfile <- tempfile()
data.url <- "https://raw.githubusercontent.com/SantanderMetGroup/mopa/master/data/biostack.rda"
download.file(data.url, destfile)
load(destfile, verbose = TRUE)

## Spatial reference
r <- biostack$baseline[[1]]

## Create background grid
bg <- backgroundGrid(r)
## Generate pseudo-absences
RS_random <-pseudoAbsences(xy = Oak_phylo2, background = bg$xy, 
                           exclusion.buffer = 0.083*5, prevalence = -0.5, kmeans = FALSE)
## Model training
fittedRS <- mopaTrain(y = RS_random, x = biostack$baseline, 
                      k = 10, algorithm = "glm", weighting = TRUE)
## Extract fitted models
mods <- extractFromModel(models = fittedRS, value = "model")
## Extract observed and predicted values
ObsPred <- extractFromModel(models = fittedRS, value = "ObsPred")

# }

Run the code above in your browser using DataLab