funsZnnsym2cl.dx: Dixon's NN Symmetry Test with Normal Approximation for Two...

funsZnnsym2cl.dxR Documentation

Dixon's NN Symmetry Test with Normal Approximation for Two Classes

Description

Two functions: Znnsym2cl.dx.ct and Znnsym2cl.dx.

Both functions are objects of class "htest" 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=2 classes. That is, each performs Dixon's NN symmetry test which 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 normal approximation of the difference of the off-diagonal entries in the NNCT and are due to \insertCitedixon:1994;textualnnspat.

Each function yields the test statistic, p-value for the corresponding alternative, the confidence interval, estimate and null value for the parameter of interest (which is the difference of the off-diagonal entries in the NNCT), and method and name of the data set used.

The null hypothesis is that all E(N_{12})=E(N_{21}) in the 2 \times 2 NNCT (i.e., symmetry in the mixed NN structure).

See also (\insertCitedixon:1994,ceyhan:SWJ-spat-sym2014;textualnnspat) and the references therein.

Usage

Znnsym2cl.dx.ct(
  ct,
  Q,
  R,
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95
)

Znnsym2cl.dx(
  dat,
  lab,
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95,
  ...
)

Arguments

ct

A nearest neighbor contingency table, used in Znnsym2cl.dx.ct only

Q

The number of shared NNs, used in Znnsym2cl.dx.ct only

R

The number of reflexive NNs (i.e., twice the number of reflexive NN pairs), used in Znnsym2cl.dx.ct only

alternative

Type of the alternative hypothesis in the test, one of "two.sided", "less" or "greater".

conf.level

Level of the upper and lower confidence limits, default is 0.95, for the difference of the off-diagonal entries, N_{12}-N_{21}

dat

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

lab

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

...

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

Value

A list with the elements

statistic

The Z test statistic for Pielou's first type of NN symmetry test

p.value

The p-value for the hypothesis test for the corresponding alternative

conf.int

Confidence interval for the difference of the off-diagonal entries, N_{12}-N_{21} in the 2 \times 2 NNCT at the given confidence level conf.level and depends on the type of alternative.

estimate

Estimate, i.e., the difference of the off-diagonal entries of the 2 \times 2 NNCT, N_{12}-N_{21}.

null.value

Hypothesized null value for the expected difference between the off-diagonal entries, E(N_{12})-E(N_{21}) in the 2 \times 2 NNCT, which is 0 for this function.

alternative

Type of the alternative hypothesis in the test, one of "two.sided", "less", "greater"

method

Description of the hypothesis test

data.name

Name of the data set, dat, or name of the contingency table, ct

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

Znnsym2cl.ss.ct, Znnsym2cl.ss, Znnsym.dx.ct, Znnsym.dx, Xsq.nnsym.dx.ct and Xsq.nnsym.dx

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)
ct

W<-Wmat(ipd)
Qv<-Qvec(W)$q
Rv<-Rval(W)

Znnsym2cl.dx(Y,cls)
Znnsym2cl.dx.ct(ct,Qv,Rv)

Znnsym2cl.dx(Y,cls,method="max")

Znnsym2cl.dx(Y,cls,alt="g")
Znnsym2cl.dx.ct(ct,Qv,Rv,alt="g")

#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
Znnsym2cl.dx(Y,fcls)

#############
ct<-matrix(sample(1:20,4),ncol=2)
Znnsym2cl.dx.ct(ct,Qv,Rv) #gives an error message if ct<-matrix(sample(1:20,9),ncol=3)
#here, Qv and Rv values are borrowed from above, to highlight a point


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