The aim of this vignette is to showcase the different plotting options that STEPCAM has to offer. We are not aiming to correctly infer underlying parameter values.
To be able to plot results, we need data, and some STEPCAM output. We use a bit higher number of particles, for plotting reasons. Always try to use as many particles as computationally possible! A higher number of particles increases the accuracy of the STEPCAM model, but also requires more computational time to complete.
library(STEPCAM)
set.seed(42)
simul_data <- generate.Artificial.Data(n_species = 20, n_traits = 3, n_communities = 10,
occurence_distribution = 2, average_richness = 0.6,
sd_richness = 0.25, mechanism_random = FALSE)
output <- STEPCAM_ABC(simul_data$abundances, simul_data$traits,
numParticles = 100, n_traits = 3, plot_number = 5,
stopRate = 0.1, stop_at_iteration = 8,
continue_from_file = TRUE)
##
## Generating Particles for iteration 1
## 0--------25--------50--------75--------100
## ***************************************** 4.82 4.35 4.83 accept rate = 1
##
## Generating Particles for iteration 2
## 0--------25--------50--------75--------100
## ***************************************** 4.76 4.34 4.9 accept rate = 1
##
## Generating Particles for iteration 3
## 0--------25--------50--------75--------100
## ***************************************** 5.18 4.27 4.55 accept rate = 1
##
## Generating Particles for iteration 4
## 0--------25--------50--------75--------100
## ***************************************** 4.51 4.46 5.03 accept rate = 0.9439252
##
## Generating Particles for iteration 5
## 0--------25--------50--------75--------100
## ***************************************** 4.86 3.9 5.24 accept rate = 0.8559322
##
## Generating Particles for iteration 6
## 0--------25--------50--------75--------100
## ***************************************** 6.42 3.83 3.75 accept rate = 0.7214286
##
## Generating Particles for iteration 7
## 0--------25--------50--------75--------100
## ***************************************** 5.23 4.55 4.22 accept rate = 0.3646209
##
## Generating Particles for iteration 8
## 0--------25--------50--------75--------100
## * 50.5 50.5 50.5 accept rate = 1
The Ternary plot shows us that at least LS does not have a high contribution, but since many dots are overlapping, not all information is shown:
Alternatively, we can plot histograms of the parameter values for each parameter:
This shows us that indeed the posterior distribution of Limiting Similarity is skewed towards zero (note that we did not use a lot of particles, nor push the algorithm towards extremely low acceptance rates for computational reasons). Furthermore, we see that although the mean of DA is around 0.3, the distribution has a strong peak towards zero, indicating a low contribution of DA as well. Furthermore, Habitat Filtering is peaked around 0.75, suggesting a sizeable contribution of Habitat Filtering.
Lastly we can plot the progress of the ABC-SMC algorithm:
The top row indicates the first iteration, and with each row moving downward, we proceed one iteration, until we arrive at the final iteration at the bottom (notice how the distributions of DA, HF and LS match that of the previous figure). Furthermore we notice that over time the Fit of the model (e.g. the similarity with the data) decreases, as expected. Also, we notice that the summary statistics (Richness, Evennees, Diversity and Optimum) converge to a single value, most likely the value of the observed data.