Ninv: Vector of Shared NNs and Number of Reflexive NNs

View source: R/NNCTFunctions.R

NinvR Documentation

Vector of Shared NNs and Number of Reflexive NNs

Description

Returns the Qvec and R where Qvec=(Q_0,Q_1,\ldots) with Q_j is the number of points shared as a NN by j other points i.e., number of points that are NN of i points, for i=0,1,2,\ldots and R is the number of reflexive pairs where points A and B are reflexive iff they are NN to each other.

Usage

Ninv(x, is.ipd = TRUE, ...)

Arguments

x

The IPD matrix (if is.ipd=TRUE) or a data set of points in matrix or data frame form where points correspond to the rows (if is.ipd = FALSE).

is.ipd

A logical parameter (default=TRUE). If TRUE, x is taken as the inter-point distance matrix, otherwise, x is taken as the data set with rows representing the data points.

...

are for further arguments, such as method and p, passed to the dist function.

Value

Returns a list with two elements

Qvec

vector of Q_j values

R

number of reflexive points

Author(s)

Elvan Ceyhan

See Also

Qval, Qvec, sharedNN, Rval, and QRval

Examples

#3D data points
n<-20  #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
W<-Wmat(ipd)
sharedNN(W)
Qvec(W)
Ninv(ipd)
Ninv(Y,is.ipd = FALSE)
Ninv(Y,is.ipd = FALSE,method="max")

#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)
W<-Wmat(ipd)
sharedNN(W)
Qvec(W)
Ninv(ipd)

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


nnspat documentation built on May 29, 2024, 10:03 a.m.