SpatEntropy (version 0.1.0)

shannonZ: Shannon's entropy of the transformed variable \(Z\).

Description

This function computes Shannon's entropy of variable \(Z\), where \(Z\) identifies pairs of realizations of the variable of interest.

Usage

shannonZ(data, missing.cat = NULL)

Arguments

data

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

missing.cat

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

Value

Estimated probabilities for all \(Z\) categories (data pairs), and Shannon's entropy of \(Z\).

Details

Many spatial entropy indices are based on the trasformation \(Z\) of the study variable, i.e. on pairs (unordered couples) of realizations of the variable of interest. 'Unordered couples' 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\). When all possible pairs occurring within the observation areas are considered, Shannon's entropy of the variable \(Z\) may be computed as $$H(Z)=\sum p(z_r)\log(1/p(z_r))$$ where \(p(z_r)\) is the probability of the \(r\)-th pair of realizations, here estimated by its relative frequency. Shannon's entropy of \(Z\) varies between 0 and \(\log(R)\), \(R\) being the number of possible pairs of categories of the variable under study.

Examples

Run this code
# NOT RUN {
#NON SPATIAL DATA
shannonZ(sample(1:5, 50, replace=TRUE))

#POINT DATA
data.pp=runifpoint(100, win=square(10))
marks(data.pp)=sample(c("a","b","c"), 100, replace=TRUE)
shannonZ(marks(data.pp))

#LATTICE DATA
data.lat=matrix(sample(c("a","b","c"), 100, replace=TRUE), nrow=10)
shannonZ(data.lat)

#when categories are missing
shannonZ(data.lat, missing.cat=c("d", "e"))

# }

Run the code above in your browser using DataCamp Workspace