Qsym.ct: Q-symmetry Contingency Table (QCT)

View source: R/NNCTFunctions.R

Qsym.ctR Documentation

Q-symmetry Contingency Table (QCT)

Description

Returns the k \times 3 contingency table for Q-symmetry (i.e., Q-symmetry contingency table (QCT)) given the IPD matrix or data set x where k is the number of classes in the data set. Each row in the QCT is the vector of number of points with shared NNs, Q_i=(Q_{i0},Q_{i1},Q_{i2}) where Q_{ij} is the number of class i points that are NN to class j points for j=0,1 and Q_{i2} is the number of class i points that are NN to class j or more points. That is, this function pools the cells 3 or larger together for k classes, so, Q_2, Q_3 etc. are pooled, so, the column labels are Q_0, Q_1 and Q_2 with the last one is actually sum of Q_j for j \ge 2. Rows the QCT are labeled with the corresponding class labels.

Q-symmetry is also equivalent to Pielou's second type of NN symmetry or the symmetry in the shared NN structure for all classes.

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 (\insertCitepielou:1961,ceyhan:SWJ-spat-sym2014;textualnnspat) and the references therein.

Usage

Qsym.ct(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 = FALSE).

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 k \times 3 QCT where k is the number of classes in the data set.

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

sharedNNmc, Qsym.test and scct

Examples

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

Qsym.ct(ipd,cls)
Qsym.ct(Y,cls,is.ipd = FALSE)
Qsym.ct(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))
Qsym.ct(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)

Qsym.ct(ipd,cls)


nnspat documentation built on May 29, 2024, 10:03 a.m.