itsdm
calls isolation forest and variations such as
SCiForest and EIF to model species distribution. It provides features
including:
Install the CRAN release of itsdm
with
install.packages("itsdm")
You can install the development version of itsdm from GitHub with:
# install.packages("remotes")
::install_github("LLeiSong/itsdm") remotes
This is a basic example which shows you how to solve a common problem:
library(itsdm)
library(dplyr)
library(stars)
library(ggplot2)
# Using a pseudo presence-only occurrence dataset of
# virtual species provided in this package
data("occ_virtual_species")
# Split to training and test
<- occ_virtual_species %>%
occ_virtual_species mutate(id = row_number())
set.seed(11)
<- occ_virtual_species %>% sample_frac(0.7)
occ <- occ_virtual_species %>% filter(! id %in% occ$id)
occ_test <- occ %>% select(-id)
occ <- occ_test %>% select(-id)
occ_test
# Get environmental variables
<- system.file(
env_vars 'extdata/bioclim_tanzania_10min.tif',
package = 'itsdm') %>% read_stars() %>%
slice('band', c(1, 6, 12, 15))
# Train the model
<- isotree_po(
mod occ = occ, occ_test = occ_test,
variables = env_vars, ntrees = 200,
sample_size = 0.8, ndim = 2L,
seed = 123L)
# Check results
## Suitability
ggplot() +
geom_stars(data = mod$prediction) +
scale_fill_viridis_c('Predicted suitability',
na.value = 'transparent') +
coord_equal() +
theme_linedraw()
## Plot independent response curves
plot(mod$independent_responses,
target_var = c('bio1', 'bio12'))
isotree
.We are welcome any helps! Please make a pull request or reach out to lsong@clarku.edu if you want to make any contribution.
This package is part of project “Combining Spatially-explicit Simulation of Animal Movement and Earth Observation to Reconcile Agriculture and Wildlife Conservation”. This project is funded by NASA FINESST program (award number: 80NSSC20K1640).