model_validation {enmpa}R Documentation

Model validation options

Description

Model evaluation using entire set of data and a k-fold cross validation approach. Models are assessed based on discrimination power (ROC-AUC), classification ability (accuracy, sensitivity, specificity, TSS, etc.), and the balance between fitting and complexity (AIC).

Usage

model_validation(formula, data, family = binomial(link = "logit"),
                 weights = NULL, cv = FALSE, partition_index = NULL,
                 k = NULL, dependent = NULL, n_threshold = 100,
                 keep_coefficients = FALSE, seed = 1)

Arguments

formula

(character) expression to be used as a glm formula.

data

data.frame with dependent and independent variables.

family

a family object for models used by functions such as glm. Default = binomial(link = "logit").

weights

(numeric) vector with weights for observations. Default = NULL.

cv

(logical) whether to use a k-fold cross validation for evaluation. Default = FALSE.

partition_index

list of indices for cross validation in k-fold. Obtained with the function kfold_partition. Default = NULL.

k

(numeric) number of folds for a new k-fold index preparation. Ignored if partition_index is defined or if cv = FALSE. Default = NULL.

dependent

(character) name of dependent variable. Ignore if cv = FALSE. Default = NULL.

n_threshold

(numeric) number of threshold values to be used for ROC. Default = 100.

keep_coefficients

(logical) whether to keep model coefficients. Default = FALSE.

seed

(numeric) a seed number. Default = 1.

Value

A data.frame with results from evaluation.

Examples

# Load species occurrences and environmental data.
data("enm_data", package = "enmpa")
head(enm_data)

# Custom formula
form <- c("Sp ~ bio_1 + I(bio_1^2) + I(bio_12^2)")

# Model evaluation using the entire set of records
model_validation(form, data = enm_data)

# Model evaluation using a k-fold cross-validation (k = 3)
model_validation(form, data = enm_data, cv = TRUE, k = 3, dependent = "Sp")

[Package enmpa version 0.1.8 Index]