Description Usage Arguments Value Author(s) See Also Examples

Two functions: `kthNNdist`

and `kNNdist`

.

`kthNNdist`

returns the distances between subjects and their *k^{th}* NNs. The output is an *n \times 2* matrix where
*n* is the data size and first column is the subject index and second column contains the corresponding
distances to *k^{th}* NN subjects.

`kNNdist`

returns the distances between subjects and their `k`

NNs.
The output is an *n \times (k+1)* matrix where
*n* is the data size and first column is the subject index and the remaining `k`

columns contain the corresponding
distances to `k`

NN subjects.

1 2 3 |

`x` |
The IPD matrix (if |

`k` |
Integer specifying the number of NNs (of subjects). |

`is.ipd` |
A logical parameter (default= |

`...` |
are for further arguments, such as |

`kthNNdist`

returns an *n \times 2* matrix where *n* is data size (i.e. number of subjects) and
first column is the subject index and second column is the *k^{th}* NN distances.

`kNNdist`

returns an *n \times (k+1)* matrix where *n* is data size (i.e. number of subjects) and
first column is the subject index and the remaining `k`

columns contain the corresponding
distances to `k`

NN subjects.

Elvan Ceyhan

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ```
#Examples for kthNNdist
#3D data points, gives NAs when n<=k
n<-20 #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
kthNNdist(ipd,3)
kthNNdist(Y,3,is.ipd = FALSE)
kthNNdist(ipd,5)
kthNNdist(Y,5,is.ipd = FALSE)
kthNNdist(Y,3,is.ipd = FALSE,method="max")
#1D data points
X<-as.matrix(runif(5)) # need to be entered as a matrix with one column
#(i.e., a column vector), hence X<-runif(5) would not work
ipd<-ipd.mat(X)
kthNNdist(ipd,3)
#Examples for kNNdist
#3D data points, gives NAs if n<=k for n,n+1,...,kNNs
n<-20 #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
kNNdist(ipd,3)
kNNdist(ipd,5)
kNNdist(Y,5,is.ipd = FALSE)
kNNdist(Y,5,is.ipd = FALSE,method="max")
kNNdist(ipd,1)
kthNNdist(ipd,1)
#1D data points
X<-as.matrix(runif(5)) # need to be entered as a matrix with one column
#(i.e., a column vector), hence X<-runif(5) would not work
ipd<-ipd.mat(X)
kNNdist(ipd,3)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.