funsQandR: Functions for the Number of Shared NNs, Shared NN vector and... In nnspat: Nearest Neighbor Methods for Spatial Patterns

 funsQandR R Documentation

Functions for the Number of Shared NNs, Shared NN vector and the number of reflexive NNs

Description

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,…) 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,…) 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=∑_{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.

Usage

```Qval(W)

Qvec(W)

sharedNN(W)

Rval(W)
```

Arguments

 `W` The incidence matrix, W, for the NN digraph

Value

`Qval` returns the Q value `Qvec` returns a `list` with two elements

 `q` the Q value, the number of shared NNs `qvec` the `vector` of Q_j values

`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 `Rval`the R value, the number of reflexive NNs

See the description above for the details of these quantities.

Author(s)

Elvan Ceyhan

`Tval`, `QRval`, `sharedNNmc` and `Ninv`

Examples

```#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)

```

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