correlate_sdm: Correlation between projections

View source: R/correlate_sdm.r

correlate_sdmR Documentation

Correlation between projections

Description

This function aims to unveil the correlation of different algorithms outputs. For that, it uses the predictions on current scenario, but other scenarios can be tested.

Usage

correlate_sdm(i, scenario = "current")

Arguments

i

A input_sdm object containing predictions.

scenario

A character containing scenario to be tested. Standard is "current". Value must match scenarios_names(i).

Value

A data.frame with pearson correlation between projections.

Author(s)

Luíz Fernando Esser (luizesser@gmail.com) https://luizfesser.wordpress.com

Examples

if (interactive()) {
  # Create sdm_area object:
  set.seed(1)
  sa <- sdm_area(parana, cell_size = 100000, crs = 6933)

  # Include predictors:
  sa <- add_predictors(sa, bioc) |> select_predictors(c("bio1", "bio12"))

  # Include scenarios:
  sa <- add_scenarios(sa)

  # Create occurrences:
  oc <- occurrences_sdm(occ, crs = 6933) |> join_area(sa)

  # Create input_sdm:
  i <- input_sdm(oc, sa)

  # Pseudoabsence generation:
  i <- pseudoabsences(i, method="random", n_set=2)

  # Custom trainControl:
  ctrl_sdm <- caret::trainControl(method = "boot",
                                  number = 1,
                                  repeats = 1,
                                  classProbs = TRUE,
                                  returnResamp = "all",
                                  summaryFunction = summary_sdm,
                                  savePredictions = "all")

  # Train models:
  i <- train_sdm(i, algo = c("naive_bayes"), ctrl=ctrl_sdm) |>
    suppressWarnings()

  # Predict models:
  i  <- predict_sdm(i, th = 0.8)

  # Check correlations:
  correlate_sdm(i)
}

caretSDM documentation built on March 10, 2026, 5:08 p.m.