Compute semi-variance (partial R[2]) for GLMMs fit used lme4.
library(lme4)
example <- data.frame(
y = rnorm(100),
x = rnorm(100),
nested1 = letters[1:20],
nested2 = rep(letters[1:5], each = 4),
Compute semi-variance (partial R[2]) for GLMMs fit used lme4.
library(lme4)
example <- data.frame(
y = rnorm(100),
x = rnorm(100),
nested1 = letters[1:20],
nested2 = rep(letters[1:5], each = 4),
A function that takes individual species thermal indices (STIs) and their abundances, and partitions their contributions to the change in the community thermal index through at least two time points.
example <- data.frame(
site = "site1",
date = c(rep(as.Date("2001-01-01"), 5), rep(as.Date("2002-01-01"), 5)),
species = paste0("species", LETTERS[1:5]),
STI = c(21.2, 23.4, 19.2, 26.1, 22.0),
abundance = c(0, 0, 10, 8, 3, 1, 3, 5, 0, 0)
)
A function that takes a sample (rows)-by-species (columns) community matrix and uses coverage-based subsampling to identify the number of samples of individuals required to achieve a given level of coverage of total biodiversity.
From: Chao, Anne, and Lou Jost. "Coverage‐based rarefaction and extrapolation: standardizing samples by completeness rather than size." Ecology 93.12 (2012): 2533-2547.
# generate fake community matrix
vec <- sample(0:100, 100, replace = T)
Simulate community-by-species matrix of "functioning" (e.g., biomass) where the total community richness has a predefined correlation with total community biomass (i.e., the row sums).
# Generate community data
ncomms <- 100
nspecies <- 20
A revised function from the iNEXT
package (https://github.com/JohnsonHsieh/iNEXT) that
calculates coverage-based rarefaction from abundance data. Instead of computing all orders
of q
it allows the user to specify a single order, and additionally omits bootstrapping
of standard errors. The resulting function is much, much faster.
# Create fake community-by-species abundance matrix
Takes a sample-by-species abundance matrix and species-by-species functional distance matrix and returns values of Rao's quadratic entropy. Values are optionally converted into effective numbers of species through the transformation: 1/(1 - D).
# Create sample-by-species abundance matrix
abund <- matrix(sample(1:100, 100, replace = T), 10, 10)
colnames(abund) <- paste0("species", 1:10)
The function VarCorrCI
takes a merMod
object and returns variance components and 95% confidence intervals.
Modified from: http://rpubs.com/bbolker/varwald and various other places.
library(lme4)
This function takes a data.frame
corresponding to the site-by-species "functioning" matrix (where cells contain the values of the ecosystem function), and returns the five additive components of the Price equation.
# Example 1: all species contribute equally to functioning and all occur at the baseline site
# Here, RICH_L should be negative and equal the total number of unshared species at each site
# COMP and CDE terms should be zero
Generates estimates of ash-free dry weight from size-fractionated abundances of epifaunal invertebrates.
From:
Edgar, Graham J. "The use of the size structure of benthic macrofaunal communities to estimate faunal biomass
and secondary production." Journal of Experimental Marine Biology and Ecology 137.3 (1990): 195-214.