View source: R/boot_networklevel.r
boot_networklevel_n | R Documentation |
Bootstrap a single network of interactions n times in parallel and collects
the network level metrics. Starts with a small sample size of interactions
(e.g. start = 30
), builds the corresponding web matrix/network, computes
its metric (e.g. index = "nestedness"
) using
networklevel
, 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_networklevel_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 the interaction 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 a single matrix or a list of two matrices depending on the
provided index
metric and level
value. For example if
index='nestedness'
and level='both'
, then it returns a list of a single
matrix. But in the case of index='niche overlap'
, it returns a list of two
matrices, first matrix (niche.overlap.HL
) corresponding to the higher level
(e.g. insects), and the second (niche.overlap.LL
) for the lower level (e.g.
plants). The number of rows 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 row names
give the sample size at each iteration. The last iteration (last row name) is
always the entire network (total number of interactions in data
). The
number of columns corresponds to n_boot
(number of bootstraps).
library(bootstrapnet)
library(magrittr)
library(bipartite)
data(Safariland)
Safariland %>%
web_matrix_to_df() %>%
boot_networklevel_n(col_lower = "lower", # column name for plants
col_higher = "higher", # column name for insects
index = "niche overlap",
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.