View source: R/NNCTFunctions.r
nnct | R Documentation |
Returns the k \times k NNCT given the IPD matrix or data set x
where k is
the number of classes in the data set.
Rows and columns of the NNCT are labeled with the corresponding class labels.
The argument ties
is a logical argument (default=FALSE
) 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 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 (\insertCitedixon:1994,dixon:NNCTEco2002,ceyhan:eest-2010,ceyhan:jkss-posthoc-2017;textualnnspat) and the references therein.
nnct(x, lab, ties = FALSE, is.ipd = TRUE, ...)
x |
The IPD matrix (if |
lab |
The |
ties |
A logical argument (default= |
is.ipd |
A logical parameter (default= |
... |
are for further arguments, such as |
Returns the k \times k NNCT where k is the number of classes in the data set.
Elvan Ceyhan
nnct.sub
, scct
, rct
, and tct
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(ipd,cls) nnct(ipd,cls,ties = TRUE) nnct(Y,cls,is.ipd = FALSE) nnct(Y,cls,is.ipd = FALSE,method="max") nnct(Y,cls,is.ipd = FALSE,method="mink",p=6) #with one class, it works but really uninformative cls<-rep(1,n) nnct(ipd,cls) #cls as a factor na<-floor(n/2); nb<-n-na fcls<-rep(c("a","b"),c(na,nb)) nnct(ipd,fcls) #cls as an unsorted factor fcls1<-sample(c("a","b"),n,replace = TRUE) nnct(ipd,fcls1) fcls2<-sort(fcls1) nnct(ipd,fcls2) #ipd needs to be sorted as well, otherwise this result will not agree with fcls1 nnct(Y,fcls1,ties = TRUE,is.ipd = FALSE) ############# 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(ipd,cls) nnct(Y,cls,is.ipd = FALSE) #cls as a factor fcls<-rep(letters[1:4],rep(10,4)) nnct(ipd,fcls) #1D data points n<-20 #or try sample(1:20,1) X<-as.matrix(runif(n))# need to be entered as a matrix with one column #(i.e., a column vector), hence X<-runif(n) would not work ipd<-ipd.mat(X) cls<-sample(1:2,n,replace = TRUE) #or try cls<-rep(1:2,c(10,10)) nnct(ipd,cls) #cls as a factor na<-floor(n/2); nb<-n-na fcls<-rep(c("a","b"),c(na,nb)) nnct(ipd,fcls) #with possible ties in the data Y<-matrix(round(runif(3*n)*10),ncol=3) ipd<-ipd.mat(Y) cls<-sample(1:2,n,replace = TRUE) #or try cls<-rep(1:2,c(10,10)) nnct(ipd,cls) nnct(ipd,cls,ties = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.