oneill {SpatEntropy} | R Documentation |
O'Neill's entropy.
Description
This function computes O'Neill's entropy for a data matrix (see O'Neill et al, 1988).
Usage
oneill(
data,
win = spatstat.geom::owin(xrange = c(0, ncol(data)), yrange = c(0, nrow(data))),
plotout = T
)
Arguments
data |
A data matrix, can be numeric, factor, character, ... |
win |
Optional, an object of class |
plotout |
Logical. Default to |
Details
O'Neill's entropy index is based on the transformed variable , identifying couples of realizations
of the variable of interest:
where is a generic couple of realizations of the study variable
.
The conditioning on
for grid data means that only contiguous couples are considered, i.e.
couples of pixels sharing a border.
All contiguous couples of realizations of the variable of interest are counted
and their relative frequencies are used to compute the index. The maximum value for O'Neill's entropy is
where
is the number of categories of
. The relative version of O'Neill's entropy
is obtained by dividing the entropy value by its maximum, and is useful for comparison across datasets with
a different number of categories.
The function is able to work with grids containing missing data, specified as NA values.
All NAs are ignored in the computation and only couples of non-NA observations are considered.
Value
a list of four elements:
-
oneill
O'Neill's entropy -
range
the theoretical range of O'Neill's entropy, from 0 to rel.oneill
O'Neill's relative entropy-
probabilities
a table with absolute frequencies and estimated probabilities (relative frequencies) for all couple categories
Moreover, a plot of the dataset is produced.
Examples
#numeric data, square grid
data=matrix(sample(1:5, 100, replace=TRUE), nrow=10)
oneill(data)
#plot data
plot(as.im(data, W=square(nrow(data))),
col=grDevices::gray(seq(1,0,length.out=length(unique(c(data))))),
main="", ribbon=TRUE)
#character data, rectangular grid
data=matrix(sample(c("a","b","c"), 300, replace=TRUE), nrow=30)
oneill(data)
#plot data
plot(as.im(data, W=owin(xrange=c(0,ncol(data)), yrange=c(0,nrow(data)))),
col=terrain.colors(length(unique(c(data)))),
main="", ribbon=TRUE)
#data with missing values
data=matrix(sample(1:5, 100, replace=TRUE), nrow=10)
data=rbind(rep(NA, ncol(data)), data, rep(NA, ncol(data)))
oneill(data)