multivariate_difference: Using dissimilarity-based measures to calculate differences...

Description Usage Arguments Value References Examples

View source: R/multivariate_change_and_difference.R

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

1
2
3
4
5
6
7
8
9
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:

References

Avolio et al. Submitted, Avolio et al. 2015, Marti Anderson et al. 2006

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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.

Example output

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             N1P0
7      N1P0       N2P3       0.09985185          0.04426276             N1P0
8      N2P0       N2P3       0.15244281          0.03302294             N2P0
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             N1P0
2      N1P0       N2P3       0.09985185          0.04426276             N1P0
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              N1P0
2              N1P0
3              N2P0
4              N1P0
5              N2P3
6              N2P3
7              N2P0
8              N1P0
9              N2P0
10             N1P0
11             N1P0
12             N2P0

codyn documentation built on Dec. 1, 2020, 9:09 a.m.