SpatEntropy (version 0.1.0)

pair_count: Build pairs (unordered couples) in a dataset.

Description

This function builds and counts the number of all types of pairs in a data vector or matrix, according to a chosen adjacency matrix.

Usage

pair_count(data, adj.mat, missing.cat = NULL)

Arguments

data

A matrix or vector, can be numeric, factor, character... If the dataset is a point pattern, data is the mark vector.

adj.mat

An adjacency matrix, upper- or lower-triangular. Provided by user or generated by adj_mat().

missing.cat

Optional, a vector with the names of all categories that are absent in data.

Value

The number of pairs, and a table with absolute and relative frequencies for each pair of categories.

Details

This function needs a data matrix or data vector of any type (numeric, factor, character, ...), and an adjacency matrix as generated by adj_mat(). It returns all the data pairs identified by the adjacency matrix, i.e. occurring at the chosen neighbourhood distance. Relative and absolute frequencies for all possible pairs are returned, and may be used for computation of spatial entropy at the chosen distance range. 'Unordered couple', i.e. 'pair', means that the relative spatial location is irrelevant, i.e. that a couple where category \(i\) occurs at the left of category \(j\) is identical to a couple where category \(j\) occurs at the left of category \(i\).

Examples

Run this code
# NOT RUN {
dist.mat=euclid_dist(cbind(rep(1:5, each=5), rep(1:5,5)))
adj.mat=adj_mat(dist.mat, dd1=dist.mat[1,2]) #for the contiguity matrix
pair_count(sample(1:3, 25, replace=TRUE), adj.mat)

# }

Run the code above in your browser using DataLab