sharedNNmc {nnspat} | R Documentation |
The Shared NN Vectors for Multiple Classes
Description
Returns a matrix
with k
rows
where each row is the vector of number of points with shared NNs,
Q_i=(Q_{i0},Q_{i1},\ldots)
where Q_{ij}
is the number of class i
points
that are NN to class j
points.
The function also returns the indices of columns with nonzero sums as a vector.
The output matrix of shared NNs is used in testing symmetry
in shared NN structure (i.e., Q
-symmetry
or Pielou's second type of symmetry),
e.g., in functions Qsym.ct
and Qsym.test
.
See also (Pielou (1961); Ceyhan (2014)) and the references therein.
Usage
sharedNNmc(x, lab, is.ipd = TRUE, ...)
Arguments
x |
The IPD matrix (if |
lab |
The |
is.ipd |
A logical parameter (default= |
... |
are for further arguments,
such as |
Value
The function Qval
returns the Q
value
The function Qvec
returns a list
with two elements
q |
the |
qvec |
the |
The function sharedNN
returns a matrix
with 2 rows,
where first row is the j
values and second row is
the corresponding vector of Q_j
values
The function Rval
returns the R
value, the number of reflexive NNs.
Returns a list
with two elements
Nv |
A |
col.ind |
The |
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
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))
ipd<-ipd.mat(Y)
sharedNNmc(ipd,cls)
sharedNNmc(Y,cls,is.ipd = FALSE)
sharedNNmc(Y,cls,is.ipd = FALSE,method="max")
#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
sharedNNmc(ipd,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))
ipd<-ipd.mat(Y)
sharedNNmc(ipd,cls)