karlstrom {SpatEntropy} | R Documentation |
Karlstrom and Ceccato's entropy.
Description
This function computes Karlstrom and Ceccato's spatial entropy for a
chosen neighbourhood distance,
following Karlstrom and Ceccato (2002), see also Altieri et al (2017) and following works
(references are under the topic SpatEntropy
).
Usage
karlstrom(
data,
category = 1,
cell.size = 1,
partition = 10,
win = NULL,
neigh = 4,
method = "number",
plotout = T
)
battyLISA(
data,
category = 1,
cell.size = 1,
partition = 10,
win = NULL,
neigh = 4,
method = "number",
plotout = T
)
Arguments
data |
If data are lattice, a data matrix, which can be numeric, factor, character, ...
If the dataset is a point pattern, |
category |
A single value matching the data category of interest for computing Batty's entropy. Default to 1. If the dataset is an unmarked point pattern, this argument must not be changed from the default. |
cell.size |
A single number or a vector of length two, only needed if data are lattice. It gives the length of the side of each pixel; if the pixel is rectangular, the first number gives the horizontal side and the second number gives the vertical side. Default to 1. Ignored if data are points. |
partition |
Input defining the partition into subareas. If an integer, it defines the
number of sub-areas that are randomly generated by areapart; if a two column matrix
with coordinates, they are the centroids of the subareas built by areapart. Alternatively,
it can be the output of areapart, a |
win |
Optional, the observation area given as a |
neigh |
A single number. It can be either the number of neighbours for each sub-area (including the area itself). or the Euclidean distance to define which sub-areas are neighbours, based on their centroids. Default to 4 neighbours. |
method |
Character, it guides the interpretation of |
plotout |
Logical. Default to |
Details
Karlstrom and Ceccato's spatial entropy measures the heterogeneity in the spatial distribution
of a phenomenon of interest, with regard to an area partition and accounting for the neighbourhood.
It is similar to Batty's entropy (see batty) discarding the sub-area size,
with the difference that the probability of occurrence of the phenomenon over area g
is actually a weighted sum of the neighbouring probabilities.
H_{KC}=\sum p_g \log(1/ \tilde{p}_g)
where p_g
is the probability of occurrence of the phenomenon over sub-area g
,
and \tilde{p}_g
is the averaged probability over the neighbouring areas (including the g-th area itself).
When data are categorical, the phenomenon of interest corresponds to
one category, which must be specified. If data are an unmarked
point pattern, a fake mark vector is be created with the same category for all points.
For comparison purposes, the relative version of Karlstrom and Ceccato's entropy is also returned, i.e.
Karlstrom and Ceccato's entropy divided by its maximum log(number of sub-areas).
The function is able to work with grids containing missing data, specified as NA values.
All NAs are ignored in the computation.
Value
A list of five elements:
-
karlstrom
Karlstrom and Ceccato's entropy -
range
The theoretical range of Karlstrom and Ceccato's entropy -
rel.karl
Karlstrom and Ceccato's entropy divided by\log(G)
(number og sub-areas) for comparison across observation areas. -
areas
a dataframe giving, for each sub-area, the absolute and relative frequency of the points/pixels of interest, the weighted probabilities of the neighbours and the sub-area size -
area.tess
atess
object with the area partition
Moreover, a plot is produced showing the data and the area partition.
Examples
#LATTICE DATA
data=matrix((sample(c("a","b","c"), 100, replace=TRUE)), nrow=10)
KC.entropy=karlstrom(data, category="a")
KC.entropy=karlstrom(data, category="a", neigh=3.5, method="distance")
##to plot
data.binary=matrix(as.numeric(data=="a"), nrow(data))
plot(as.im(data.binary, W=KC.entropy$area.tess$window), main="",
col=grDevices::gray(seq(1,0,l=length(unique(c(data.binary))))), ribbon=FALSE)
plot(KC.entropy$area.tess, add=TRUE, border=2)
#POINT DATA
#unmarked pp
data=ppp(x=runif(100, 0, 10), y=runif(100, 0, 10), window=square(10))
KC.entropy=karlstrom(data)
##to plot
plot(data)
plot(KC.entropy$area.tess, add=TRUE, border=2)
#marked pp
data=ppp(x=runif(100, 0, 10), y=runif(100, 0, 10), window=square(10),
marks=(sample(1:5, 100, replace=TRUE)))
#if you want to compute the entropy on all points
KC.entropy=karlstrom(unmark(data))
#if you want to compute the entropy on a category, say 3
KC.entropy=karlstrom(data, category=3)
##to plot using the selected category
ind=which(spatstat.geom::marks(data)==3)
data.binary=unmark(data[ind])
plot(data.binary)
plot(KC.entropy$area.tess, add=TRUE, border=2)