DOI: 10.6084/m9.figshare.3531572.v1
title: Supplement 1. R functions used for the analysis.

description: File List <i><b>All files at once</b></i> supplement_functions.zip <i><b>Function list</b></i> confint.r intasymm.r intereven.r mgen.r mlik.r netstats.r plotmat.r quant2bin.r sortmatr.r sortmatrext.r Description <b>Main functions</b> This supplement contains R functions used for the analyses presented in the main text. Main functions are plotmat, which draws plots of the interaction matrices (Fig. 1); netstats, which calculates aggregate network statistics (Fig. 2); and mlik, which calculates multinomial likelihood and AIC (Fig. 3). Other functions are either called by these main functions to perform operations, or do other related operations. An example of the use of these functions is available in the bipartite package of R (Dormann et al., 2008) (type ?vazquez.example in the R console after installing and uploading the bipartite package). <b>Function descriptions</b> confint -- Confidence intervals of a vector or matrix of simulated values. Used by netstats to calculate 95% confidence intervals of simulated aggregate network statistics. intasymm -- Interaction strength asymmetry, calculated following Vázquez et al. (2007). intereven -- Interaction evenness, calculated following Tylianakis et al. (2007). mgen -- Matrix generating algorithm used by netstats to generate simulated interaction matrices according to a given probability matrix. mlik -- Calculation of multinomial likelihood and AIC according to a given probability matrix. Usage: mlik(imatr, m.p, par), where imatr is the observed interaction matrix, m.p is the probability matrix, and par is the number of parameters used to calculate AIC. netstats -- Aggregate network statistics: connectance, nestedness, interaction evenness and mean interaction strength asymmetry for each group in the network. Usage: netstats(imatr, randomize=TRUE, iter=1000, pmatr=NULL), where imatr is the observed interaction matrix and pmatr is the probability matrix used for generating predicted matrices. The R package bipartite (Dormann et al. 2008) is required by netstats to calculate nestedness. plotmat -- Graphic function to plot interaction matrices as in Fig. 1. Usage: plotmat(imatr, xlabel="PLANTS", ylabel="POLLINATORS", cexmin=0.2, cexmax=2, sortm=TRUE, sqroot=TRUE), where imatr is the interaction matrix to be plotted, xlabel and ylabel are the texts for the <i>x</i> and <i>y</i> axes, cexmin and cexmax are the minimum and maximum sizes of circles representing pairwise interactions, sortm indicates whether matrix should be sorted (sortm=TRUE) or left in the original order (sortm=FALSE), and sqroot indicates whether interaction frequencies (matrix cells) are to be plotted in untransformed or square-root transformed. quant2bin -- Transformation of quantitative matrix into binary. Used by netstats to calculate connectance. sortmatr -- Matrix sorting algorithm used by plotmat. The matrix is sorted according to row and column totals, so that nestedness can be visualized. sortmatrext -- Matrix sorting algorithm used as an alternative to sortmatr. Here, the matrix is sorted according to external vectors instead of row and column totals.