funs.scct | R Documentation |
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 \insertCiteceyhan:NNCorrespond2018;textualnnspat 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).
scct.ct(x, lab = NULL, ties = FALSE, nnct = FALSE)
scct(dat, lab, ties = FALSE, ...)
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 |
Returns the k \times 2
SCCT where k
is the number of classes in the data set.
Elvan Ceyhan
nnct
, tct
, rct
and Qsym.ct
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.