funsXsq.nnsym.ss: Pielou's First Type of NN Symmetry Test with Chi-square...

funsXsq.nnsym.ssR Documentation

Pielou's First Type of NN Symmetry Test with Chi-square Approximation for multiple classes (for Sparse Sampling)

Description

Two functions: Xsq.nnsym.ss.ct and Xsq.nnsym.ss.

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 ≥ 2 classes. That is, each performs Pielou's first type of NN symmetry test which is also equivalent to McNemar's test on the NNCT. The test is appropriate (i.e. have the appropriate asymptotic sampling distribution) provided that data is obtained by sparse sampling. (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 are due to \insertCitepielou:1961;textualnnspat.

The argument cont.corr is a logical argument (default=TRUE) for continuity correction to this test. If TRUE the continuity correction to McNemar's test is implemented, and if FALSE such a correction is not implemented.

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 th off-diagonal entries of NNCT (in the upper-triangular form). The functions also provide names of the test statistics, the method and the data set used.

The null hypothesis is that E(N_{ij})=E(N_{ji}) for all entries for i \ne j (i.e., symmetry in the mixed NN structure). In the output, the test statistic, p-value and df are valid only for (properly) sparsely sampled data.

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

Usage

Xsq.nnsym.ss.ct(ct, cont.corr = TRUE)

Xsq.nnsym.ss(dat, lab, cont.corr = TRUE, ...)

Arguments

ct

A nearest neighbor contingency table, used in Xsq.nnsym.ss.ct only

cont.corr

A logical argument (default=TRUE). If TRUE the continuity correction to McNemar's test is implemented, and if FALSE such a correction is not implemented.

dat

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

lab

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

...

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

Value

A list with the elements

statistic

The chi-squared test statistic for Pielou's first type of 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.ss.ct only

data.name

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

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

Znnsym2cl.ss.ct, Znnsym2cl.ss, Znnsym.ss.ct, Znnsym.ss, Xsq.nnsym.dx.ct, Xsq.nnsym.dx 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)
ct

Xsq.nnsym.ss(Y,cls)
Xsq.nnsym.ss.ct(ct)

Xsq.nnsym.ss(Y,cls,method="max")

Xsq.nnsym.ss(Y,cls,cont.corr=FALSE)
Xsq.nnsym.ss.ct(ct,cont.corr=FALSE)

#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
Xsq.nnsym.ss(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)

Xsq.nnsym.ss(Y,cls)
Xsq.nnsym.ss.ct(ct)
Xsq.nnsym.ss.ct(ct,cont.corr = FALSE)


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