Learn R Programming

nnspat (version 0.1.2)

funsExpTk: 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 kNNs 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 cuzick: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 tango:2007;textualnnspat, where \(a_{ij}(k) = 1\) if \(z_j\) is among the kNNs of \(z_i\) and 0 otherwise.

See also (ceyhan:SiM-seg-ind2014;textualnnspat).

Usage

EV.Tk(k, n1, n0)

EV.Tkaij(k, n1, a)

Value

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

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

Author

Elvan Ceyhan

References

See Also

ceTk and EV.Tcomb

Examples

Run this code
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)

Run the code above in your browser using DataLab