gbsm.res | R Documentation |
This function allows the replication of the results on generalised B-spline modelling, presented
in Lagat et al. (2021b). Executing gbsm.res()
therefore gives these outputs that are saved
as .RDS
files in msco
. If the codes that produced these (saved) outcomes are desired, the
codes below are made available.
gbsm.res()
Returns all the results presented in Lagat et al. (2021b). To replicate
Figs. 1, 3, 4, 5, and Tables 1 and S1, execute the following code:
my.path <- system.file("extdata/gsmdat", package = "msco") setwd(my.path) s.data <- get(load("s.data.csv")) ##Species-by-site matrix t.data <- get(load("t.data.csv")) ##Species-by-trait matrix p.d.mat <- get(load("p.d.mat.csv")) ##Species-by-species phylogenetic distance matrix RNGkind(sample.kind = "Rejection") set.seed(1) gb.res <- msco::gbsm_m.orders(s.data, t.data, p.d.mat, metric = "Simpson_eqn", gbsm.model, orders = c(2:5, 8, 10, 15), d.f = 4, degree = 3, n = 1000, k = 5, p = 0.8, type = "k-fold", scat.plots = TRUE, response.curves = TRUE, j.occs.distrbn = TRUE, mp.plots = TRUE, max.vif = 10, max.vif2 = 3, start.range=c(-0.1,0) ) gb.res$contbn_table$`order 3` ## Table 1 gb.res$model.validation.table ## Table S1 gb.res$Original.VIFs$`order 3` gb.res$Intermediate.VIFs$`order 3` ## Resulting covariate VIFs after removing ## covariates with VIF > max.vif gb.res$Final.VIFs$`order 3` ## Resulting covariate VIFs after removing ## covariates with VIF > max.vif2
Figs. S1, 2, and S2, execute the following codes:
Fig. S1:
remotes::install_github("jinyizju/V.PhyloMaker", force = TRUE) library(V.PhyloMaker) my.path <- system.file("extdata/gsmdat", package = "msco") setwd(my.path) s.data <- get(load("s.data.csv")) ##Species-by-site matrix taxa <- get(load("taxa.levels.csv")) ##Species taxa my.phylo.plot <- msco::s.phylo(s.data, p.d.mat = NULL, database = "ncbi", obs.taxa = FALSE, taxa.levels = taxa, Obs.data = FALSE, phy.d.mat = FALSE, phylo.plot = TRUE)
Fig. 2:
my.path <- system.file("extdata/gsmdat", package = "msco") setwd(my.path) s.data <- get(load("s.data.csv")) ##Species-by-site matrix t.data <- get(load("t.data.csv")) ##Species-by-trait matrix p.d.mat <- get(load("p.d.mat.csv")) ##Species-by-species phylogenetic distance matrix RNGkind(sample.kind = "Rejection") set.seed(1) my.gbsm <- msco::gbsm(s.data, t.data, p.d.mat, metric = "Simpson_eqn", gbsm.model, d.f = 4, order.jo = 3, degree = 3, n = 1000, b.plots = TRUE, scat.plot = FALSE, response.curves = FALSE, leg = 1, max.vif = 10, max.vif2 = 3, start.range=c(-0.1,0) )
Fig. 6:
my.path <- system.file("extdata/gsmdat", package = "msco") setwd(my.path) s.data <- get(load("s.data.csv")) ##Species-by-site matrix t.data <- get(load("t.data.csv")) ##Species-by-trait matrix p.d.mat <- get(load("p.d.mat.csv")) ##Species-by-species phylogenetic distance matrix RNGkind(sample.kind = "Rejection") set.seed(1) pe <- msco::pred.error.bands(s.data, t.data, p.d.mat, metric = "Simpson_eqn", gbsm.model, d.f = 4, simm = 10, orders = c(2:5, 8, 10, 15), degree = 3, n = 1000, start.range = c(-0.2, 0) )
Caveat: The above codes can collectively take approximately 7 minutes to execute (with prediction uncertainty plot taking 6 minutes alone). It took 7.3895 minutes to run (and output results) on a 64 bit system with 8 GB RAM and 3.60 GHz CPU.
The function gbsm.res is not for general use. We included it in this package to help the readers of Lagat et al. (2021b) paper, who may want to get a deeper understanding of how the results presented in this paper were arrived at. It also allows deeper scrutiny of Lagat et al. (2021b)'s findings.
Lagat, V. K., Latombe, G. and Hui, C. (2021b). Dissecting the effects
of random encounter versus functional trait mismatching on multi-species
co-occurrence and interference with generalised B-spline modelling. DOI: <To be added>
.
## Not run:
gbs.res <- msco::gbsm.res()
gbs.res$contbn_table$`order 3`
gbs.res$model.validation.table
gbs.res$Original.VIFs$`order 3`
gbs.res$Intermediate.VIFs$`order 3`
gbs.res$Final.VIFs$`order 3`
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.