diff --git a/articles/01_data_preparationhelpers.html b/articles/01_data_preparationhelpers.html index 75c59670..e63adda3 100644 --- a/articles/01_data_preparationhelpers.html +++ b/articles/01_data_preparationhelpers.html @@ -96,7 +96,7 @@
vignettes/articles/01_data_preparationhelpers.Rmd
01_data_preparationhelpers.Rmd
## Lets load some testing data from the package
# Background layer
-background <- terra::rast(system.file("extdata/europegrid_50km.tif",package = "ibis.iSDM", mustWork = TRUE))
+background <- terra::rast(system.file("extdata/europegrid_50km.tif",package = "ibis.iSDM", mustWork = TRUE))
# Load virtual species points
virtual_species <- sf::st_read(system.file("extdata/input_data.gpkg",package = "ibis.iSDM", mustWork = TRUE), "points",quiet = TRUE)
# Add a range
@@ -199,7 +199,7 @@ Adding pseudo-absenc
# --- #
# Another option sampling inside the range, but biased by a bias layer
-bias <- terra::rast(system.file("extdata/predictors/hmi_mean_50km.tif",
+bias <- terra::rast(system.file("extdata/predictors/hmi_mean_50km.tif",
package = "ibis.iSDM", mustWork = TRUE))
abs <- pseudoabs_settings(background = background,
@@ -264,7 +264,7 @@ Thinning observations
# Another way: Use environmental thinning to retain enough points
# across the niche defined by a set of covariates
-covariates <- terra::rast(list.files(system.file("extdata/predictors/", package = "ibis.iSDM", mustWork = TRUE), "*.tif",full.names = TRUE))
+covariates <- terra::rast(list.files(system.file("extdata/predictors/", package = "ibis.iSDM", mustWork = TRUE), "*.tif",full.names = TRUE))
point2 <- thin_observations(data = virtual_species,
background = background,
@@ -274,7 +274,7 @@ Thinning observations )
#> (environmental) thinning completed!
#> Original number of records: 208
-#> Number of retained records: 33
+#> Number of retained records: 28
plot(point2['Observed'], main = "Environmentally stratified data")
@@ -298,7 +298,7 @@ Preparing and altering predictor
terra
package).
# Load some test covariates
-predictors <- terra::rast(list.files(system.file("extdata/predictors/", package = "ibis.iSDM", mustWork = TRUE), "*.tif",full.names = TRUE))
+predictors <- terra::rast(list.files(system.file("extdata/predictors/", package = "ibis.iSDM", mustWork = TRUE), "*.tif",full.names = TRUE))
@@ -330,8 +330,8 @@ Transforming predictors windsor_props = c(0,.9))
new <- c(layer, new3)
-names(new) <- c("original", "windsorized")
-terra::plot( new )
Other options for transformation are also available and are listed in the methods file.
@@ -361,8 +361,8 @@
@@ -371,14 +371,14 @@ Derivates of predictors # The number is controlled by the number of knots
nknots = 4
)
-terra::plot( new2 )
# What does this do precisely?
# Lets check
-df <- data.frame( ndvi = terra::values(layer),
- terra::values(new2))
+df <- data.frame( ndvi = terra::values(layer),
+ terra::values(new2))
plot(df$ndvi_mean_50km, df[,2], ylab = "First hinge of ndvi", xlab = "NDVI")
# Make a subset of all predictors to show the concept
-layers <- subset(predictors, c("aspect_mean_50km",
+layers <- subset(predictors, c("aspect_mean_50km",
"CLC3_312_mean_50km",
"elevation_mean_50km"))
# All these layers have identical data coverage.
# Now add missing data in one of the layers for testing
-layers$CLC3_312_mean_50km[sample(1:ncell(layers), 1000)] <- NA
+layers$CLC3_312_mean_50km[sample(1:ncell(layers), 1000)] <- NA
# Harmonize the predictors
new <- predictor_homogenize_na(env = layers)
# Now all the predictors have identical coverage of NA values
-terra::plot(new)
vignettes/articles/02_train_simple_model.Rmd
02_train_simple_model.Rmd
# Background layer
-background <- terra::rast(system.file("extdata/europegrid_50km.tif",package = "ibis.iSDM", mustWork = TRUE))
+background <- terra::rast(system.file("extdata/europegrid_50km.tif",package = "ibis.iSDM", mustWork = TRUE))
# Load virtual species points
virtual_species <- sf::st_read(system.file("extdata/input_data.gpkg",package = "ibis.iSDM", mustWork = TRUE), "points")
#> Reading layer `points' from data source
@@ -164,9 +164,9 @@ Load package and make a basic model
#> Bounding box: xmin: 4.109162 ymin: 48.7885 xmax: 24.47594 ymax: 64.69323
#> Geodetic CRS: WGS 84
# Predictors
-predictors <- terra::rast(list.files(system.file("extdata/predictors/", package = "ibis.iSDM", mustWork = TRUE), "*.tif",full.names = TRUE))
+predictors <- terra::rast(list.files(system.file("extdata/predictors/", package = "ibis.iSDM", mustWork = TRUE), "*.tif",full.names = TRUE))
# Make use only of a few of them
-predictors <- subset(predictors, c("bio01_mean_50km","bio03_mean_50km","bio19_mean_50km",
+predictors <- subset(predictors, c("bio01_mean_50km","bio03_mean_50km","bio19_mean_50km",
"CLC3_112_mean_50km","CLC3_132_mean_50km",
"CLC3_211_mean_50km","CLC3_312_mean_50km",
"elevation_mean_50km"))
# Other options to explore
-names(mod)
+names(mod)
#> [1] "summary" "show_biodiversity_length"
#> [3] "show_biodiversity_equations" "show_background_info"
#> [5] "show" "set_priors"
@@ -417,51 +417,51 @@ Validation of model predictionsfit$rm_threshold()
validate(fit, method = "cont")
#> modelid name method
-#> 1 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species continuous
-#> 2 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species continuous
-#> 3 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species continuous
-#> 4 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species continuous
-#> 5 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species continuous
-#> 6 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species continuous
-#> metric value
-#> 1 n 175.00000000
-#> 2 rmse 0.87856015
-#> 3 mae 0.67314153
-#> 4 logloss 1.77608616
-#> 5 normgini -0.07569721
-#> 6 cont.boyce 0.26208641
+#> 1 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species continuous
+#> 2 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species continuous
+#> 3 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species continuous
+#> 4 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species continuous
+#> 5 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species continuous
+#> 6 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species continuous
+#> metric value
+#> 1 n 175.0000000
+#> 2 rmse 0.8779555
+#> 3 mae 0.6723207
+#> 4 logloss 1.7755858
+#> 5 normgini -0.0749004
+#> 6 cont.boyce 0.2521260
# If the prediction is first thresholded, we can calculate discrete validation estimates (binary being default)
fit <- threshold(fit, method = "percentile", value = 0.5, format = "binary")
validate(fit, method = "disc")
#> modelid name method
-#> 1 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 2 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 3 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 4 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 5 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 6 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 7 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 8 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 9 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 10 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 11 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 12 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
-#> 13 8e18b74f-932d-4856-9d8b-cbbf30b86506 Virtual test species discrete
+#> 1 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 2 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 3 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 4 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 5 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 6 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 7 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 8 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 9 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 10 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 11 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 12 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
+#> 13 1fe29d02-2d76-40f9-950b-362492c129bd Virtual test species discrete
#> metric value
-#> 1 n 506.0000000
-#> 2 auc 0.6804316
-#> 3 overall.accuracy 0.7351779
-#> 4 true.presence.ratio 0.3963964
-#> 5 precision 0.6518519
+#> 1 n 513.0000000
+#> 2 auc 0.6878191
+#> 3 overall.accuracy 0.7465887
+#> 4 true.presence.ratio 0.4036697
+#> 5 precision 0.6717557
#> 6 sensitivity 0.5028571
-#> 7 specificity 0.8580060
-#> 8 tss 0.3608632
-#> 9 f1 0.5677419
-#> 10 logloss 6.2052837
-#> 11 expected.accuracy 0.5718961
-#> 12 kappa 0.3814068
-#> 13 brier.score 0.2648221
Validating integrated SDMs, particular those fitted with multiple likelihoods is challenging and something that has not yet fully been explored in the scientific literature. For example strong priors can diff --git a/articles/02_train_simple_model_files/figure-html/Example for model-based thresholding-1.png b/articles/02_train_simple_model_files/figure-html/Example for model-based thresholding-1.png index 6b8c8c38..d7c6c089 100644 Binary files a/articles/02_train_simple_model_files/figure-html/Example for model-based thresholding-1.png and b/articles/02_train_simple_model_files/figure-html/Example for model-based thresholding-1.png differ diff --git a/articles/02_train_simple_model_files/figure-html/Example for model-based thresholding-2.png b/articles/02_train_simple_model_files/figure-html/Example for model-based thresholding-2.png index 2e2cd42e..9c310d38 100644 Binary files a/articles/02_train_simple_model_files/figure-html/Example for model-based thresholding-2.png and b/articles/02_train_simple_model_files/figure-html/Example for model-based thresholding-2.png differ diff --git a/articles/02_train_simple_model_files/figure-html/Plot the model output-1.png b/articles/02_train_simple_model_files/figure-html/Plot the model output-1.png index d5821780..36eb0dbd 100644 Binary files a/articles/02_train_simple_model_files/figure-html/Plot the model output-1.png and b/articles/02_train_simple_model_files/figure-html/Plot the model output-1.png differ diff --git a/articles/02_train_simple_model_files/figure-html/Prediction limits-1.png b/articles/02_train_simple_model_files/figure-html/Prediction limits-1.png index ff5e97da..51878afe 100644 Binary files a/articles/02_train_simple_model_files/figure-html/Prediction limits-1.png and b/articles/02_train_simple_model_files/figure-html/Prediction limits-1.png differ diff --git a/articles/02_train_simple_model_files/figure-html/Train models with spatial constrains-2.png b/articles/02_train_simple_model_files/figure-html/Train models with spatial constrains-2.png index 46ef9e91..3623130e 100644 Binary files a/articles/02_train_simple_model_files/figure-html/Train models with spatial constrains-2.png and b/articles/02_train_simple_model_files/figure-html/Train models with spatial constrains-2.png differ diff --git a/articles/02_train_simple_model_files/figure-html/Train models with spatial constrains-3.png b/articles/02_train_simple_model_files/figure-html/Train models with spatial constrains-3.png index df7a5a5e..e554aa02 100644 Binary files a/articles/02_train_simple_model_files/figure-html/Train models with spatial constrains-3.png and b/articles/02_train_simple_model_files/figure-html/Train models with spatial constrains-3.png differ diff --git a/articles/02_train_simple_model_files/figure-html/partial effect-1.png b/articles/02_train_simple_model_files/figure-html/partial effect-1.png index 5dad6c5f..2b354a0e 100644 Binary files a/articles/02_train_simple_model_files/figure-html/partial effect-1.png and b/articles/02_train_simple_model_files/figure-html/partial effect-1.png differ diff --git a/articles/02_train_simple_model_files/figure-html/partial effect-2.png b/articles/02_train_simple_model_files/figure-html/partial effect-2.png index 5cb62201..48c197bb 100644 Binary files a/articles/02_train_simple_model_files/figure-html/partial effect-2.png and b/articles/02_train_simple_model_files/figure-html/partial effect-2.png differ diff --git a/articles/03_integrate_data.html b/articles/03_integrate_data.html index eed1cbd6..340bac4e 100644 --- a/articles/03_integrate_data.html +++ b/articles/03_integrate_data.html @@ -96,7 +96,7 @@
vignettes/articles/03_integrate_data.Rmd
03_integrate_data.Rmd
# Background layer
-background <- terra::rast(system.file("extdata/europegrid_50km.tif",package = "ibis.iSDM", mustWork = TRUE))
+background <- terra::rast(system.file("extdata/europegrid_50km.tif",package = "ibis.iSDM", mustWork = TRUE))
# Load virtual species points
virtual_species <- sf::st_read(system.file("extdata/input_data.gpkg",package = "ibis.iSDM", mustWork = TRUE), "points", quiet = TRUE)
virtual_range <- sf::st_read(system.file('extdata/input_data.gpkg', package='ibis.iSDM'), 'range', quiet = TRUE)
@@ -165,9 +165,9 @@ Load relevant packages and test
settings = ass)
# Predictors
-predictors <- terra::rast(list.files(system.file("extdata/predictors/", package = "ibis.iSDM", mustWork = TRUE), "*.tif",full.names = TRUE))
+predictors <- terra::rast(list.files(system.file("extdata/predictors/", package = "ibis.iSDM", mustWork = TRUE), "*.tif",full.names = TRUE))
# Make use only of a few of them
-predictors <- subset(predictors, c("bio01_mean_50km","bio03_mean_50km","bio19_mean_50km",
+predictors <- subset(predictors, c("bio01_mean_50km","bio03_mean_50km","bio19_mean_50km",
"CLC3_112_mean_50km","CLC3_132_mean_50km",
"CLC3_211_mean_50km","CLC3_312_mean_50km",
"elevation_mean_50km"))