# funsAijmat: Aij matrices for computation of Moments of Cuzick and Edwards... In nnspat: Nearest Neighbor Methods for Spatial Patterns

 funsAijmat R Documentation

## Aij matrices for computation of Moments of Cuzick and Edwards T_k Test statistic

### Description

Two functions: `aij.mat` and `aij.nonzero`.

The function `aij.mat` yields the A=(a_{ij}(k)) matrix where a_{ij}(k) = 1 if z_j is among the `k`NNs of z_i and 0 otherwise due to \insertCitetango:2007;textualnnspat. This matrix is useful in calculation of the moments of Cuzick-Edwards T_k tests.

The function `aij.nonzero` keeps only nonzero entries, i.e., row and column entries where in each row, for the entry (r_1,c_1) r_1 is the row entry and c_1 is the column entry. Rows are from 1 to n, which stands for the data point or observation, and column entries are from 1 to `k`, where `k` is specifying the number of `k`NNs (of each observation) considered. This function saves in storage memory, but needs to be carefully unfolded in the functions to represent the actual the A matrix.

### Usage

```aij.mat(dat, k, ...)

aij.nonzero(dat, k, ...)
```

### Arguments

 `dat` The data set in one or higher dimensions, each row corresponds to a data point. `k` Integer specifying the number of NNs (of subject i), default is `1`. `...` are for further arguments, such as `method` and `p`, passed to the `dist` function.

### Value

The function `aij.mat` returns the A_{ij} matrix for computation of moments of Cuzick and Edwards T_k Test statistic while the function `aij.nonzero` returns the (locations of the) non-zero entries in the A_{ij} matrix

Elvan Ceyhan

### References

\insertAllCited

`aij.theta` and `EV.Tkaij`

### Examples

```n<-20  #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
k<-3 #try also 2,3

Aij<-aij.mat(Y,k)
Aij
Aij2<-aij.mat(Y,k,method="max")
range(Aij,Aij2)

apply(Aij,2,sum) #row sums of Aij

aij.nonzero(Y,k)
aij.nonzero(Y,k,method="max")

```

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