# Creates null model for bipartite networks

### Description

Function to generate null model webs under the following constraints: 1. marginal
totals are identical to those observed (as in `r2dtable`

), 2. connectance is as observed (as in `shuffle.web`

.)

### Usage

1 | ```
swap.web(N, web, verbose=FALSE, c.crit=1e4)
``` |

### Arguments

`N` |
Number of desired null model matrices. |

`web` |
An interaction matrix. |

`verbose` |
Should various verbal outputs of this function be shown? Defaults to FALSE, since it was mainly used during the debugging period. |

`c.crit` |
Sometimes the algorithm gets stuck in a very sparse matrix. Then c.crit sets the number of swaps it shall attempt before giving up and starting over on a new random matrix. Defaults to 10000. |

### Details

This function is designed to behave similar to `r2dtable`

, i.e. it returns a list of randomised matrices. In addition to `r2dtable`

is also keeps the connectance constant!

This function is thought of as a very constrained null model for the analysis of bipartite webs. It keeps two web properties constant: The marginal totals (as in `r2dtable`

and the number of links (and hence connectance). A comparison of `swap.web`

- and `r2dtable`

-based webs allows to elucidate the effect of evolutionary specialisation, since the unrealised connections may represent “forbidden links”.

This null model is similar to the one employed by Vázquez et al. But while Vázquez starts by assigning 1s to the allowed connections and then fills the web, `swap.web`

starts with an `r2dtable`

-web and successively “empties” it. The two approaches should result in very similar null models, since both constrain marginal totals and connectance.

A few words on the way `swap.web`

works. It starts with a random web created by `r2dtable`

. Then, it finds, randomly, 2x2 submatrices with entries all larger than 0. Next, it subtracts the minimum value from the diagonal and adds it to the off-diagonal (minor diagonal). Thereby one cell becomes 0, but the column and row sums do not change. This idea is adapted from the swap-algorithm used in various binary null models by Nick Gotelli. If the random web has too few 0s (which is I have yet to encounter), then the opposite strategy is applied.

The algorithm in our implementation has some variations on finding the submatrix and constraining the number of unsuccessfull trials before starting on a new random matrix, but they are only for speeding up the process.

### Value

A list of N randomised matrices with the same dimensions as the initial web.

### Note

Long stories can be told about the swap algorithm. I am not the right person to do so, but for a much more detailed coverage of the topic, for many more ways to implement null models for **binary** matrices, with various flavours of the swap and possible alternatives, first brew yourself a cup of tea and then check out the help pages of `simulate`

in vegan. (As usual, Jari Oksanen has spend considerable care to implement even the most bizarre and abstruse way to move 0s and 1s around. His ecological advise between the lines make his package worthwhile already! I, personally, would use `method="quasiswap"`

, as is done in the example to `discrepancy`

.)

When comparing the `swap.web`

algorithm with that proposed by Vázquez et al. (2007, implemented in `vaznull`

), we found that `swap.web`

contains a certain bias. The subtraction of the swap will reduce the value of low-value cells, and increase that of high-value cells. As a consequence, it produces somewhat of a dichotomy between very high and very low values. Using e.g. H2' to quantify this pattern, `swap.web`

will produce very specialised networks (around 0.5), while the Vazquez-algorithm yields lower H2' values and a more even distribution of interactions within cells.
The ramifications are that `swap.web`

will predict higher-than-necessary expectations. (Date of this entry: 15.1.2010)

In fact, Artzy-Randrup & Stone (2005) have shown that the swap algorithm is *fundamentally biased*, because some swaps are more likely than others. This applies to this version of the swap as well as to the one implemented in `vaznull`

. So, despite heavy citation, the approach of Miklós & Podani (2004) is thus also not ideal, as often claimed.

`swap.web`

is a very constraint null model. You need to consider if it is the right one for your application!

### Author(s)

Carsten F. Dormann <carsten.dormann@biom.uni-freiburg.de>

### References

Artzy-Randrup, Y., and Stone, L. (2005) Generating uniformly distributed random networks. *Physical Review E* **72**, 1–7

Miklós, I. and Podani, J. (2004) Randomization of presence-absence matrices: comments and new algorithms. *Ecology* **85**, 86–92

Vázquez, D. P., and M. A. Aizen (2003) Null model analyses of specialization in plant-pollinator interactions. *Ecology* **84**, 2493–2501

Vázquez, D. P., C. J. Melian, N. M. Williams, N. Blüthgen, B. R. Krasnov, and R. Poulin (2007) Species abundance and asymmetric interaction strength in ecological networks. *Oikos* **116**, 1120–1127

For a very nice and thorough overview of null models in general see:

Gotelli, N. J., and G. R. Graves (1996) Null Models in Ecology. Smithsonian Institution Press, Washington D.C.

### See Also

`r2dtable`

, `vaznull`

and `shuffle.web`

### Examples

1 | ```
swap.web(Safariland, N=2)
``` |