Rao: Rao's index of quadratic entropy (Q)

View source: R/Rao.R

RaoR Documentation

Rao's index of quadratic entropy (Q)

Description

Deprecated, use paRao(..., alpha=1). Computes Rao's index of quadratic entropy (Q) on different classes of numeric matrices using a moving window algorithm.

Usage

Rao(x, dist_m="euclidean", window=9, rasterOut = TRUE,
 mode="classic",lambda=0, shannon=FALSE, rescale=FALSE,
 na.tolerance=1.0, simplify=2, np=1, cluster.type="SOCK", 
 debugging=FALSE)
 

Arguments

x

input data may be a matrix, a Spatial Grid Data Frame, a RasterLayer or a list of these objects. In the latter case, if mode="classic" only the first element of the list will be considered.

dist_m

define the type of distance to be calculated between numerical categories. dist_m can be a character string which defines the name of the distance to derive such as "euclidean". The distance names allowed are the same as for proxy::dist. Alternatively, dist_m can be a function which calculates an user defined distance, (i.e., function(x,y) {return(cos(y-x)-sin(y-x))}) or a matrix of distances. If mode="multidimension" then only "euclidean", "manhattan", "canberra", "minkowski" and "mahalanobis" can be used. Default value is "euclidean".

window

the side of the square moving window, it must be a odd numeric value greater than 1 to ensure that the target pixel is in the centre of the moving window. Default value is 3. If proxy::dist is a matrix then the function will assume that this is the distance matrix, and therefore no distance will be derived.

rasterOut

Boolean, if TRUE the output will be in RasterLayer format with x as template.

mode

currently, there are two modes to calculate Rao's index. If mode is "classic", then the classic Rao's index will be calculated on one single matrix. If mode is "multidimension" (experimental!) a list of matrices must be provided as input. In this latter case, the overall distance matrix will be calculated in a multi- or hyper-dimensional system by using the measure defined through the function argument dist_m. Each pairwise distance is then multiplied by the inverse of the squared number of pixels in the considered moving window, and the Rao's Q is finally derived by applying a summation. Default value is "classic".

lambda

the value of the lambda of Minkowski's distance. Considered only if dist_m = "minkowski" and mode="multidimension". Default value is 0.

shannon

a boolean variable set to FALSE by default. If TRUE, a matrix with Shannon index will be also calculated. Default value is FALSE.

rescale

a boolean variable set to FALSE by default. If TRUE, x will be scaled and centred to standardise different matrices if mode is "multidimension". Default value is FALSE.

na.tolerance

a numeric value (0.0-1.0) which indicates the proportion of NA values that will be tolerated to calculate Rao's index in each moving window over x. If the relative proportion of NA's in a moving window is bigger than na.tolerance, then the value of the window will be set as NA, otherwise Rao's index will be calculated considering the non-NA values. Default values is 1.0 (i.e., full tolerance for NA's).

simplify

Number of decimal places to be retained to calculate distances in Rao's index. Only if x is floats.

np

the number of processes (cores) which will be spawned. Default value is 1.

cluster.type

the type of cluster which will be created. The options are "MPI" (which calls "makeMPIcluster"), "FORK" and "SOCK" (which call "makeCluster"). Default type is "SOCK".

debugging

a boolean variable set to FALSE by default. If TRUE, additional messages will be printed. For debugging only.

Details

Classical Rao's Index (Q) is calculated on a numerical matrix as Q = ∑_{i=1}^{R}{∑_{j=1}^{R}{d_{i,j}\times{p_i}\times{p_j}}} [1]. Where R is the number of categories, whereas i and j are pair of numerical categories in the same moving window. In the "multidimension" Rao's index, distances among categories are calculated considering more than one layer, then the pairwise distance between each pair of numerical categories is multiplied to the square of the size of the moving window (which is somewhat the same as to calculate the variance of the multidimensional distance [2].).
The theoretical minimum of Rao's Q is 0, when all categories in a window have distance 0. If the distance chosen to calculate Rao's Index ranges between 0 and 1, the maximum value of Rao's Index equals the Simpson Index of Diversity 1-1/S_i where S is the number of categories in window i.

Value

If shannon=TRUE, a list of matrices of length two, otherwise a matrix of dimension dim(x).

Author(s)

Matteo Marcantonio marcantoniomatteo@gmail.com
Duccio Rocchini duccio.rocchini@unibo.it

References

[1] Rao, C.R. (1982). Diversity and dissimilarity coefficients: a unified approach. Theoretical Population Biology, 21: 2443. [2] Rocchini, D., M. Marcantonio, and C. Ricotta (2017). Measuring Rao’s Q diversity index from remote sensing: An open source solution. Ecological Indicators. 72: 234–238.

Examples

# Minimal example; compute Rao's index 
 ## Not run: 
  a <- matrix(c(10,10,10,20,20,20,20,30,30),ncol=3,nrow=3)
  out <- Rao(x=a,window=3,dist_m="euclidean",na.tolerance=1.0,shannon=FALSE,mode="classic")

# Compute both Rao and Shannon index 
  out <- Rao(x=a,window=3,dist_m="euclidean",na.tolerance=1.0,shannon=TRUE,mode="classic")

# Compute both Rao and Shannon index multiple windows
  out <- Rao(x=a,window=c(3,5),dist_m="euclidean",na.tolerance=1.0,shannon=TRUE,mode="classic")

# Compute multidimension Rao's index rescaling the input matrices
  a <- matrix(c(10,10,10,20,20,20,20,30,30),ncol=3,nrow=3)
  b <- matrix(c(0.5,0.5,0.1,0.1,0.3,0.3,0.3,0.3,0.3),ncol=3,nrow=3)
  out <- Rao(x=list(a,b),window=3,dist_m="euclidean",na.tolerance=1.0,
    mode="multidimension",rescale=TRUE,debugging=TRUE)

## End(Not run)

rasterdiv documentation built on Nov. 24, 2022, 9:07 a.m.