macroeco.empirical.comm_grid(patch, cols, splits, divs, metric='Sorensen')

Calculates commonality as a function of distance for a gridded patch


patch : Patch obj

Patch object containing data for analysis

cols : str

Indicates which column names in patch data table are associated with species identifiers, counts, energy, and mass. See Notes.

splits : str

If multiple analyses for subsets of patch data table are desired, specifies how columns should be split. See Notes.

divs : str

Description of how to divide x_col and y_col. Unlike SAR and EAR, only one division can be given at a time. See notes.

metric : str

One of Sorensen or Jaccard, giving the metric to use for commonality calculation


list :

List of tuples containing results, where the first element of each tuple is a string indicating the split values used for that result and second element is a dataframe giving the result. Result has three columns, pair, x, and y, that give the locations of

the pair of patches for which commonality is calculated, the distance :

between those cells, and the Sorensen or Jaccard result. :


The parameter cols is a string describing which column in the data table should be used for which “special columns” in analysis. The five possible special columns are

  • spp_col - Unique species identifiers
  • count_col - Number of individuals at a location
  • x_col - x coordinate of location
  • y_col - y coordinate of location
  • energy_col - Energetic requirements of individual(s) at a location

For example, setting cols to spp_col: spp: count_col: number will use the column named “spp” in the data table to represent the unique species identifiers, and the column “number” in the data table to represent the count of individuals at a point.

Different special columns are required for different analyses. count_col is used when multiple individuals of a species may be found at a single recorded location, as is the case in gridded censuses where all individuals in a quadrat are “assigned” to a single point. If count_col is not specified, each record in the data table will be presumed to represent a single individual (i.e., a count of 1).

Note that the value of spp_col may be set to a columm in the data table giving the genus, family, functional group, etc., which allows for analysis of this metric by those groups.

For gridded commonality, cols must also contain x_col and y_col, giving the x and y dimensions along which to grid the patch.

The parameter splits is a semicolon-separated string in the form of “column: value”, where column is a name of a column in the patch data table and value is either (a) an integer giving the number of equally-spaced divisions of a column, or (b) the special keyword ‘split’, which evaluates all unique levels of a column.

For example, presume a data table has columns for x and y spatial coordinates and a column for year, of which there are three. The string “x:2; y:2; year:split” will perform the analysis separately for each of four subplots of the patch (created by dividing the x and y coordinates each into two equally sized divisions) within each of the three years, for a total of 12 separate analyses. Note that if you pass in the x split you MUST also pass in a y split (even if it is just “y:1”) or vice versa. Otherwise, the computed areas will be incorrect.