Skip to contents

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")
#> Composition and dispersion change calculation using 18 observations.
#>   treatment treatment2 composition_diff abs_dispersion_diff trt_greater_disp
#> 4      N1P0       N2P0       0.07108743          0.01123982             N2P0
#> 7      N1P0       N2P3       0.09985185          0.04426276             N2P3
#> 8      N2P0       N2P3       0.15244281          0.03302294             N2P3
# 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")
#> Composition and dispersion change calculation using 18 observations.
#>   treatment treatment2 composition_diff abs_dispersion_diff trt_greater_disp
#> 1      N1P0       N2P0       0.07108743          0.01123982             N2P0
#> 2      N1P0       N2P3       0.09985185          0.04426276             N2P3
# 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")
#> Composition and dispersion change calculation using 18 observations for 2002
#> Composition and dispersion change calculation using 18 observations for 2003
#> Composition and dispersion change calculation using 18 observations for 2004
#> Composition and dispersion change calculation using 18 observations for 2005
#>    year treatment treatment2 composition_diff abs_dispersion_diff
#> 1  2002      N1P0       N2P0       0.07108743         0.011239820
#> 2  2002      N1P0       N2P3       0.09985185         0.044262761
#> 3  2002      N2P0       N2P3       0.15244281         0.033022941
#> 4  2003      N1P0       N2P0       0.09548703         0.008186288
#> 5  2003      N1P0       N2P3       0.10783624         0.030544559
#> 6  2003      N2P0       N2P3       0.17232900         0.038730848
#> 7  2004      N1P0       N2P0       0.14521928         0.066055250
#> 8  2004      N1P0       N2P3       0.29875868         0.013209995
#> 9  2004      N2P0       N2P3       0.22255134         0.079265246
#> 10 2005      N1P0       N2P0       0.22363491         0.007121622
#> 11 2005      N1P0       N2P3       0.29970588         0.070916786
#> 12 2005      N2P0       N2P3       0.16573085         0.063795164
#>    trt_greater_disp
#> 1              N2P0
#> 2              N2P3
#> 3              N2P3
#> 4              N2P0
#> 5              N1P0
#> 6              N2P0
#> 7              N1P0
#> 8              N2P3
#> 9              N2P3
#> 10             N2P0
#> 11             N2P3
#> 12             N2P3
# In each year there are 6 replicates for each of three treatments, for a
# total of 18 observations.