funsXsq.nnsym.dx {nnspat} | R Documentation |
Dixon's NN Symmetry Test with Chi-square Approximation for multiple classes
Description
Two functions: Xsq.nnsym.dx.ct
and Xsq.nnsym.dx
.
Both functions are objects of class "Chisqtest"
but with different arguments (see the parameter list below).
Each one performs the hypothesis test of equality of the expected value of the off-diagonal
cell counts (i.e., entries) under RL or CSR in the NNCT for k \ge 2
classes.
That is, each performs Dixon's overall NN symmetry test.
The test is appropriate (i.e., have the appropriate asymptotic sampling distribution)
for completely mapped data.
(See Ceyhan (2014) for more detail).
Each symmetry test is based on the chi-squared approximation of the corresponding quadratic form and is an extension of Dixon's NN symmetry test, which is extended by Ceyhan (2014).
Each function yields the test statistic, p
-value and df
which is k(k-1)/2
, description of the
alternative with the corresponding null values (i.e., expected values) of differences of the off-diagonal entries,(which is
0 for this function) and also the sample estimates (i.e., observed values) of absolute differences of the off-diagonal entries of
NNCT (in the upper-triangular form).
The functions also provide names of the test statistics, the description of the test and the data set used.
The null hypothesis is that all E(N_{ij})=E(N_{ji})
entries for all i \ne j
(i.e., symmetry in the
mixed NN structure).
See also (Ceyhan (2014)) and the references therein.
Usage
Xsq.nnsym.dx.ct(ct, covS)
Xsq.nnsym.dx(dat, lab, ...)
Arguments
ct |
A nearest neighbor contingency table, used in |
covS |
The |
dat |
The data set in one or higher dimensions, each row corresponds to a data point,
used in |
lab |
The |
... |
are for further arguments, such as |
Value
A list
with the elements
statistic |
The chi-squared test statistic for Dixon's overall NN symmetry test |
stat.names |
Name of the test statistic |
p.value |
The |
df |
Degrees of freedom for the chi-squared test, which is |
estimate |
Estimates, i.e., absolute differences of the off-diagonal entries of NNCT (in the upper-triangular form). |
est.name , est.name2 |
Names of the estimates, former is a shorter description of the estimates than the latter. |
null.value |
Hypothesized null values for the differences between the expected values of the off-diagonal entries, which is 0 for this function. |
method |
Description of the hypothesis test |
ct.name |
Name of the contingency table, |
data.name |
Name of the data set, |
Author(s)
Elvan Ceyhan
References
Ceyhan E (2014). “Testing Spatial Symmetry Using Contingency Tables Based on Nearest Neighbor Relations.” The Scientific World Journal, Volume 2014, Article ID 698296.
See Also
Znnsym.dx.ct
, Znnsym.dx
, Znnsym
,
Xsq.nnsym
, Xsq.nnsym.ss.ct
, Xsq.nnsym.ss
and Qsym.test
Examples
n<-20 #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
cls<-sample(1:2,n,replace = TRUE) #or try cls<-rep(1:2,c(10,10))
ct<-nnct(ipd,cls)
W<-Wmat(ipd)
Qv<-Qvec(W)$q
Rv<-Rval(W)
varN<-var.nnct(ct,Qv,Rv)
covN<-cov.nnct(ct,varN,Qv,Rv) #default is byrow
covS<-cov.nnsym(covN)
Xsq.nnsym.dx(Y,cls)
Xsq.nnsym.dx.ct(ct,covS)
Xsq.nnsym.dx(Y,cls,method="max")
#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
ct<-nnct(ipd,fcls)
Xsq.nnsym.dx(Y,fcls)
Xsq.nnsym.dx.ct(ct,covS)
#############
n<-40
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
cls<-sample(1:4,n,replace = TRUE) #or try cls<-rep(1:2,c(10,10))
ct<-nnct(ipd,cls)
W<-Wmat(ipd)
Qv<-Qvec(W)$q
Rv<-Rval(W)
varN<-var.nnct(ct,Qv,Rv)
covN<-cov.nnct(ct,varN,Qv,Rv)
covS<-cov.nnsym(covN)
Xsq.nnsym.dx(Y,cls)
Xsq.nnsym.dx.ct(ct,covS)