QRval: Number of Shared and Reflexive NNs

View source: R/NNCTFunctions.R

QRvalR Documentation

Number of Shared and Reflexive NNs

Description

Returns the Q and R values where Q is the number of points shared as a NN by other points i.e. number of points that are NN of other points (which occurs when two or more points share a NN, for data in any dimension) and R is the number of reflexive pairs where A and B are reflexive iff they are NN to each other.

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.

Usage

QRval(njr)

Arguments

njr

A list that is the output of Ninv (with first entry in the list is vector of number of shared NNs and second is the R value, number of reflexive points)

Value

A list with two elements

Q

the Q value, the number of shared NNs

R

the R value, the number of reflexive NNs

Author(s)

Elvan Ceyhan

See Also

Qval, Qvec, sharedNN, Rval and Ninv

Examples

#3D data points
n<-20  #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
ninv<-Ninv(ipd)
QRval(ninv)
W<-Wmat(ipd)
Qvec(W)$q

#1D data points
n<-15
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)
ninv<-Ninv(ipd)
QRval(ninv)
W<-Wmat(ipd)
Qvec(W)$q

#with possible ties in the data
Y<-matrix(round(runif(30)*10),ncol=3)
ny<-nrow(Y)
ipd<-ipd.mat(Y)
ninv<-Ninv(ipd)
QRval(ninv)
W<-Wmat(ipd)
Qvec(W)$q


nnspat documentation built on Aug. 30, 2022, 9:06 a.m.