# ceTkinv: Cuzick and Edwards T_k^{inv} Test statistic In nnspat: Nearest Neighbor Methods for Spatial Patterns

## Description

This function computes Cuzick and Edwards T_k^{inv} test statistic based on the sum of number of cases closer to each case than the `k`-th nearest control to the case.

T_k^{inv} test statistic is an extension of the run length test allowing a fixed number of controls in the run sequence.

T_k^{inv} test statistic is defined as T_k^{inv}=∑_{i=1}^n δ_i ν_i^k where δ_i=1 if z_i is a case, and 0 if z_i is a control and ν_i^k is the number of cases closer to the index case than the `k` nearest control, i.e., number of cases encountered beginning at z_i until `k`-th control is encountered.

The argument `cc.lab` is case-control label, 1 for case, 0 for control, if the argument `case.lab` is `NULL`, then `cc.lab` should be provided in this fashion, if `case.lab` is provided, the labels are converted to 0's and 1's accordingly.

## Usage

 `1` ```ceTkinv(dat, k, cc.lab, case.lab = NULL, ...) ```

## Arguments

 `dat` The data set in one or higher dimensions, each row corresponds to a data point. `k` Integer specifying the number of the closest controls to subject i. `cc.lab` Case-control labels, 1 for case, 0 for control `case.lab` The label used for cases in the `cc.lab` (if `cc.lab` is not provided then the labels are converted such that cases are 1 and controls are 0), default is `NULL`. `...` are for further arguments, such as `method` and `p`, passed to the `dist` function.

## Value

A `list` with two elements

 `Tkinv` Cuzick and Edwards T_k^{inv} test statistic for disease clustering `run.vec` The `vector` of number of cases till the `k`-th control for each point in the data set

Elvan Ceyhan

## References

\insertAllCited

`ceTrun`, `ceTk`, and `Tcomb`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22``` ```n<-20 Y<-matrix(runif(3*n),ncol=3) cls<-sample(0:1,n,replace = TRUE) #or try cls<-rep(0:1,c(10,10)) cls k<-2 #also try 3,4 ceTkinv(Y,k,cls) ceTkinv(Y,k,cls+1,case.lab = 2) ceTkinv(Y,k,cls,method="max") ceTrun(Y,cls) ceTkinv(Y,k=1,cls) #cls as a factor na<-floor(n/2); nb<-n-na fcls<-rep(c("a","b"),c(na,nb)) ceTkinv(Y,k,fcls,case.lab="a") #try also ceTrun(Y,fcls) ############# n<-40 Y<-matrix(runif(3*n),ncol=3) cls<-sample(1:4,n,replace = TRUE) #here ceTkinv(Y,k,cls) #gives error ```