50% off | Unlimited Data & AI Learning

Last chance! 50% off unlimited learning

Sale ends in


nnspat (version 0.1.2)

funsVarTk: Variance of Cuzick and Edwards Tk Test statistic

Description

Two functions: VarTk and VarTkaij.

Both functions compute the (finite sample) variance of Cuzick and Edwards Tk 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 n1 and number of controls as n0 in this function to match the case-control class labeling, which is just the reverse of the labeling in cuzick: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 Ns and Nt, which are required in the computation of the variance. Ns and Nt are defined on page 78 of (cuzick:1990;textualnnspat) as follows. Ns=ijaijaji (i.e., number of ordered pairs for which kNN relation is symmetric) and Nt=ilaijalj (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=(aij) matrix (and is equivalent to the function VarTk, see tango:2007;textualnnspat, where aij(k)=1 if zj is among the kNNs of zi and 0 otherwise.

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

See (cuzick:1990,tango:2007;textualnnspat).

Usage

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

varTkaij(n1, k, a)

Value

The function VarTk returns a list with the elements

var.Tk

The (finite sample) variance of Cuzick and Edwards Tk test statistic for disease clustering

Ns

The Ns value standing for the number of ordered pairs for which kNN relation is symmetric, see the description.

Nt

The Nt 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.

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 Ns and Nt. 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=(aij) matrix, used in VarTkaij only.

Author

Elvan Ceyhan

References

See Also

asyvarTk

Examples

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

Run the code above in your browser using DataLab