funsVarTk: Variance of Cuzick and Edwards T_k Test statistic

funsVarTkR Documentation

Variance of Cuzick and Edwards T_k Test statistic

Description

Two functions: VarTk and VarTkaij.

Both functions compute the (finite sample) variance 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 common arguments for both functions are n1, representing the number of cases and k. 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 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 kNN 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 kNNs of i and j is among kNNs of l).

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

The function varTkaij is equivalent to varTk (with $var extension).

See (\insertCitecuzick:1990,tango:2007;textualnnspat).

Usage

varTk(dat, n1, k, nonzero.mat = TRUE, ...)

varTkaij(n1, k, a)

Arguments

dat

The data set in one or higher dimensions, each row corresponds to a data point, used in VarTk only.

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. Used in VarTk only.

...

are for further arguments, such as method and p, passed to the dist function. Used in VarTk only.

a

The A=(a_{ij}) matrix, used in VarTkaij only.

Value

The function VarTk returns a list with the elements

var.Tk

The (finite sample) 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 kNN 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 kNNs of i and j is among kNNs of l see the description.

The function VarTkaij returns only var.Tk as above.

Author(s)

Elvan Ceyhan

Elvan Ceyhan

References

\insertAllCited

See Also

asyvarTk

Examples

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<-2 #try also 2,3

a<-aij.mat(Y,k)

varTk(Y,n1,k)
varTk(Y,n1,k,nonzero.mat=FALSE)
varTk(Y,n1,k,method="max")

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<-1 #try also 2,3, sample(1:5,1)

a<-aij.mat(Y,k)

varTkaij(n1,k,a)
varTk(Y,n1,k)$var


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