Package: nnspat 0.1.1

nnspat: Nearest Neighbor Methods for Spatial Patterns

Contains the functions for testing the spatial patterns (of segregation, spatial symmetry, association, disease clustering, species correspondence and reflexivity) based on nearest neighbor relations, especially using contingency tables such as nearest neighbor contingency tables (Ceyhan (2010) <doi:10.1007/s10651-008-0104-x> and Ceyhan (2017) <doi:10.1016/j.jkss.2016.10.002> and references therein), nearest neighbor symmetry contingency tables (Ceyhan (2014) <doi:10.1155/2014/698296>), species correspondence contingency tables and reflexivity contingency tables (Ceyhan (2018) <doi:10.2436/20.8080.02.72>) for two (or higher) dimensional data. Also contains functions for generating patterns of segregation, association, uniformity in a multi-class setting (Ceyhan (2014) <doi:10.1007/s00477-013-0824-9>), and various non-random labeling patterns for disease clustering in two dimensional cases (Ceyhan (2014) <doi:10.1002/sim.6053>), and for visualization of all these patterns for the two dimensional data. The tests are usually (asymptotic) normal z-tests and chi-square tests.

Authors:Elvan Ceyhan

nnspat_0.1.1.tar.gz
nnspat_0.1.1.zip(r-4.5)nnspat_0.1.1.zip(r-4.4)nnspat_0.1.1.zip(r-4.3)
nnspat_0.1.1.tgz(r-4.4-any)nnspat_0.1.1.tgz(r-4.3-any)
nnspat_0.1.1.tar.gz(r-4.5-noble)nnspat_0.1.1.tar.gz(r-4.4-noble)
nnspat_0.1.1.tgz(r-4.4-emscripten)nnspat_0.1.1.tgz(r-4.3-emscripten)
nnspat.pdf |nnspat.html
nnspat/json (API)

# Install 'nnspat' in R:
install.packages('nnspat', repos = c('https://elvanceyhan.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/elvanceyhan/nnspat/issues

Datasets:

On CRAN:

2.90 score 16 scripts 139 downloads 196 exports 88 dependencies

Last updated 2 years agofrom:7173ace6a9. Checks:OK: 3 NOTE: 4. Indexed: yes.

TargetResultDate
Doc / VignettesOKNov 05 2024
R-4.5-winNOTENov 05 2024
R-4.5-linuxNOTENov 05 2024
R-4.4-winNOTENov 05 2024
R-4.4-macNOTENov 05 2024
R-4.3-winOKNov 05 2024
R-4.3-macOKNov 05 2024

Exports:aij.mataij.nonzeroaij.thetaasycovTkTlasyvarTkbase.class.specbase.class.spec.ctbvnorm.pdfcell.speccell.spec.ctcell.spec.sscell.spec.ss.ctcellsTijceTkceTkinvceTrunclass.specclass.spec.ctclassirestcol.sumcorrect.cf1correct.cf2cov.2cellscov.2colscov.cell.colcov.nnctcov.nnsymcov.seg.coeffcov.tctcov.tct3cov.tctIcov.tctIIIcov.tctIVcovCiCjcovNiicovNii.ctcovNijCkcovNrow2colcovTcombcovTkTldist.std.datadist2fulleuc.distEV.NiiEV.nnctEV.rctEV.TcombEV.tctEV.tctIEV.TkEV.TkaijEV.TkinvEV.Trunexact.nnctexact.pval1sexact.pval2sipd.matipd.mat.euckNNkNNdistkNNdist2clkthNNdistkthNNdist2cllab.onevsrestmat2vecmatrix.sqrtNinvNNNN.class.specNN.class.spec.ctnnctnnct.boot.disnnct.cr1nnct.cr2nnct.subNNdistNNdist2clNNsubNt.defNtkloverall.nnctoverall.nnct.ctoverall.segoverall.seg.ctoverall.tctoverall.tct.ctpairwise.labpick.min.maxprob.nnctPseg.coeffPseg.ssPseg.ss.ctQRvalQsym.ctQsym.testQvalQvecrassocrassocCrassocGrassocIrassocUrctrdiag.clustrhor.clustrnonRLrnonRLIrnonRLIIrnonRLIIIrnonRLIVrow.sumrrot.clustrsegrself.refrunif.circRvalscctscct.ctseg.coeffseg.indsharedNNsharedNNmcSkewTkTcombtcttocher.corTvalvar.nnctvar.nnsymvar.seg.coeffvar.tctvarNiivarNii.ctvarPseg.coeffvarTkvarTkaijvarTkinv.simvarTrunvarTrun.simW3valW4valW5valWmatXsq.ceTkXsq.nnrefXsq.nnref.ctXsq.nnsymXsq.nnsym.dxXsq.nnsym.dx.ctXsq.nnsym.ssXsq.nnsym.ss.ctXsq.seg.coeffXsq.seg.coeff.ctXsq.spec.corXsq.spec.cor.ctZcell.nnctZcell.nnct.2sZcell.nnct.ctZcell.nnct.lsZcell.nnct.pvalZcell.nnct.rsZcell.tctZcell.tct.ctZceTkZdir.nnctZdir.nnct.ctZdir.nnct.ssZdir.nnct.ss.ctZmixed.nonrefZmixed.nonref.ctZnnrefZnnref.ctZnnselfZnnself.ctZnnself.sumZnnself.sum.ctZnnsymZnnsym.dxZnnsym.dx.ctZnnsym.ssZnnsym.ss.ctZnnsym2clZnnsym2cl.dxZnnsym2cl.dx.ctZnnsym2cl.ssZnnsym2cl.ss.ctZseg.coeffZseg.coeff.ctZseg.indZseg.ind.ctZself.refZself.ref.ctZTcombZTkinvZTkinv.simZTrun

Dependencies:abindbase64encbslibcachemclicolorspacecombinatcpp11deldirdigestdplyrevaluatefansifarverfastmapfontawesomefsgenericsgeometryggplot2ggrepelgluegMOIPgtablehighrhtmltoolshtmlwidgetsinterpisobandjquerylibjsonliteknitrlabelinglatticelifecyclelinproglpSolvemagicmagrittrMASSMatrixmatrixStatsmemoisemgcvmimemisc3dmoocoremunsellnlmepcdspillarpkgconfigplot3DplotrixplyrpngpurrrR6rappdirsrbibutilsRColorBrewerRcppRcppArmadilloRcppEigenRcppGSLRcppParallelRcppProgressRcppZigguratRdpackRfastrglrlangrmarkdownsassscalesspstringistringrtibbletidyrtidyselecttinytexutf8vctrsviridisLitewithrxfunyaml

Readme and manuals

Help Manual

Help pageTopics
.onAttach start message.onAttach
.onLoad getOption package settings.onLoad
Closeness or Proximity Matrix for Tango's Spatial Clustering Testsaij.theta
Asymptotic Covariance between T_k and T_l ValuesasycovTkTl
Asymptotic Variance of Cuzick and Edwards T_k Test statisticasyvarTk
pdf of the Bivariate Normal Distributionbvnorm.pdf
Entries for the Types I-IV cell-specific testscellsTij
Cuzick and Edwards T_k Test statisticceTk
Cuzick and Edwards T_k^{inv} Test statisticceTkinv
Cuzick and Edwards T_{run} Test statisticceTrun
Covariance Matrix of the Cell Counts in an NNCTcov.nnct
Covariance Matrix of the Differences of the Off-Diagonal Cell Counts in an NNCTcov.nnsym
Covariance Matrix of Segregation Coefficients in a Multi-class Casecov.seg.coeff
Covariance Matrix of the Entries of the Type I-IV TCTscov.tct
Conversion of the Covariance Matrix of the Row-wise Vectorized Cell Counts to Column-wise Vectorized Cell Counts in an NNCTcovNrow2col
Covariance matrix for T_k values in 'Tcomb'covTcomb
Finite Sample Covariance between T_k and T_l ValuescovTkTl
Interpoint Distance Matrix for Standardized Datadist.std.data
Converts a lower triangular distance matrix to a full distance matrixdist2full
The Euclidean distance between two vectors, matrices, or data frameseuc.dist
Expected Values of the Self Entries in a Species Correspondence Contingency Table (SCCT)EV.Nii
Expected Values of the Cell Counts in NNCTEV.nnct
Expected Values of the Cell Counts in RCTEV.rct
Expected Value for Cuzick & Edwards T_{comb} Test StatisticEV.Tcomb
Expected Values of the Types I-IV cell-specific testsEV.tct
Expected Values of the Type I cell-specific testsEV.tctI
Expected Value of Cuzick and Edwards T_k^{inv} Test statisticEV.Tkinv
Exact version of Pearson's chi-square test on NNCTsexact.nnct
p-value correction to the one-sided version of exact NNCT testexact.pval1s
p-value correction to the two-sided version of exact NNCT testexact.pval2s
Auxiliary Functions for Computing Covariances Between Cell Counts in the TCTcov.2cells cov.2cols cov.cell.col covCiCj covNijCk funs.auxcovtct
Base Class-specific Chi-square Tests based on NNCTsbase.class.spec base.class.spec.ct funs.base.class.spec
Pielou's Cell-specific Segregation Test with Normal Approximation (for Sparse Sampling)cell.spec.ss cell.spec.ss.ct funs.cell.spec.ss
Class-specific Chi-square Tests based on NNCTsclass.spec class.spec.ct funs.class.spec
Covariance Matrix of the Self Entries in a Species Correspondence Contingency Table (SCCT)covNii covNii.ct funs.covNii
Functions for Covariances of the Entries of the Types I, III and IV TCTscov.tct3 cov.tctI cov.tctIII cov.tctIV funs.covtct
Functions for the k^{th} and 'k' NN distancesfuns.kNNdist kNNdist kthNNdist
Functions for the k^{th} and 'k' NN distancesfuns.kNNdist2cl kNNdist2cl kthNNdist2cl
Dixon's Overall Test of Segregation for NNCTfuns.overall.nnct overall.nnct overall.nnct.ct
Overall Segregation Tests for NNCTsfuns.overall.seg overall.seg overall.seg.ct
Types I-IV Overall Tests of Segregation for NNCTfuns.overall.tct overall.tct overall.tct.ct
The functions for probability of selecting a number of points from respective classesfuns.pijPij P11 p11 P111 p111 P1111 p1111 P1112 p1112 P112 p112 P1122 p1122 P1123 p1123 P12 p12 p122 p1223 P123 p123 P1234 p1234
Species Correspondence Contingency Table (SCCT)funs.scct scct scct.ct
Pielou's Segregation Coefficients for NNCTsfuns.seg.coeff Pseg.coeff seg.coeff
Variances of the Self Entries in a Species Correspondence Contingency Table (SCCT)funs.varNii varNii varNii.ct
Functions for Variances of Cell Counts in the Types I, III and IV TCTsfuns.vartct var.tctI var.tctIII var.tctIV
Aij matrices for computation of Moments of Cuzick and Edwards T_k Test statisticaij.mat aij.nonzero funsAijmat
Correction Matrices for the Covariance Matrix of NNCT entriescorrect.cf1 correct.cf2 funsC_MI_II
Expected Value for Cuzick and Edwards T_k Test statisticEV.Tk EV.Tkaij funsExpTk
Expected Value for Cuzick and Edwards T_{run} Test statisticEV.Trun EV.Trun.alt funsExpTrun
Correction Matrices for the NNCT entriesfunsN_I_II nnct.cr1 nnct.cr2
NN Class-specific Chi-square Tests based on NNCTsfunsNNclass.spec NN.class.spec NN.class.spec.ct
Functions for one versus rest type labelingclassirest funsOnevsRest lab.onevsrest
Pielou's Overall Test of Segregation for NNCT (for Sparse Sampling)funsPseg.ss Pseg.ss Pseg.ss.ct
Functions for the Number of Shared NNs, Shared NN vector and the number of reflexive NNsfunsQandR Qval Qvec Rval sharedNN
Functions for row and column sums of a matrixcol.sum funsRowColSums row.sum
Variance of Cuzick and Edwards T_k Test statisticfunsVarTk varTk varTkaij
Variance of Cuzick and Edwards T_{run} Test statisticfunsVarTrun varTrun varTrun.sim
W_k values for Tango's T test statisticfunsW345values W3val W4val W5val
Reflexivity Test with Chi-square ApproximationfunsXsq.nnref Xsq.nnref Xsq.nnref.ct
Dixon's NN Symmetry Test with Chi-square Approximation for multiple classesfunsXsq.nnsym.dx Xsq.nnsym.dx Xsq.nnsym.dx.ct
Pielou's First Type of NN Symmetry Test with Chi-square Approximation for multiple classes (for Sparse Sampling)funsXsq.nnsym.ss Xsq.nnsym.ss Xsq.nnsym.ss.ct
Chi-square Test for Segregation CoefficientsfunsXsq.seg.coeff Xsq.seg.coeff Xsq.seg.coeff.ct
Overall Species Correspondence Test with Chi-square ApproximationfunsXsq.spec.cor Xsq.spec.cor Xsq.spec.cor.ct
Dixon's Cell-specific Z Tests of Segregation for NNCTfunsZcell.nnct Zcell.nnct Zcell.nnct.ct
p-values for Cell-specific Z Test Statistics for NNCTfunsZcell.nnct.pval Zcell.nnct.2s Zcell.nnct.ls Zcell.nnct.pval Zcell.nnct.rs
Cell-specific Z Tests of Segregation for NNCTscell.spec cell.spec.ct funsZcell.spec
Types I-IV Cell-specific Z Tests of Segregation based on NNCTsfunsZcell.tct Zcell.tct Zcell.tct.ct
Directional Segregation Test for Two Classes with Normal ApproximationfunsZdir.nnct Zdir.nnct Zdir.nnct.ct
Directional Segregation Test for Two Classes with Normal Approximation (for Sparse Sampling)funsZdir.nnct.ss Zdir.nnct.ss Zdir.nnct.ss.ct
Mixed-Non-Reflexivity Test with Normal ApproximationfunsZmixed.nonref Zmixed.nonref Zmixed.nonref.ct
Z Tests for NN ReflexivityfunsZnnref Znnref Znnref.ct
Self-Reflexivity Tests with Normal ApproximationfunsZnnself Znnself Znnself.ct
Cumulative Species Correspondence Test with Normal ApproximationfunsZnnself.sum Znnself.sum Znnself.sum.ct
Dixon's Pairwise NN Symmetry Test with Normal ApproximationfunsZnnsym.dx Znnsym.dx Znnsym.dx.ct
Pielou's Pairwise NN Symmetry Test with Normal Approximation (for Sparse Sampling)funsZnnsym.ss Znnsym.ss Znnsym.ss.ct
Dixon's NN Symmetry Test with Normal Approximation for Two ClassesfunsZnnsym2cl.dx Znnsym2cl.dx Znnsym2cl.dx.ct
Pielou's First Type of NN Symmetry Test with Normal Approximation for Two Classes (for Sparse Sampling)funsZnnsym2cl.ss Znnsym2cl.ss Znnsym2cl.ss.ct
Z Tests for Segregation CoefficientsfunsZseg.coeff Zseg.coeff Zseg.coeff.ct
Z Tests for Segregation IndicesfunsZsegind Zseg.ind Zseg.ind.ct
Self-Reflexivity Test with Normal ApproximationfunsZself.ref Zself.ref Zself.ref.ct
Z-Test for Cuzick and Edwards T_k^{inv} statisticfunsZTkinv ZTkinv ZTkinv.sim
Index Matrix for Computing the Covariance of Dixon's Overall NN Symmetry Testind.nnsym
Index Matrix for Computing the Covariance of Segregation Coefficientsind.seg.coeff
Interpoint Distance Matrixipd.mat
Euclidean Interpoint Distance Matrixipd.mat.euc
Finding the indices of the 'k' NNs of a given pointkNN
Conversion of a Matrix to a Vectormat2vec
Square root of a matrixmatrix.sqrt
Vector of Shared NNs and Number of Reflexive NNsNinv
Finding the index of the NN of a given pointNN
Nearest Neighbor Contingency Table (NNCT)nnct
Bootstrap Nearest Neighbor Contingency Table (NNCT)nnct.boot.dis
Nearest Neighbor Contingency Table (NNCT) with (only) base points restricted to a subsamplennct.sub
Distances between subjects and their NNsNNdist
Distances between subjects from class i and their NNs from class jNNdist2cl
nnspat: A package for NN Methods and Their Use in Testing Spatial Patternsnnspat
Finding the index of the NN of a given point among a subset of pointsNNsub
N_t Value (found with the definition formula)Nt.def
N_{tkl} ValueNtkl
Keeping the pair of the specified labels in the datapairwise.lab
Smallest and Largest Distances in a Distance Matrixpick.min.max
Probability of 'k' items selected from the class with size n_1pk
Plot a 'Clusters' objectplot.Clusters
Plot a 'SpatPatterns' objectplot.SpatPatterns
Print a summary of a 'cellhtest' objectprint.cellhtest
Print a summary of a 'Chisqtest' objectprint.Chisqtest
Print a summary of a 'classhtest' objectprint.classhtest
Print a 'Clusters' objectprint.Clusters
Print a summary of a 'refhtest' objectprint.refhtest
Print a 'SpatPatterns' objectprint.SpatPatterns
Print a summary of a 'Clusters' objectprint.summary.Clusters
Print a summary of a 'SpatPatterns' objectprint.summary.SpatPatterns
Probability of the current nearest neighbor contingency tableprob.nnct
Number of Shared and Reflexive NNsQRval
Q-symmetry Contingency Table (QCT)Qsym.ct
Pielou's Second Type of NN Symmetry Test with Chi-square ApproximationQsym.test
Generation of Points Associated with a Given Set of Pointsrassoc
Generation of Points Associated in the Type C Sense with a Given Set of PointsrassocC
Generation of Points Associated in the Type G Sense with a Given Set of PointsrassocG
Generation of Points Associated in the Type I Sense with a Given Set of PointsrassocI
Generation of Points Associated in the Type U Sense with a Given Set of PointsrassocU
Reflexivity Contingency Table (RCT)rct
Generation of Points with Clusters along the First Diagonalrdiag.clust
Generation of Points with Clusters along the Horizontal Axisrhor.clust
Non-Random Labeling of a Given Set of PointsrnonRL
Type I Non-Random Labeling of a Given Set of PointsrnonRLI
Type II Non-Random Labeling of a Given Set of PointsrnonRLII
Type III Non-Random Labeling of a Given Set of PointsrnonRLIII
Type IV Non-Random Labeling of a Given Set of PointsrnonRLIV
Generation of Points with Rotational Clustersrrot.clust
Generation of Points under Segregation of Two Classesrseg
Generation of Points from Self Correspondence Patternrself.ref
Generation of Uniform Points in a Circlerunif.circ
Dixon's Segregation Indices for NNCTsseg.ind
The Shared NN Vectors for Multiple ClassessharedNNmc
Skewness of Cuzick and Edwards T_k Test statisticSkewTk
Return a summary of a 'Clusters' objectsummary.Clusters
Return a summary of a 'SpatPatterns' objectsummary.SpatPatterns
Tree Species in a Swamp Forestswamptrees
Cuzick & Edwards Tcomb Test StatisticTcomb
T Contingency Table (TCT)tct
Tocher's randomized correction to the exact p-valuetocher.cor
T value in NN structureTval
Variances of Cell Counts in an NNCTvar.nnct
Variances of Differences of Off-Diagonal Entries in an NNCTvar.nnsym
Variances of Segregation Coefficients in a Multi-class Casevar.seg.coeff
Variances of Entries in a TCTvar.tct
Variance of Pielou's Segregation Coefficient for 2 ClassesvarPseg.coeff
Simulated Variance of Cuzick and Edwards T_k^{inv} Test statisticvarTkinv.sim
The incidence matrix 'W' for the NN digraphWmat
Chi-square Approximation to Cuzick and Edwards T_k Test statisticXsq.ceTk
Overall NN Symmetry Test with Chi-square ApproximationXsq.nnsym
Z-test for Cuzick and Edwards T_k statisticZceTk
NN Symmetry Test with Normal ApproximationZnnsym
NN Symmetry Test with Normal Approximation for Two ClassesZnnsym2cl
Z-test for Cuzick and Edwards T_{comb} statisticZTcomb
Z-test for Cuzick and Edwards T_{run} statisticZTrun