2: Modelling Current Distributions
The environmental variables that you will be using are :
MTW - Mean temperature of warmest month
MTC - Mean temperature of coldest month
PREC0112 - Average annual precipitation
EVTR0112 - Evapotranspiration potential
GDD10_0112 - Growth days over 10°C
TMEAN0112 - Mean annual temperature
When you are selecting an environmental variable to use, you must ensure that you spell the variable name correctly (eg: TMEAN0112). If you do not, or if you use lower case letters, the GAM will not function correctly.
Calibrating, evaluation and running the GAM.
Load the "Script.R" script in a similar manner to the previous script. This script has explanations for each function that you will carry out, delimited by hashed lines:
#------------------------- # Load R Function Libraries #-------------------------
Some of these lines will describe how the following command line functions, and which variables you can replace:
#------------------------- # Calibration of the GAM # gam.model.name<-gamfunction(nameofspp~s(var1) + s(var2) .... etc, familyofdata(binomial for presence/absence), datasettocalibrateon, fit) # # Replace Species1 with a label of your choice #-------------------------
Some of the commands allow you to choose between two options - these are explained in the script. Those lines that ARE NOT preceded by a hash (#) are commands, and you run them by highlighting the command, and then clicking on the "Run command/line" button:
Continue through the script, all the way through to the point where you export the predictions to a text file, (followed by three full hashed lines ###########), which you can then open in ArcView. As before, highlight the relevant text in the script, and click on the RUN button in the GAM. The steps below are what you will be doing in R once you have initialized the GAM, and each of them refers to a section of the "Script.R" script that you are using to run the GAM.
NB: Each stage is explained in the script before the actual functions. You can use the script itself as a guide to what you should be doing.
NB: Some of the functions have outputs that can only be seen in the Console window, such as the model summary and the ROC outputs. Be certain to look at these outputs in the console.
- Load Script.R
- Set up and calibrate the script as shown in this flash demonstration.
- Generate and study the summary, and check accuracy of model. To see the output of this line in R, have a look at the console.
- Look at the response curves. Notice how they differ from model to model.
- Use calibrated model to predict distributions.
- Evaluate accuracy using ROC. Check output in the command window. A good model has a value of 0.8, 0.6 - 0.8 fair, 0.5 random, less than 0.6 poor. (The output should be in the form AUC: 0.568435123)
- Estimate the optimal threshold for conversion of probability to binary data. (Done automatically by the script - you do not need to do any independent calculations).
- Do binary transformation (apply the chosen threshold value to the probability surface, in order to obtain presence/absence values).
- Export the binary predictions and probabilistic predictions as .txt files.
- Import the .txt files to ArcView, create an event theme, and compare the results with the observed distribution of the species.
- Save script with new name before step 12.
Repeating the experiment with more variables.
Having successfully run the model using one variable, you will need to repeat this process using 3 variables, and then 5 variables. Reload the "Script.R" script into R.
- Repeat steps 1 to 11 using 3 and 5 variables.