funsZnnsym.dx: Dixon's Pairwise NN Symmetry Test with Normal Approximation

funsZnnsym.dxR Documentation

Dixon's Pairwise NN Symmetry Test with Normal Approximation

Description

Two functions: Znnsym.dx.ct and Znnsym.dx.

Both functions are objects of class "cellhtest" but with different arguments (see the parameter list below). Each one performs hypothesis tests 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 ≥ 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 \insertCitedixon:1994,ceyhan: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 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 estimates (i.e. observed values) 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 and the method 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 ≥ 2. In the output, the test statistic, p-value and the lower and upper confidence limits are valid for completely mapped data.

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

Usage

Znnsym.dx.ct(
  ct,
  varS,
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95
)

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

Arguments

ct

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

varS

The variance vector of differences of off-diagonal cell counts in NNCT, ct , usually output of var.nnsym function.

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_{ij}-N_{ji}

dat

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

lab

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

...

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

Value

A list with the elements

statistic

The matrix of Z test statistics for Dixon's 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

ct.name

Name of the contingency table, ct, returned by Znnsym.dx.ct only

data.name

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

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

Znnsym2cl.dx.ct, Znnsym2cl.dx, Znnsym.ss.ct, Znnsym.ss, 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)
varN<-var.nnct(ct,Qv,Rv)
covN<-cov.nnct(ct,varN,Qv,Rv) #default is byrow

varS<-var.nnsym(covN)

Znnsym.dx(Y,cls)
Znnsym.dx.ct(ct,varS)

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

Znnsym.dx(Y,cls,alt="g")
Znnsym.dx.ct(ct,varS,alt="g")

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

#############
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) #default is byrow

varS<-var.nnsym(covN)

Znnsym.dx(Y,cls)
Znnsym.dx.ct(ct,varS)


nnspat documentation built on Aug. 30, 2022, 9:06 a.m.