# asyvarTk: Asymptotic Variance of Cuzick and Edwards T_k Test statistic In nnspat: Nearest Neighbor Methods for Spatial Patterns

## Description

This function computes the asymptotic variance of Cuzick and Edwards T_k test statistic based on the number of cases within `k`NNs of the cases in the data.

The argument, n_1, is the number of cases (denoted as `n1` as an argument). The number of cases are denoted as n_1 and number of controls as n_0 in this function to match the case-control class labeling, which is just the reverse of the labeling in \insertCitecuzick:1990;textualnnspat.

The logical argument `nonzero.mat` (default=`TRUE`) is for using the A matrix if `FALSE` or just the matrix of nonzero locations in the A matrix (if `TRUE`) for computing N_s and N_t, which are required in the computation of the asymptotic variance. N_s and N_t are defined on page 78 of (\insertCitecuzick:1990;textualnnspat) as follows. N_s=∑_i∑_j a_{ij} a_{ji} (i.e., number of ordered pairs for which `k`NN relation is symmetric) and N_t= ∑ ∑_{i \ne l}∑ a_{ij} a_{lj} (i.e, number of triplets (i,j,l) i,j, and l distinct so that j is among `k`NNs of i and j is among `k`NNs of l). For the A matrix, see the description of the functions `aij.mat` and `aij.nonzero`.

See (\insertCitecuzick:1990;textualnnspat) for more details.

## Usage

 `1` ```asyvarTk(dat, n1, k, nonzero.mat = TRUE, ...) ```

## Arguments

 `dat` The data set in one or higher dimensions, each row corresponds to a data point. `n1` Number of cases `k` Integer specifying the number of NNs (of subject i) `nonzero.mat` A logical argument (default is `TRUE`) to determine whether the A matrix or the matrix of nonzero locations of the A matrix will be used in the computation of N_s and N_t. If `TRUE` the nonzero location matrix is used, otherwise the A matrix itself is used. `...` are for further arguments, such as `method` and `p`, passed to the `dist` function.

## Value

A `list` with the elements

 `asy.var` The asymptotic variance of Cuzick and Edwards T_k test statistic for disease clustering `Ns` The N_s value standing for the number of ordered pairs for which `k`NN relation is symmetric, see the description. `Nt` The N_t value standing for the number of triplets (i,j,l) i,j, and l distinct so that j is among `k`NNs of i and j is among `k`NNs of l see the description.

Elvan Ceyhan

## References

\insertAllCited

`ceTk`, `varTk`, and `varTkaij`
 ```1 2 3 4 5 6 7 8 9``` ```n<-20 #or try sample(1:20,1) Y<-matrix(runif(3*n),ncol=3) cls<-sample(0:1,n,replace = TRUE) #or try cls<-rep(0:1,c(10,10)) n1<-sum(cls==1) k<-3 #try also 2,3 asyvarTk(Y,n1,k) asyvarTk(Y,n1,k,nonzero.mat=FALSE) asyvarTk(Y,n1,k,method="max") ```