-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
351 additions
and
1,831 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#--------------------------------------------------------------- | ||
# main_habitat_species | ||
#--------------------------------------------------------------- | ||
# This script controls the workflow used for habitat modeling | ||
|
||
|
||
#----------------------------------------------------------- | ||
# 1. Set parameters | ||
#----------------------------------------------------------- | ||
|
||
## Load dependencies | ||
source("setup.R") | ||
source("scr/fun_habitat_plot.R") | ||
|
||
## Set initial parameters | ||
sp_code <- "GAZ" # species code | ||
sp_name <- "A. gazella" | ||
stack_repo <- paste0(output_data, "/stack_daily") # location of environmental data | ||
vars <- c("BAT", "SLP", "SST", "SSTg", "SAL", "SALg", "SSH", "EKE", "CHL", "SIC", "MLD", "EDGE", "SIT") # list of all predictors | ||
|
||
## computer cores | ||
cores <- 50 # numbers of cores | ||
|
||
|
||
#----------------------------------------------------------- | ||
# 2. Split training and testing dataset | ||
#----------------------------------------------------------- | ||
# Training and testing | ||
# This step was originaly designed to split datasets for cross-validation. | ||
# Final version of the analysis uses a leave-one-out approach and this part is | ||
# is no longer required. I keep the code as it does not affect and can be useful | ||
# for other works. | ||
train_prop <- 0.75 | ||
source("analysis/habitat_model/scr/training_testing.R") | ||
|
||
|
||
#----------------------------------------------------------- | ||
# 3. Exploratory Data Analysis | ||
#----------------------------------------------------------- | ||
# Reads all presence/absence data and generates several plots to explore all variables | ||
# - Checks for missing data | ||
# - Pearson and Spearman rank correlations | ||
# - Density plots to compare presence/absence | ||
source("analysis/habitat_model/scr/eda.R") | ||
|
||
# After visual inspection, keep and exclude variables | ||
vars2remove <- c("SIT") # We remove SIT (keep SIC) | ||
vars <- vars[!vars %in% vars2remove] | ||
|
||
|
||
#----------------------------------------------------------- | ||
# 4. Fit BRT | ||
#----------------------------------------------------------- | ||
# Fit model | ||
source("analysis/habitat_model/scr/fit_brt.R") | ||
|
||
|
||
|
||
#----------------------------------------------------------- | ||
# 5. Fit Accessibility model | ||
#----------------------------------------------------------- | ||
# Fit model | ||
source("analysis/habitat_model/scr/accessibility_ice.R") | ||
|
||
|
||
#----------------------------------------------------------- | ||
# 6. Predict combining BRT and accessbility model | ||
#----------------------------------------------------------- | ||
# Set prediction period | ||
date_start <- as.Date("2019-02-01") | ||
date_end <- as.Date("2019-09-30") | ||
|
||
# Select if use bootrap models or full model | ||
bootstrap <- TRUE | ||
|
||
# Predict | ||
if(bootstrap == FALSE) source("analysis/habitat_model/scr/predict_brt.R") | ||
if(bootstrap == TRUE) source("analysis/habitat_model/scr/predict_brt_boot.R") | ||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.