shannonZ | R Documentation |
Z
.This function computes Shannon's entropy of variable Z
,
where Z
identifies pairs of realizations of the variable of interest.
shannonZ(data)
data |
A data matrix or vector, can be numeric, factor, character, ...
Alternatively, a marked |
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=binom(n+1,2)
(where n
is the number of observations) being the
number of possible pairs of categories of the variable under study.
The function is able to work with lattice data with missing data, as long as they are specified as NAs:
missing data are ignored in the computations.
a list of three elements:
shannZ
Shannon's entropy of Z
range
The theoretical range of Shannon's entropy of Z
,
from 0 to \log(R)
rel.shannZ
Shannon's relative entropy of Z
probabilities
a table with absolute frequencies and estimated probabilities (relative frequencies) for all Z
categories (data pairs)
#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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.