funsZnnsym.ss {nnspat} | R Documentation |
Pielou's Pairwise NN Symmetry Test with Normal Approximation (for Sparse Sampling)
Description
Two functions: Znnsym.ss.ct
and Znnsym.ss
.
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 \ge 2
classes.
That is, each performs Pielou's first type of NN symmetry test which is appropriate
(i.e., have the appropriate asymptotic sampling distribution)
provided that data is obtained by sparse sampling.
(See Ceyhan (2014) for more detail).
Each symmetry test is based on the normal approximation of the differences of the off-diagonal entries in the NNCT and are due to Pielou (1961).
Each function yields a contingency table of the test statistics, p
-values for the corresponding
alternative, expected values, lower and upper confidence levels, sample estimates (i.e., observed values)
and null value(s) (i.e., expected 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, 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, the test statistic, p
-value and the lower and upper confidence limits are valid only
for (properly) sparsely sampled data.
See also (Pielou (1961); Ceyhan (2014)) and the references therein.
Usage
Znnsym.ss.ct(
ct,
alternative = c("two.sided", "less", "greater"),
conf.level = 0.95
)
Znnsym.ss(
dat,
lab,
alternative = c("two.sided", "less", "greater"),
conf.level = 0.95,
...
)
Arguments
ct |
A nearest neighbor contingency table, used in |
alternative |
Type of the alternative hypothesis in the test, one of |
conf.level |
Level of the upper and lower confidence limits, default is |
dat |
The data set in one or higher dimensions, each row corresponds to a data point,
used in |
lab |
The |
... |
are for further arguments, such as |
Value
A list
with the elements
statistic |
The |
stat.names |
Name of the test statistics |
p.value |
The |
LCL , UCL |
Matrix of Lower and Upper Confidence Levels (in the upper-triangular form) for the |
conf.int |
The confidence interval for the estimates, it is |
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 |
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,
|
null.name |
Name of the null values |
alternative |
Type of the alternative hypothesis in the test, one of |
method |
Description of the hypothesis test |
ct.name |
Name of the contingency table, |
data.name |
Name of the data set, |
Author(s)
Elvan Ceyhan
References
Ceyhan E (2014).
“Testing Spatial Symmetry Using Contingency Tables Based on Nearest Neighbor Relations.”
The Scientific World Journal, Volume 2014, Article ID 698296.
Pielou EC (1961).
“Segregation and symmetry in two-species populations as studied by nearest-neighbor relationships.”
Journal of Ecology, 49(2), 255-269.
See Also
Znnsym.dx.ct
, Znnsym.dx
, Znnsym2cl.ss.ct
and
Znnsym2cl.ss
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
Znnsym.ss(Y,cls)
Znnsym.ss.ct(ct)
Znnsym.ss(Y,cls,method="max")
Znnsym.ss(Y,cls,alt="g")
Znnsym.ss.ct(ct,alt="g")
#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
Znnsym.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)
Znnsym.ss(Y,cls)
Znnsym.ss.ct(ct)