multivariate_difference {codyn} | R Documentation |
Using dissimilarity-based measures to calculate differences in composition and dispersion between pairs of treatments at a single time point
Description
Calculates the difference in composition and dispersion between treatments based off a Bray-Curtis dissimilarity matrix at a single point in time. Composition difference is the pairwise distance between centroids of compared treatments and ranges from 0-1, where identical communities give 0 and completely different communities give 1. Dispersion difference is the difference between treatments in the dispersion of replicates, i.e. the average distance between a replicate and its centroid.
Usage
multivariate_difference(
df,
time.var = NULL,
species.var,
abundance.var,
replicate.var,
treatment.var,
reference.treatment = NULL
)
Arguments
df |
A data frame containing a species, abundance, replicate, and treatment columns and optional time column. |
time.var |
The name of the optional 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 identifiers must be unique within the dataset and cannot be nested within treatments or blocks. |
treatment.var |
The name of the treatment column. |
reference.treatment |
The name of the optional treatment that all other treatments will be compared to (e.g. only controls will be compared to all other treatments). If not specified all pairwise treatment comparisons will be made. |
Value
The multivariate_difference function returns a data frame with the following attributes:
treatment.var: A column that has same name and type as the treatment.var column, if treatment.var is specified.
treatment.var2: A column that has the same type as the treatment.var column, and is named treatment.var with a 2 appended to it.
composition_diff: A numeric column that is the euclidean distance between the centroids of two treatments at a single point in time.
abs_dispersion_diff: A numeric column that is the absolute value of the difference in the average dispersion of the replicates around the centroid for the two treatments.
trt_greater_disp: A column that has same type as the treatment.var column, and specifies which of the two treatments has greater dispersion.
time.var: A characteristic column that has the same name and type as the time.var column, if specified.
References
Avolio et al. Submitted, Avolio et al. 2015, Marti Anderson et al. 2006
Examples
data(pplots)
# Without time
df <- subset(pplots, year == 2002)
multivariate_difference(df,
replicate.var = "plot",
treatment.var = "treatment",
species.var = "species",
abundance.var = "relative_cover")
# There are 6 replicates for each of three treatments, thus 18 total
# observations.
# Without time and with reference treatment
df <- subset(pplots, year == 2002)
multivariate_difference(df,
replicate.var = "plot",
treatment.var = "treatment",
species.var = "species",
abundance.var = "relative_cover",
reference.treatment = "N1P0")
# There are 6 replicates for each of three treatments, thus 18 total
# observations.
# With time
multivariate_difference(pplots,
time.var = "year",
replicate.var = "plot",
species.var = "species",
abundance.var = "relative_cover",
treatment.var = "treatment")
# In each year there are 6 replicates for each of three treatments, for a
# total of 18 observations.