# funsExpTk: Expected Value for Cuzick and Edwards T_k Test statistic In nnspat: Nearest Neighbor Methods for Spatial Patterns

 funsExpTk R Documentation

## Expected Value for Cuzick and Edwards T_k Test statistic

### Description

Two functions: `EV.Tk` and `EV.Tkaij`.

Both functions compute the expected value of Cuzick and Edwards T_k test statistic based on the number of cases within `k`NNs of the cases in the data under RL or CSR independence.

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

The function `EV.Tkaij` uses Toshiro Tango's moments formulas based on the A=(a_{ij}) matrix (and is equivalent to the function `EV.Tk`, see \insertCitetango:2007;textualnnspat, where a_{ij}(k) = 1 if z_j is among the `k`NNs of z_i and 0 otherwise.

### Usage

```EV.Tk(k, n1, n0)

EV.Tkaij(k, n1, a)
```

### Arguments

 `k` Integer specifying the number of NNs (of subject i). `n1, n0` The number of cases and controls, n_1 used for both functions, and n_0 used in `EV.Tk` only. `a` The A=(a_{ij}) matrix

### Value

The expected value of Cuzick and Edwards T_k test statistic for disease clustering

Elvan Ceyhan

### References

\insertAllCited

`ceTk` and `EV.Tcomb`

### Examples

```n1<-20
n0<-25
k<-1 #try also 3, 5, sample(1:5,1)

EV.Tk(k,n1,n0)

###
n<-20  #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
cls<-sample(0:1,n,replace = TRUE)
n1<-sum(cls==1)
n0<-sum(cls==0)
a<-aij.mat(Y,k)

EV.Tk(k,n1,n0)
EV.Tkaij(k,n1,a)

```

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