funsXsq.nnsym.dx: Dixon's NN Symmetry Test with Chi-square Approximation for...

funsXsq.nnsym.dxR 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 \insertCiteceyhan:SWJ-spat-sym2014;textualnnspat 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 \insertCiteceyhan:SWJ-spat-sym2014;textualnnspat.

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 (\insertCiteceyhan:SWJ-spat-sym2014;textualnnspat) 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 Xsq.nnsym.dx.ct only

covS

The k(k-1)/2 \times k(k-1)/2 covariance matrix of the differences of the off-diagonal entries in the NNCT, ct, usually the output of the function cov.nnsym.

dat

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

lab

The vector of class labels (numerical or categorical), used in Xsq.nnsym.dx only

...

are for further arguments, such as method and p, passed to the dist function. used in Xsq.nnsym.dx only

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 p-value for the hypothesis test

df

Degrees of freedom for the chi-squared test, which is k(k-1)/2 for this function.

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, ct, returned by Xsq.nnsym.dx.ct only

data.name

Name of the data set, dat, returned by Xsq.nnsym.dx only

Author(s)

Elvan Ceyhan

References

\insertAllCited

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)


nnspat documentation built on May 29, 2024, 10:03 a.m.