Learn R Programming

This is an R package that contains the functions for generating patterns of segregation, association, Uniform data, and various non-random labeling patterns for disease clustering in two dimensional cases, and for testing the spatial patterns (of segregation, spatial symmetry, association, disease clustering, species correspondence and reflexivity) based on NN relations, especially using contingency tables such as nearest neighbor contingency tables, NN symmetry contingency tables, species correspondence contingency tables and reflexivity contingency tables for two- and higher-dimensional data, for visualization for the two dimensional data. The tests are usually (asymptotic) normal z-tests and chi-square tests.

Install from GitHub : devtools::install_github("elvanceyhan/nnspat")

Copy Link

Version

Install

install.packages('nnspat')

Monthly Downloads

153

Version

0.1.2

License

GPL-2

Maintainer

Elvan Ceyhan

Last Published

December 19th, 2023

Functions in nnspat (0.1.2)

Ntkl

\(N_{tkl}\) Value
Tval

\(T\) value in NN structure
Qsym.test

Pielou's Second Type of NN Symmetry Test with Chi-square Approximation
SkewTk

Skewness of Cuzick and Edwards \(T_k\) Test statistic
Tcomb

Cuzick & Edwards Tcomb Test Statistic
Qsym.ct

\(Q\)-symmetry Contingency Table (QCT)
Ninv

Vector of Shared NNs and Number of Reflexive NNs
NNsub

Finding the index of the NN of a given point among a subset of points
Nt.def

\(N_t\) Value (found with the definition formula)
QRval

Number of Shared and Reflexive NNs
asycovTkTl

Asymptotic Covariance between \(T_k\) and \(T_l\) Values
Wmat

The incidence matrix W for the NN digraph
Xsq.ceTk

Chi-square Approximation to Cuzick and Edwards \(T_k\) Test statistic
Znnsym

NN Symmetry Test with Normal Approximation
Xsq.nnsym

Overall NN Symmetry Test with Chi-square Approximation
ZTrun

\(Z\)-test for Cuzick and Edwards \(T_{run}\) statistic
Znnsym2cl

NN Symmetry Test with Normal Approximation for Two Classes
aij.theta

Closeness or Proximity Matrix for Tango's Spatial Clustering Tests
ZTcomb

\(Z\)-test for Cuzick and Edwards \(T_{comb}\) statistic
ZceTk

\(Z\)-test for Cuzick and Edwards \(T_k\) statistic
ceTrun

Cuzick and Edwards \(T_{run}\) Test statistic
cov.tct

Covariance Matrix of the Entries of the Type I-IV TCTs
asyvarTk

Asymptotic Variance of Cuzick and Edwards \(T_k\) Test statistic
bvnorm.pdf

pdf of the Bivariate Normal Distribution
ceTkinv

Cuzick and Edwards \(T_k^{inv}\) Test statistic
cellsTij

Entries for the Types I-IV cell-specific tests
cov.nnsym

Covariance Matrix of the Differences of the Off-Diagonal Cell Counts in an NNCT
cov.seg.coeff

Covariance Matrix of Segregation Coefficients in a Multi-class Case
cov.nnct

Covariance Matrix of the Cell Counts in an NNCT
ceTk

Cuzick and Edwards \(T_k\) Test statistic
.onLoad

.onLoad getOption package settings
exact.nnct

Exact version of Pearson's chi-square test on NNCTs
dist2full

Converts a lower triangular distance matrix to a full distance matrix
covNrow2col

Conversion of the Covariance Matrix of the Row-wise Vectorized Cell Counts to Column-wise Vectorized Cell Counts in an NNCT
euc.dist

The Euclidean distance between two vectors, matrices, or data frames
covTkTl

Finite Sample Covariance between \(T_k\) and \(T_l\) Values
exact.pval1s

\(p\)-value correction to the one-sided version of exact NNCT test
dist.std.data

Interpoint Distance Matrix for Standardized Data
covTcomb

Covariance matrix for \(T_k\) values in Tcomb
.onAttach

.onAttach start message
funs.class.spec

Class-specific Chi-square Tests based on NNCTs
funs.overall.nnct

Dixon's Overall Test of Segregation for NNCT
exact.pval2s

\(p\)-value correction to the two-sided version of exact NNCT test
funs.kNNdist

Functions for the \(k^{th}\) and k NN distances
funs.kNNdist2cl

Functions for the \(k^{th}\) and k NN distances
funs.covtct

Functions for Covariances of the Entries of the Types I, III and IV TCTs
funs.cell.spec.ss

Pielou's Cell-specific Segregation Test with Normal Approximation (for Sparse Sampling)
funs.base.class.spec

Base Class-specific Chi-square Tests based on NNCTs
funs.auxcovtct

Auxiliary Functions for Computing Covariances Between Cell Counts in the TCT
funs.covNii

Covariance Matrix of the Self Entries in a Species Correspondence Contingency Table (SCCT)
funs.varNii

Variances of the Self Entries in a Species Correspondence Contingency Table (SCCT)
funs.scct

Species Correspondence Contingency Table (SCCT)
funsC_MI_II

Correction Matrices for the Covariance Matrix of NNCT entries
funs.overall.seg

Overall Segregation Tests for NNCTs
funsExpTk

Expected Value for Cuzick and Edwards \(T_k\) Test statistic
funsAijmat

Aij matrices for computation of Moments of Cuzick and Edwards \(T_k\) Test statistic
funs.seg.coeff

Pielou's Segregation Coefficients for NNCTs
funs.overall.tct

Types I-IV Overall Tests of Segregation for NNCT
funs.pijPij

The functions for probability of selecting a number of points from respective classes
funs.vartct

Functions for Variances of Cell Counts in the Types I, III and IV TCTs
funsRowColSums

Functions for row and column sums of a matrix
funsOnevsRest

Functions for one versus rest type labeling
funsPseg.ss

Pielou's Overall Test of Segregation for NNCT (for Sparse Sampling)
funsExpTrun

Expected Value for Cuzick and Edwards \(T_{run}\) Test statistic
funsNNclass.spec

NN Class-specific Chi-square Tests based on NNCTs
funsVarTrun

Variance of Cuzick and Edwards \(T_{run}\) Test statistic
funsQandR

Functions for the number of shared NNs, shared NN vector, and the number of reflexive NNs
funsW345values

\(W_k\) values for Tango's \(T\) test statistic
funsN_I_II

Correction Matrices for the NNCT entries
funsVarTk

Variance of Cuzick and Edwards \(T_k\) Test statistic
funsXsq.nnref

Reflexivity Test with Chi-square Approximation
funsZcell.tct

Types I-IV Cell-specific Z Tests of Segregation based on NNCTs
funsZcell.nnct.pval

\(p\)-values for Cell-specific Z Test Statistics for NNCT
funsXsq.nnsym.ss

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

Cell-specific Z Tests of Segregation for NNCTs
funsZcell.nnct

Dixon's Cell-specific Z Tests of Segregation for NNCT
funsXsq.nnsym.dx

Dixon's NN Symmetry Test with Chi-square Approximation for multiple classes
funsZTkinv

Z-Test for Cuzick and Edwards \(T_k^{inv}\) statistic
funsXsq.spec.cor

Overall Species Correspondence Test with Chi-square Approximation
funsXsq.seg.coeff

Chi-square Test for Segregation Coefficients
funsZnnref

Z Tests for NN Reflexivity
funsZdir.nnct.ss

Directional Segregation Test for Two Classes with Normal Approximation (for Sparse Sampling)
funsZdir.nnct

Directional Segregation Test for Two Classes with Normal Approximation
funsZmixed.nonref

Mixed-Non-Reflexivity Test with Normal Approximation
funsZnnsym.ss

Pielou's Pairwise NN Symmetry Test with Normal Approximation (for Sparse Sampling)
funsZnnsym.dx

Dixon's Pairwise NN Symmetry Test with Normal Approximation
funsZnnself.sum

Cumulative Species Correspondence Test with Normal Approximation
funsZnnsym2cl.dx

Dixon's NN Symmetry Test with Normal Approximation for Two Classes
funsZnnsym2cl.ss

Pielou's First Type of NN Symmetry Test with Normal Approximation for Two Classes (for Sparse Sampling)
funsZnnself

Self-Reflexivity Tests with Normal Approximation
matrix.sqrt

Square root of a matrix
funsZsegind

Z Tests for Segregation Indices
ind.nnsym

Index Matrix for Computing the Covariance of Dixon's Overall NN Symmetry Test
kNN

Finding the indices of the k NNs of a given point
mat2vec

Conversion of a Matrix to a Vector
funsZseg.coeff

Z Tests for Segregation Coefficients
funsZself.ref

Self-Reflexivity Test with Normal Approximation
ipd.mat.euc

Euclidean Interpoint Distance Matrix
ipd.mat

Interpoint Distance Matrix
ind.seg.coeff

Index Matrix for Computing the Covariance of Segregation Coefficients
nnct.boot.dis

Bootstrap Nearest Neighbor Contingency Table (NNCT)
pairwise.lab

Keeping the pair of the specified labels in the data
nnct

Nearest Neighbor Contingency Table (NNCT)
plot.SpatPatterns

Plot a SpatPatterns object
pick.min.max

Smallest and Largest Distances in a Distance Matrix
plot.Clusters

Plot a Clusters object
nnspat-package

nnspat: A package for NN Methods and Their Use in Testing Spatial Patterns
pk

Probability of k items selected from the class with size \(n_1\)
nnct.sub

Nearest Neighbor Contingency Table (NNCT) with (only) base points restricted to a subsample
print.Chisqtest

Print a summary of a Chisqtest object
print.summary.SpatPatterns

Print a summary of a SpatPatterns object
rassoc

Generation of Points Associated with a Given Set of Points
print.summary.Clusters

Print a summary of a Clusters object
print.refhtest

Print a summary of a refhtest object
print.classhtest

Print a summary of a classhtest object
print.cellhtest

Print a summary of a cellhtest object
print.SpatPatterns

Print a SpatPatterns object
rassocC

Generation of Points Associated in the Type C Sense with a Given Set of Points
print.Clusters

Print a Clusters object
prob.nnct

Probability of the current nearest neighbor contingency table
rhor.clust

Generation of Points with Clusters along the Horizontal Axis
rassocG

Generation of Points Associated in the Type G Sense with a Given Set of Points
rassocI

Generation of Points Associated in the Type I Sense with a Given Set of Points
rnonRLIII

Type III Non-Random Labeling of a Given Set of Points
rassocU

Generation of Points Associated in the Type U Sense with a Given Set of Points
rct

Reflexivity Contingency Table (RCT)
rdiag.clust

Generation of Points with Clusters along the First Diagonal
rnonRL

Non-Random Labeling of a Given Set of Points
rnonRLII

Type II Non-Random Labeling of a Given Set of Points
rnonRLI

Type I Non-Random Labeling of a Given Set of Points
rrot.clust

Generation of Points with Rotational Clusters
rseg

Generation of Points under Segregation of Two Classes
sharedNNmc

The Shared NN Vectors for Multiple Classes
seg.ind

Dixon's Segregation Indices for NNCTs
swamptrees

Tree Species in a Swamp Forest
summary.Clusters

Return a summary of a Clusters object
summary.SpatPatterns

Return a summary of a SpatPatterns object
rnonRLIV

Type IV Non-Random Labeling of a Given Set of Points
rself.ref

Generation of Points from Self Correspondence Pattern
runif.circ

Generation of Uniform Points in a Circle
varTkinv.sim

Simulated Variance of Cuzick and Edwards \(T_k^{inv}\) Test statistic
var.nnct

Variances of Cell Counts in an NNCT
tct

\(T\) Contingency Table (TCT)
var.seg.coeff

Variances of Segregation Coefficients in a Multi-class Case
var.nnsym

Variances of Differences of Off-Diagonal Entries in an NNCT
tocher.cor

Tocher's randomized correction to the exact \(p\)-value
varPseg.coeff

Variance of Pielou's Segregation Coefficient for 2 Classes
var.tct

Variances of Entries in a TCT
NNdist

Distances between subjects and their NNs
EV.tctI

Expected Values of the Type I cell-specific tests
EV.Nii

Expected Values of the Self Entries in a Species Correspondence Contingency Table (SCCT)
NN

Finding the index of the NN of a given point
EV.nnct

Expected Values of the Cell Counts in NNCT
EV.tct

Expected Values of the Types I-IV cell-specific tests
EV.rct

Expected Values of the Cell Counts in RCT
EV.Tkinv

Expected Value of Cuzick and Edwards \(T_k^{inv}\) Test statistic
NNdist2cl

Distances between subjects from class \(i\) and their NNs from class \(j\)
EV.Tcomb

Expected Value for Cuzick & Edwards \(T_{comb}\) Test Statistic