| funsQandR | R Documentation |
Four functions: Qval, Qvec, sharedNN and Rval.
Qval returns the Q value, the number of points with
shared nearest neighbors (NNs), which occurs when two or
more points share a NN, for data in any dimension.
Qvec returns the Q-value and also yields
the Qv vector Qv=(Q_0,Q_1,\ldots) as well
for data in any dimension,
where Q_j is the number of points shared as
a NN by j other points.
sharedNN returns the vector of number of points
with shared NNs, Q=(Q_0,Q_1,\ldots)
where Q_i is the number of points that are NN to i points,
and if a point is a NN of i points,
then there are i(i-1) points that share a NN.
So, Q=\sum_{i>1} i(i-1)Q_i.
Rval returns the number of reflexive NNs,
R (i.e., twice the number of reflexive NN pairs).
These quantities are used, e.g., in computing the variances
and covariances of the entries of the
nearest neighbor contingency tables used for Dixon's tests
and other NNCT tests.
The input must be the incidence matrix, W, of the NN digraph.
Qval(W)
Qvec(W)
sharedNN(W)
Rval(W)
W |
The incidence matrix, |
The function Qval returns the Q value
The function Qvec returns a list with two elements
q |
the |
qvec |
the |
The function sharedNN returns a matrix with 2 rows,
where first row is the j values and second row is
the corresponding vector of Q_j values
The function Rval returns the R value,
the number of reflexive NNs.
See the description above for the details of these quantities.
Elvan Ceyhan
Tval, QRval, sharedNNmc,
and Ninv
#Examples for Qval
#3D data points
n<-10
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
W<-Wmat(ipd)
Qval(W)
#1D data points
X<-as.matrix(runif(10)) # need to be entered as a matrix with one column
#(i.e., a column vector), hence X<-runif(10) would not work
ipd<-ipd.mat(X)
W<-Wmat(ipd)
Qval(W)
#with ties=TRUE in the data
Y<-matrix(round(runif(15)*10),ncol=3)
ipd<-ipd.mat(Y)
W<-Wmat(ipd,ties=TRUE)
Qval(W)
#with ties=TRUE in the data
Y<-matrix(round(runif(15)*10),ncol=3)
ipd<-ipd.mat(Y)
W<-Wmat(ipd,ties=TRUE)
Qval(W)
#Examples for Qvec
#3D data points
n<-10
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
W<-Wmat(ipd)
Qvec(W)
#2D data points
n<-15
Y<-matrix(runif(2*n),ncol=2)
ipd<-ipd.mat(Y)
W<-Wmat(ipd)
Qvec(W)
#1D data points
X<-as.matrix(runif(15)) # need to be entered as a matrix with one column
#(i.e., a column vector), hence X<-runif(15) would not work
ipd<-ipd.mat(X)
W<-Wmat(ipd)
Qvec(W)
#with ties=TRUE in the data
Y<-matrix(round(runif(15)*10),ncol=3)
ipd<-ipd.mat(Y)
W<-Wmat(ipd,ties=TRUE)
Qvec(W)
#Examples for sharedNN
#3D data points
n<-10
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
W<-Wmat(ipd)
sharedNN(W)
Qvec(W)
#1D data points
X<-as.matrix(runif(15)) # 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)
W<-Wmat(ipd)
sharedNN(W)
Qvec(W)
#2D data points
n<-15
Y<-matrix(runif(2*n),ncol=2)
ipd<-ipd.mat(Y)
W<-Wmat(ipd)
sharedNN(W)
Qvec(W)
#with ties=TRUE in the data
Y<-matrix(round(runif(30)*10),ncol=3)
ipd<-ipd.mat(Y)
W<-Wmat(ipd,ties=TRUE)
sharedNN(W)
#Examples for Rval
#3D data points
n<-10
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
W<-Wmat(ipd)
Rval(W)
#1D data points
X<-as.matrix(runif(15)) # 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)
W<-Wmat(ipd)
Rval(W)
#with ties=TRUE in the data
Y<-matrix(round(runif(30)*10),ncol=3)
ipd<-ipd.mat(Y)
W<-Wmat(ipd,ties=TRUE)
Rval(W)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.