boot.matrix | R Documentation |
Bootstraps and rarefies either a matrix or a list of matrices.
boot.matrix(
data,
bootstraps = 100,
boot.type = "full",
boot.by = "rows",
rarefaction = FALSE,
verbose = FALSE,
prob = NULL
)
data |
A |
bootstraps |
The number of bootstrap pseudoreplicates ( |
boot.type |
The bootstrap algorithm to use ( |
boot.by |
Which dimension of the data to bootstrap: either |
rarefaction |
Either a |
verbose |
A |
prob |
Optional, a |
data
: The data is considered as the multidimensional space and is not transformed (e.g. if ordinated with negative eigen values, no correction is applied to the matrix).
rarefaction
: when the input is numeric
, the number of elements is set to the value(s) for each bootstrap. If some subsets have fewer elements than the rarefaction value, the subsets is not rarefied.
When the input is "min"
, the smallest number of elements is used (or 3 if some subsets have less than 3 elements).
boot.type
: the different bootstrap algorithms are:
"full"
: resamples all the rows of the matrix and replaces them with a new random sample of rows (with replace = TRUE
, meaning all the elements can be duplicated in each bootstrap).
"single"
: resamples only one row of the matrix and replaces it with a new randomly sampled row (with replace = FALSE
, meaning that only one element can be duplicated in each bootstrap).
"null"
: resamples all rows of the matrix across subsets. I.e. for each subset of n elements, this algorithm resamples n elements across ALL subsets. If only one subset (or none) is used, this does the same as the "full"
algorithm.
prob
: This option allows to attribute specific probability to each element to be drawn.
A probability of 0 will never sample the element, a probability of 1 will always allow it to be sampled.
This can also be useful for weighting elements: an element with a weight of 10 will be sampled ten times more.
If the argument is a matrix
, it must have rownames attributes corresponding to the element names.
If the argument is a vector
, it must have names attributes corresponding to the element names.
Multiple trees: If the given data
is a chrono.subsets
based on multiple trees, the sampling is proportional to the presence of each element in each tree: \sum (1/n) / T
(with n being the maximum number of elements among the trees and T being the total numbers of trees).
For example, for a slice through two trees resulting in the selection of elements A
and B
in the first tree and A
, B
and C
in the second tree, the "full"
bootstrap algorithm will select three elements (with replacement) between A
, B
and C
with a probability of respectively p(A) = 1/3
(p(A) = (1/3 + 1/3) / 2
), p(B) = 1/3
and p(C) = 1/6
(p(C) = (0 + 1/3) / 2
).
This function outputs a dispRity
object containing:
matrix |
the multidimensional space (a |
call |
A |
subsets |
A |
Use summary.dispRity to summarise the dispRity
object.
Thomas Guillerme
cust.subsets
, chrono.subsets
, dispRity
.
## Load the Beck & Lee 2014 matrix
data(BeckLee_mat50)
## Bootstrapping a matrix
## Bootstrapping an ordinated matrix 20 times
boot.matrix(BeckLee_mat50, bootstraps = 20)
## Bootstrapping an ordinated matrix with rarefaction
boot.matrix(BeckLee_mat50, bootstraps = 20, rarefaction = TRUE)
## Bootstrapping an ordinated matrix with only elements 7, 10 and 11 sampled
boot.matrix(BeckLee_mat50, bootstraps = 20, rarefaction = c(7, 10, 11))
## Bootstrapping an the matrix but without sampling Cimolestes and sampling Maelestes 10x more
boot.matrix(BeckLee_mat50, bootstraps = 20, prob = c("Cimolestes" = 0, "Maelestes" = 10))
## Bootstrapping a subsets of matrices
## Generating a dummy subsets of matrices
ordinated_matrix <- matrix(data = rnorm(90), nrow = 10, ncol = 9,
dimnames = list(letters[1:10]))
matrix_list <- custom.subsets(ordinated_matrix, list(A = 1:5, B = 6:10))
## Bootstrapping the subsets of matrices 20 times (each)
boot.matrix(matrix_list, bootstraps = 20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.