Learn R Programming

codyn (version 2.0.0)

multivariate_change: Using dissimilarity-based metrics to calculate changes in composition and dispersion

Description

Calculates the changes in composition and dispersion based off a Bray-Curtis dissimilarity matrix. Composition change is the euclidean distance between the centroids of compared time periods and ranges from 0-1, where 0 are identical communities, and 1 and completely different communities. Since composition change is based on plotted distance between centroids, it is context dependent and depends on how many centroids are being plotted, thus result of composition change depends on how many time periods are being measured. Dispersion change is the difference of average dispersion of each replicate to its centroid between time periods.

Usage

multivariate_change(df, time.var, species.var, abundance.var, replicate.var,
  treatment.var = NULL, reference.time = NULL)

Arguments

df

A data frame containing time, species, abundance and replicate columns and an optional column of treatment

time.var

The name of the time column

species.var

The name of the species column

abundance.var

The name of the abundance column

replicate.var

The name of the replicate column. Replicate must be unique within the dataset and cannot be nested within treatments or blocks.

treatment.var

the name of the optional treatment column

reference.time

The name of the optional time point that all other time points should be compared to (e.g. the first year of data). If not specified, each comparison is between consecutive time points (e.g. first to second year, second to third year, etc.)

Value

The multivariate_change function returns a data frame with the following attributes:

  • time.var: A column with the specified time.var and a second column, with '2' appended to the name. Time is subtracted from time2 for dispersion change.

  • composition_change: A numeric column that is the euclidean distance between the centroids of two time points.

  • dispersion_change: A numeric column that is the difference in the average dispersion of the replicates around the centroid for the two time periods. A negative value indicates replicates are converging over time (there is less dispersion at time period 2 than time period 1) and a positive value indicates replicates are diverging over time (there is more dispersion at time period 2 than time period 1.

  • treatment.var: A column that has same name and type as the treatment.var column, if treatment.var is specified.

References

Avolio et al. 2015; Avolio et al. Submitted MEE, Mari Anderson et al. 2006.

Examples

Run this code
# NOT RUN {
data(pplots)
# With treatment
multivariate_change(pplots,
                    time.var="year", 
                    replicate.var = "plot", 
                    treatment.var = "treatment", 
                    species.var = "species", 
                    abundance.var = "relative_cover")
# In each year there are 6 replicates and there are 4 years of data for 3
# time comparisons, thus 24 total observations in each treatment.

# With treatment and reference year
multivariate_change(pplots,
                    time.var="year", 
                    replicate.var = "plot", 
                    treatment.var = "treatment", 
                    species.var = "species", 
                    abundance.var = "relative_cover",
                    reference.time = 2002)
# In each year there are 6 replicates and there are 4 years of data for 3
# time comparisons, thus 24 total observations in each treatment.

# Without treatment
df <- subset(pplots, treatment == "N1P0")
multivariate_change(df, 
                    time.var="year", 
                    replicate.var = "plot", 
                    species.var = "species", 
                    abundance.var = "relative_cover")
# In each year there are 6 replicates and there are 4 years of data for 3
# time comparisons, thus 24 total observations.

# }

Run the code above in your browser using DataLab