| funs.scct {nnspat} | R Documentation |
Species Correspondence Contingency Table (SCCT)
Description
Two functions: scct.ct and scct.
Both functions return the k \times 2 species correspondence contingency table (SCCT)
but have different arguments (see the parameter list below).
SCCT is constructed by categorizing the NN pairs according to pair type as self or mixed.
A base-NN pair is called 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 the class labels and the column labels are "self" and "mixed".
The k \times 2 SCCT (whose first column is self column with entries S_i and second column is mixed with entries M_i)
is closely related to the k \times k nearest neighbor contingency table (NNCT) whose entries are N_{ij},
where S_i=N_{ii} and M_i=n_i-N_{ii} with n_i is the size of class i.
The function scct.ct returns the SCCT given the inter-point distance (IPD) matrix or data set x,
and the function scct returns the SCCT given the IPD matrix. SCCT is a k \times 2 matrix where k is
number of classes in the data set.
(See Ceyhan (2018) for more detail,
where SCCT is labeled as CCT for correspondence contingency table).
The argument ties is a logical argument (default=FALSE for both functions) to take ties into account or not.
If TRUE a NN contributes 1/m to the NN count if it is one of the m tied NNs of a subject.
The argument nnct is a logical argument for scct.ct only (default=FALSE) to determine the structure of the
argument x. If TRUE, x is taken to be the k \times k NNCT, and if FALSE, x is taken to be the IPD matrix.
The argument lab is the vector of class labels (default=NULL when nnct=TRUE in the function scct.ct and no default
specified for scct).
Usage
scct.ct(x, lab = NULL, ties = FALSE, nnct = FALSE)
scct(dat, lab, ties = FALSE, ...)
Arguments
x |
The IPD matrix (if |
lab |
The |
ties |
A logical argument (default= |
nnct |
A logical parameter (default= |
dat |
The data set in one or higher dimensions, each row corresponds to a data point,
used in |
... |
are for further arguments, such as |
Value
Returns the k \times 2 SCCT where k is the number of classes in the data set.
Author(s)
Elvan Ceyhan
References
Ceyhan E (2018). “A contingency table approach based on nearest neighbor relations for testing self and mixed correspondence.” SORT-Statistics and Operations Research Transactions, 42(2), 125-158.
See Also
Examples
n<-20 #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
cls<-sample(1:2,n,replace = TRUE) #or try cls<-rep(1:2,c(10,10))
NNCT<-nnct(ipd,cls)
NNCT
scct(Y,cls)
scct(Y,cls,method="max")
scct.ct(ipd,cls)
scct.ct(ipd,cls,ties = TRUE)
scct.ct(NNCT,nnct=TRUE)
#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
scct.ct(ipd,fcls)
#############
n<-40
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
cls<-sample(1:4,n,replace = TRUE) #or try cls<-rep(1:2,c(10,10))
NNCT<-nnct(ipd,cls)
NNCT
scct(Y,cls)
scct.ct(ipd,cls)
scct.ct(NNCT,nnct=TRUE)