Learn R Programming

vegclust (version 1.7.1)

trajectories: Community trajectory analysis

Description

Given a distance matrix between community states, functions segmentDistances and trajectoryDistances calculate the distance between pairs of directed segments and community trajectories, respectively. Function trajectoryLengths calculates lengths of directed segments and complete trajectories. Function trajectoryPCoA performs principal coordinates analysis (cmdscale) and draws trajectories in the ordination scatterplot.

Usage

segmentDistances(d, sites, surveys = NULL,
  distance.type = "directed-segment", verbose = FALSE)

trajectoryDistances(d, sites, surveys = NULL, distance.type = "DSPD", symmetrization = "mean", verbose = FALSE)

trajectoryLengths(d, sites, surveys = NULL, verbose = FALSE)

trajectoryPCoA(d, sites, surveys = NULL, selection = NULL, traj.colors = NULL, axes = c(1, 2), ...)

Arguments

d

A symmetric matrix or an object of class dist containing the distance values between pairs of community states.

sites

A vector indicating the site corresponding to each community state.

surveys

A vector indicating the survey corresponding to each community state (only necessary when surveys are not in order).

distance.type

The type of distance index to be calculated (Besse et al. 2016; De C<U+00E1>ceres et al. submitted). For segmentDistances the available indices are:

  • Hausdorff: Hausdorff distance between two segments.

  • directed-segment: Directed segment distance (default).

  • PPA: Perpendicular-parallel-angle distance.

whereas for trajectoryDistances the available indices are:

  • Hausdorff: Hausdorff distance between two trajectories.

  • SPD: Segment path distance.

  • DSPD: Directed segment path distance (default).

verbose

Provides console output informing about process (useful for large dataset).

symmetrization

Function used to obtain a symmetric distance, so that DSPD(T1,T2) = DSPD(T2,T1) (e.g., mean or min).

selection

A numeric or logical vector of the same length as sites, indicating a subset of site trajectories to be plotted.

traj.colors

A vector of colors (one per site). If selection != NULL the length of the color vector should be equal to the number of sites selected.

axes

The pair of principal coordinates to be plotted.

...

Additional parameters for function arrows.

Value

Function trajectoryDistances returns an object of class dist containing the distances between trajectories. Function trajectorySegments returns a list with the following elements:

  • Dseg: Distance matrix between segments.

  • Dini: Distance matrix between initial points of segments.

  • Dfin: Distance matrix between final points of segments.

  • Dinifin: Distance matrix between initial points of one segment and the final point of the other.

  • Dfinini: Distance matrix between final points of one segment and the initial point of the other.

Function trajectoryLengths returns a data frame with the length of each segment on each trajectory and the total length of all trajectories. Function trajectoryPCoA returns the result of calling cmdscale.

Details

These functions consider community dynamics as trajectories in a chosen space of community resemblance and takes trajectories as objects to be compared. By adapting concepts and procedures used for the analysis of trajectories in space (i.e. movement data) (Besse et al. 2016), the functions allow assessing the resemblance between trajectories. Details of calculations are given in De C<U+00E1>ceres et al (submitted)

References

Besse, P., Guillouet, B., Loubes, J.-M. & Fran<U+00E7>ois, R. (2016). Review and perspective for distance based trajectory clustering. IEEE Trans. Intell. Transp. Syst., 17, 3306<U+2013>3317.

De C<U+00E1>ceres M, Coll L, Legendre P, Allen RB, Wiser SK, Fortin MJ, Condit R & Hubbell S. (submitted). Trajectory analysis in community ecology.

See Also

cmdscale

Examples

Run this code
# NOT RUN {
  #Description of sites and surveys
  sites = c(1,1,1,2,2,2)
  surveys=c(1,2,3,1,2,3)
  
  #Raw data table
  xy<-matrix(0, nrow=6, ncol=2)
  xy[2,2]<-1
  xy[3,2]<-2
  xy[4:6,1] <- 0.5
  xy[4:6,2] <- xy[1:3,2]
  xy[6,1]<-1
  
  #Distance matrix
  d = dist(xy)
  d
  
  trajectoryLengths(d, sites, surveys)
  segmentDistances(d, sites, surveys)$Dseg
  trajectoryDistances(d, sites, surveys, distance.type = "Hausdorff")
  trajectoryDistances(d, sites, surveys, distance.type = "DSPD")
  
  #Draw trajectories
  trajectoryPCoA(d, sites, traj.colors = c("black","red"), lwd = 2)
  
  
  #Should give the same results if surveys are not in order 
  #(here we switch surveys for site 2)
  temp = xy[5,]
  xy[5,] = xy[6,]
  xy[6,] = temp
  surveys[5] = 3
  surveys[6] = 2
  trajectoryLengths(dist(xy), sites, surveys)
  segmentDistances(dist(xy), sites, surveys)$Dseg
  trajectoryDistances(dist(xy), sites, surveys, distance.type = "Hausdorff")
  trajectoryDistances(dist(xy), sites, surveys, distance.type = "DSPD")
 
# }

Run the code above in your browser using DataLab