Generates matrix with same marginal totals for non-negative decimal values
Function to generate null model matrices for the cases when the matrix entries are non-negative numbers, possibly non-integers. It maintains marginal totals (as does r2dtable
), but "smears" them out over all cells.
decimalr2dtable(N=10, web, steps=prod(dim(web)))
N |
Number of desired null model matrices. |
web |
An interaction matrix. |
steps |
Number of successive alterations of matrix entries. Defaults to 10 times the number of cells. See details. |
Index a 2 x 2 submatrix by select randomly two rows and two columns.
Draw a random value between 0 and the minimum of the diagonal entries in the submatrix.
Subtract this value from the diagonals and add it to the counter-diagonal entries.
Repeat steps times
The result is a decimal-numbered matrix, typically with values > 0 in each cell.
Indication: This function may be useful in some rare constellations. Imagine you sampled a plant-pollinator network and instead of counting the number of flower visits you recorded the nectar extracted by each pollinator. Then the marginal totals would indicate nectar production (plus confounding nectar attractiveness) and consumption potential for plants and pollinators, respectively. So, given that species differ in nectar production and consumption, what would you expect the network to look like? Enter decimalr2dtable
.
If external abundances (even in funny units such as biovolume in ml) are available, this function can easily provide the respective null models. See examples.
A list of N randomised matrices with the same dimensions as the initial web, all probably filled completely.
The output will typically be a fully filled matrix! Computing any index sensitive to matrix filling (such as connectance, degree, nestedness) for such a matrix is non-sensical!
Also, if used as a null model, an implicit assumption is that the values in the original matrix are meaningful as marginal totals. This may often not be the case, for example if entries are rates. Thus, probably this function is of very limited usefulness in the context of network analyses!
Carsten F. Dormann <carsten.dormann@biom.uni-freiburg.de>
r2dtable
, vaznull
, shuffle.web
and swap.web
obs <- networklevel(Safariland, index="generality") nulls <- decimalr2dtable(10, Safariland) g.dec <- sapply(nulls, networklevel, index="generality") nullsint <- nullmodel(Safariland, N=10) g.int <- sapply(nullsint, networklevel, index="generality") plot(density(g.dec[1,]), xlim=c(1, 3)) lines(density(g.int[1,]), col="red") abline(v=obs[1], col="green") ## If you want to use external abundances to set up your null model: set.seed(1) ext.rows <- runif(9) # imagine these are your external abundances for Safariland ext.cols <- runif(27) # standardise to sum = 1: ext.rows <- ext.rows/sum(ext.rows) ext.cols <- ext.rows/sum(ext.cols) web <- tcrossprod(ext.rows, ext.cols) * sum(Safariland) # (to get to the same interaction density as original web) # # this can now be used as input for decimalr2dtable: image(decimalr2dtable(N=1, web)[[1]]) # remember: white are high values!
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.