Znnsym: NN Symmetry Test with Normal Approximation

View source: R/NNCTFunctions.R

ZnnsymR Documentation

NN Symmetry Test with Normal Approximation

Description

An object of class "cellhtest" performing hypothesis test of equality of the expected values of the off-diagonal cell counts (i.e., entries) for each pair i,j of classes under RL or CSR in the NNCT for k \ge 2 classes. That is, the test performs Dixon's or Pielou's (first type of) NN symmetry test which is appropriate (i.e., have the appropriate asymptotic sampling distribution) for completely mapped data or for sparsely sample data, respectively. (See \insertCitepielou:1961,dixon:1994,ceyhan:SWJ-spat-sym2014;textualnnspat for more detail).

The type="dixon" refers to Dixon's NN symmetry test and type="pielou" refers to Pielou's first type of NN symmetry test. The symmetry test is based on the normal approximation of the difference of the off-diagonal entries in the NNCT and are due to \insertCitepielou:1961,dixon:1994;textualnnspat.

The function yields a contingency table of the test statistics, p-values for the corresponding alternative, expected values (i.e., null value(s)), lower and upper confidence levels and sample estimate for the N_{ij}-N_{ji} values for i \ne j (all in the upper-triangular form except for the null value, which is 0 for all pairs) and also names of the test statistics, estimates, null values, the description of the test, and the data set used.

The null hypothesis is that all E(N_{ij})=E(N_{ji}) for i \ne j in the k \times k NNCT (i.e., symmetry in the mixed NN structure) for k \ge 2. In the output, if if type="pielou", the test statistic, p-value and the lower and upper confidence limits are valid only for (properly) sparsely sampled data.

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

Usage

Znnsym(
  dat,
  lab,
  type = "dixon",
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95,
  ...
)

Arguments

dat

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

lab

The vector of class labels (numerical or categorical)

type

The type of the NN symmetry test with default="dixon". Takes on values "dixon" and "pielou" for Dixon's and Pielou's (first type) NN symmetry test

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}

...

are for further arguments, such as method and p, passed to the dist function

Value

A list with the elements

statistic

The matrix of Z test statistics for the NN symmetry test (in the upper-triangular form)

stat.names

Name of the test statistics

p.value

The matrix of p-values for the hypothesis test for the corresponding alternative (in the upper-triangular form)

LCL, UCL

Matrix of Lower and Upper Confidence Levels (in the upper-triangular form) for the N_{ij}-N_{ji} values for i \ne j at the given confidence level conf.level and depends on the type of alternative.

conf.int

The confidence interval for the estimates, it is NULL here, since we provide the UCL and LCL in matrix form.

cnf.lvl

Level of the upper and lower confidence limits (i.e., conf.level) of the differences of the off-diagonal entries.

estimate

Estimates of the parameters, i.e., matrix of the difference of the off-diagonal entries (in the upper-triangular form) of the k \times k NNCT, N_{ij}-N_{ji} for i \ne j.

est.name, est.name2

Names of the estimates, former is a shorter description of the estimates than the latter.

null.value

Hypothesized null value for the expected difference between the off-diagonal entries, E(N_{ij})-E(N_{ji}) for i \ne j in the k \times k NNCT, which is 0 for this function.

null.name

Name of the null values

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

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

Examples

n<-20  #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
cls<-sample(1:2,n,replace = TRUE)  #or try cls<-rep(1:2,c(10,10))

Znnsym(Y,cls)
Znnsym(Y,cls,method="max")
Znnsym(Y,cls,type="pielou")
Znnsym(Y,cls,type="pielou",method="max")

Znnsym(Y,cls,alt="g")
Znnsym(Y,cls,type="pielou",alt="g")

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

#############
n<-40
Y<-matrix(runif(3*n),ncol=3)
cls<-sample(1:4,n,replace = TRUE)  #or try cls<-rep(1:2,c(10,10))

Znnsym(Y,cls)
Znnsym(Y,cls,type="pielou")


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