[This article was first published on Recology, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Another grad student and I tried recently to make a contribution to our understanding of the relationship between ecological network structure (e.g., nestedness) and community structure (e.g., evenness)…Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
…Alas, I had no luck making new insights. However, I am providing the code used for this failed attempt in hopes that someone may find it useful. This is very basic code. It was roughly based off of the paper by Bluthgen et al. 2008 Ecology (here). In my code the number of interactions is set to 600, and there are 30 plant species, and 10 animal species. This assumes they share the same abundance distributions and sigma values.
####################################################### ###########Community-Network Structure Simulation###### ####################################################### library(bipartite) # Set of mean and sd combinations of log-normal distribution # In my case, these values were those empirically estimated # from many bipartite networks from the Interaction Web Database mu <- c(0.5,2.9,5.3) sig <- c(0.75,1.6,2.45) # Function to make a set of matrices based on some combination of mu and sigma values make.matrices <- function(a,b,nmats){ plants <- round(rlnorm(n=30, meanlog=mu[a], sdlog=sig[b])) animals <- round(rlnorm(n=10, meanlog=mu[a], sdlog=sig[b])) plants <- plants*(600/sum(plants)) animals <- animals*(600/sum(animals)) r2dtable(nmats,animals,plants) } # Output matrices matrices11 <- make.matrices(1,1,100) matrices12 <- make.matrices(1,2,100) matrices13 <- make.matrices(1,3,100) matrices21 <- make.matrices(2,1,100) matrices22 <- make.matrices(2,2,100) matrices23 <- make.matrices(2,3,100) matrices31 <- make.matrices(3,1,100) matrices32 <- make.matrices(3,2,100) matrices33 <- make.matrices(3,3,100) # Calculate some network metrics-e.g., for one combination of mu and sigma nest11 <- numeric(100) linkspersp11 <- numeric(100) webasymm11 <- numeric(100) h211 <- numeric(100) inteven11 <- numeric(100) generality11 <- numeric(100) for(i in 1:length(matrices11)){ m <- matrix(unlist(matrices11[i]),ncol=30,byrow=F) metrics <- t(networklevel(m,index=c("nestedness","links per species","web asymmetry","H2","interaction evenness","generality"))) nest11[i] <- metrics[1] linkspersp11[i] <- metrics[3] webasymm11[i] <- metrics[4] h211[i] <- metrics[5] inteven11[i] <- metrics[6] generality11[i] <- metrics[7] } nest11 linkspersp11 webasymm11 h211 inteven11 generality11
To leave a comment for the author, please follow the link and comment on their blog: Recology.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.