rct: Reflexivity Contingency Table (RCT)

View source: R/NNCTFunctions.R

rctR Documentation

Reflexivity Contingency Table (RCT)

Description

Returns the RCT given the IPD matrix or data set x, the RCT is 2 \times 2 regardless of the number of classes in the data set.

RCT is constructed by categorizing the NN pairs according to pair type as self or mixed and whether the pair is reflexive or non-reflexive. A base-NN pair is called a reflexive pair, if the elements of the pair are NN to each other; a non-reflexive pair, if the elements of the pair are not NN to each other; a self pair, if the elements of the pair are from the same class; a mixed pair, if the elements of the pair are from different classes. Row labels in the RCT are "ref" for reflexive and "non-ref" for non-reflexive and column labels are "self" and "mixed".

The argument is.ipd is a logical argument (default=TRUE) to determine the structure of the argument x. If TRUE, x is taken to be the inter-point distance (IPD) matrix, and if FALSE, x is taken to be the data set with rows representing the data points.

See also (\insertCiteceyhan:NNreflexivity2017,ceyhan:NNreflex1D2018;textualnnspat) and the references therein.

Usage

rct(x, lab, is.ipd = TRUE, ...)

Arguments

x

The IPD matrix (if is.ipd=TRUE) or a data set of points in matrix or data frame form where points correspond to the rows (if is.ipd = FALSEALSE).

lab

The vector of class labels (numerical or categorical)

is.ipd

A logical parameter (default=TRUE). If TRUE, x is taken as the inter-point distance matrix, otherwise, x is taken as the data set with rows representing the data points.

...

are for further arguments, such as method and p, passed to the dist function.

Value

Returns the 2 \times 2 RCT, see the description above for more detail.

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

nnct, tct and scct

Examples

n<-20  #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
cls<-sample(1:2,n,replace = TRUE)  #or try cls<-rep(1:2,c(10,10))
ipd<-ipd.mat(Y)

rct(ipd,cls)
rct(Y,cls,is.ipd = FALSE)
rct(Y,cls,is.ipd = FALSE,method="max")

#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
rct(ipd,fcls)

#############
n<-40
Y<-matrix(runif(3*n),ncol=3)
cls<-sample(1:4,n,replace = TRUE)  #or try cls<-rep(1:2,c(10,10))
ipd<-ipd.mat(Y)

rct(ipd,cls)


nnspat documentation built on Aug. 30, 2022, 9:06 a.m.