View source: R/NNCTFunctions.r
nnct.boot.dis | R Documentation |
Returns the k \times k NNCT with sampling replacement of the points for each base point. That is, for each base point, the rows in the IPD matrix are sampled with replacement and the NN counts are updated accordingly. Row and columns of the NNCT are labeled with the corresponding class labels.
The argument self is a logical argument (default=TRUE
) for including the base point in the resampling or not.
If TRUE
, for each base point all entries in the row are sampled (with replacement) so the point itself can
also be sampled multiple times and if FALSE
the point is excluded from the resampling (i.e. other points
are sampled with replacement).
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.
nnct.boot.dis(x, lab, self = TRUE, ties = TRUE, is.ipd = TRUE, ...)
x |
The IPD matrix (if |
lab |
The |
self |
A logical argument (default= |
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 with sampling replacement of the rows of the IPD matrix.
Elvan Ceyhan
nnct
and nnct.sub
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.boot.dis(ipd,cls) nnct.boot.dis(Y,cls,is.ipd = FALSE) #may give different result from above due to random sub-sampling nnct.boot.dis(ipd,cls,self = FALSE) nnct.boot.dis(ipd,cls,ties = FALSE) #differences are due to ties and resampling of distances #cls as a factor na<-floor(n/2); nb<-n-na fcls<-rep(c("a","b"),c(na,nb)) nnct.boot.dis(ipd,fcls) #cls as an unsorted factor fcls<-sample(c("a","b"),n,replace = TRUE) nnct.boot.dis(ipd,fcls) fcls<-sort(fcls) nnct.boot.dis(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.boot.dis(ipd,cls) #cls as a factor fcls<-rep(letters[1:4],rep(10,4)) nnct.boot.dis(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.boot.dis(ipd,cls) #cls as a factor na<-floor(n/2); nb<-n-na fcls<-rep(c("a","b"),c(na,nb)) nnct.boot.dis(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.boot.dis(ipd,cls) nnct.boot.dis(ipd,cls,self = FALSE) nnct.boot.dis(ipd,cls,ties = FALSE) #differences are due to ties and resampling of distances
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.