View source: R/oneill_leibovici_entropy.R
parredw | R Documentation |
Compute Parresol and Edwards' entropy, following Parresol and Edwards (2014),
starting from data. References can be found at SpatEntropy
.
parredw(
data,
win = spatstat.geom::owin(xrange = c(0, ncol(data)), yrange = c(0, nrow(data))),
plotout = T
)
data |
A data matrix or vector, can be numeric, factor, character, ... |
win |
Optional, an object of class |
plotout |
Logical. Default to |
This index is based on the transformed variable Z
identifying couples of realizations
of the variable of interest. A distance of interest is fixed: Parresol and Edwards' entropy is
thought for areas sharing a border, as O'Neill's entropy. All contiguous couples
of realizations of the variable of interest are counted
and their relative frequencies are used to compute the index, which is the opposite of O'Neill's entropy.
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.
a list of four elements:
parredw
Parresol and Edwards' entropy
range
the theoretical range of Parresol and Edwards' entropy, from -\log(I^2)
to 0
rel.parredw
Parresol and Edwards' relative entropy (with the same interpretation as 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.
#numeric data, square grid
data=matrix(sample(1:5, 100, replace=TRUE), nrow=10)
parredw(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)
parredw(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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.