View source: R/boot_specieslevel.r
boot_specieslevel_n | R Documentation |
Bootstrap a single network of interactions n times in parallel. This
function is used for network metrics at the species level. Starts with a
small sample size of interactions (e.g. start = 30
), builds the
corresponding web matrix/network, computes its metric (e.g. index = "d"
)
using specieslevel
, then adds new interactions
(e.g. step = 20
) until all interactions are sampled. The last sample is
actually the entire network. Repeats n times (as given in n_boot
) these
steps in parallel on multiple CPUs.
boot_specieslevel_n(
data,
col_lower,
col_higher,
index,
level,
start,
step,
n_boot,
n_cpu,
...
)
data |
Data frame of interactions from which to build and sample web matrices. Each interaction (row in the data frame) must be repeated as many times as it was observed. E.g. if species_1 x species_2 was observed 5 times, then repeat that row 5 times within the data frame. See examples below. |
col_lower |
Quoted column name in |
col_higher |
Quoted column name in |
index |
Passed to |
level |
Passed to |
start |
Integer. The sample size (number of interactions) to start the bootstrap
with. If the start sample size is small (e.g. 5 or 10), then first
iterations might results in NaN-s and warning messages are displayed.
Consider to set |
step |
Integer. Sample size (number of interactions) used to increase gradually the
sampled network until all interactions are sampled. If |
n_boot |
Number of desired bootstraps (50 or 100 can be enough). |
n_cpu |
Number of CPU-s to use for parallel processing. |
... |
Other arguments passed to |
Returns a list of 1, 2 or 4 arrays of matrices. The species names are stored
as the row names of each matrix. The number of columns of a matrix indicates
how many iterations took place. This is decided internally based on the given
values to start
, step
and the total number of rows (interactions) in
data
. The column names give the sample size at each iteration. The last
iteration (last column name) is always the entire network (total number of
interactions in data
). The 3rd dimension (number of matrices in the array)
corresponds to n_boot
(number of bootstraps).
library(bootstrapnet)
library(magrittr)
library(bipartite)
data(Safariland)
Safariland %>%
web_matrix_to_df() %>%
boot_specieslevel_n(col_lower = "lower", # column name for plants
col_higher = "higher", # column name for insects
index = "d",
level = "both",
start = 100,
step = 100,
n_boot = 10,
n_cpu = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.