Qsym.ct {nnspat} | R 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 (Pielou (1961); Ceyhan (2014)) and the references therein.
Usage
Qsym.ct(x, lab, is.ipd = TRUE, ...)
Arguments
x |
The IPD matrix (if |
lab |
The |
is.ipd |
A logical parameter (default= |
... |
are for further arguments, such as |
Value
Returns the k \times 3
QCT where k
is the number of classes in the data set.
Author(s)
Elvan Ceyhan
References
Ceyhan E (2014).
“Testing Spatial Symmetry Using Contingency Tables Based on Nearest Neighbor Relations.”
The Scientific World Journal, Volume 2014, Article ID 698296.
Pielou EC (1961).
“Segregation and symmetry in two-species populations as studied by nearest-neighbor relationships.”
Journal of Ecology, 49(2), 255-269.
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)