funsVarTk {nnspat} | R 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 k
NNs 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 Cuzick and Edwards (1990).
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 (Cuzick and Edwards (1990)) as follows.
N_s=\sum_i\sum_j a_{ij} a_{ji}
(i.e., number of ordered pairs for which k
NN relation is symmetric)
and N_t= \sum \sum_{i \ne l}\sum a_{ij} a_{lj}
(i.e, number of triplets (i,j,l)
i,j
, and l
distinct so that
j
is among k
NNs of i
and j
is among k
NNs 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 Tango (2007),
where a_{ij}(k) = 1
if z_j
is among the k
NNs of z_i
and 0 otherwise.
The function varTkaij
is equivalent to varTk
(with $var
extension).
See (Cuzick and Edwards (1990); Tango (2007)).
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 |
n1 |
Number of cases |
k |
Integer specifying the number of NNs (of subject |
nonzero.mat |
A logical argument (default is |
... |
are for further arguments, such as |
a |
The |
Value
The function VarTk
returns a list
with the elements
var.Tk |
The (finite sample) variance of Cuzick and Edwards |
Ns |
The |
Nt |
The |
The function VarTkaij
returns only var.Tk
as above.
Author(s)
Elvan Ceyhan
References
Cuzick J, Edwards R (1990).
“Spatial clustering for inhomogeneous populations (with discussion).”
Journal of the Royal Statistical Society, Series B, 52, 73-104.
Tango T (2007).
“A class of multiplicity adjusted tests for spatial clustering based on case-control point data.”
Biometrics, 63, 119-127.
See Also
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