| Title: | Line Transect-Based Nearest Neighbor Distance Analysis |
|---|---|
| Description: | Conducting Line transect-based one-dimensional nearest neighbor distance and conducting hypothesis testing related to local distributional aggregation pattern of species. The reason that such a package is needed is because traditional two-dimensional nearest neighbor distance is not applicable when biodiversity data are sampled via optimal ecological survey methods, like line transects. In comparison to the entire studied region, line transect-collected local biodiversity data are spatially constrained and sampling-limited. To this end, two-dimensional nearest neighbor distance would tend to over-estimate distributional aggregation pattern of species when using this limited biodiversity information. Accordingly, one-dimensional nearest neighbor distance is needed and the associated statistical testing should be established for analyzing line transect-derived biodiversity data. |
| Authors: | Youhua Chen [aut, cre], Tsung-Jen Shen [aut], Xiaoqin Shi [ctb] |
| Maintainer: | Youhua Chen <[email protected]> |
| License: | GPL-3 |
| Version: | 1.3 |
| Built: | 2026-07-05 08:18:28 UTC |
| Source: | https://github.com/cran/Linda |
Linda-an R package for conducting (Lin)e transect-based nearest neighbor (d)istance (a)nalysis
Linda is an R package for calculating one-dimensional nearest neighbor distance (NND) and conducting hypothesis testing related to local distributional aggregation pattern of species. The reason that such a package is needed is because traditional two-dimensional NND is not applicable when biodiversity data are sampled via optimal ecological survey methods, like line transects. In comparison to the entire studied region, line transect-collected local biodiversity data are spatially constrained and sampling-limited. To this end, two-dimensional NND would tend to over-estimate distributional aggregation pattern of species when using this limited biodiversity information. Accordingly, one-dimensional NND is needed and the associated statistical testing should be established for analyzing line transect-derived biodiversity data. Our package, Linda, is developed to fulfill this biodiversity-inference task.
Youhua Chen (Chengdu Institute of Biology, Chinese Academy of Sciences);
Maintainer:
Youhua Chen <[email protected]>
Xiaoqin Shi, Yongbin Wu, Qi Xiao, Youhua Chen (2026) Linda: an R package using Line transect-based nearest neighbor distance analysis to infer distributional aggregation pattern of species. Plant Diversity.
x=cbind(1,runif(100)) x=rbind(x,cbind(2,runif(100))) x=rbind(x,cbind(3,runif(100))) lxy=cbind(x,1) lxy[,2]=sort(lxy[,2]) #sequentially sampled in an economic way LNND(lxy) #in empirical data, because we assume individuals have been recorded in sequential order #so the original data do not need to be sorted. #By contrast, in simulated data, if we assumed individuals are recorded in sequential order #and in an economic way #sort() function should be used.x=cbind(1,runif(100)) x=rbind(x,cbind(2,runif(100))) x=rbind(x,cbind(3,runif(100))) lxy=cbind(x,1) lxy[,2]=sort(lxy[,2]) #sequentially sampled in an economic way LNND(lxy) #in empirical data, because we assume individuals have been recorded in sequential order #so the original data do not need to be sorted. #By contrast, in simulated data, if we assumed individuals are recorded in sequential order #and in an economic way #sort() function should be used.
CECI is a function to compute the Clark and Evans' competition index, it computes the first nearest neighbor distance for all the spatial points using extensive two-dimensional circular area searching method.
CECI(xy, area = NULL, method = "NP")CECI(xy, area = NULL, method = "NP")
xy |
xy is a two-column matrix, containing x and y coordinates of recorded organisms in a single line transect |
area |
area is the size of given study area, the default is NULL and will be estimated from xy data. |
method |
method is the method to compute the index, "NP" is the default, indicating the loop-way computation; "P" indicates parallel computing. |
It returns the following quantities:
R |
the Clark and Evans' ratio value, which is the average of the observed NND versus the expected NND |
t1 |
the average of the observed NND for all distributional points |
t2 |
the expected NND under the perfect regularity pattern, details can be referred to Clark and Evans (1954). |
c |
the Z score value for testing significance |
p |
the p value for testing significance |
Tsung-Jen Shen & Youhua Chen
Clark P, Evans F (1954) Distance to nearest neighbor as a measure of spatial relationships in populations. Ecology, 35, 445–453.
xy=cbind(runif(100),runif(100)) plot(xy) CECI(xy)xy=cbind(runif(100),runif(100)) plot(xy) CECI(xy)
find nearest neighbor distance for each distributional point from multiple line transects and conduct hypothesis testing
LNND(lxy)LNND(lxy)
lxy |
lxy is three-column matrix, the first column is the line-transect ID, the second and third columns are x- and y-coordinate respectively. In line transect sampling, usually individuals of species are recorded in a sequential order, so the second and third columns should have been ordered in a time-forward way (backward is fine). Moreover, for the first column, IDs of different line transects should have been sorted according to time-forward sampling ordered. |
It returns the following quantities:
LR |
the one-dimensional NND ratio, which is the average of the observed one-dimensional NND versus the expected NND,weighted over different line transects |
t1 |
the average of the observed NND for all distributional points over different line transects |
t2 |
the expected NND under one-dimensional perfect regularity pattern, weighted over different line transects. More details can be referred to Chen et al. (2025) |
sig |
the pool-level standard error over different line transects |
c |
the Z score value for testing significance |
p |
the p value for testing significance |
df |
sample size, i.e., the total number of distributional points for analysis |
in empirical data provided by the users themselves, because we assume individuals have been recorded in a sequential order and different line transects have been ordered in a sequential order in lxy matrix. so the original data lxy do not need to be sorted and just be used as input directly.
Youhua Chen
Xiaoqin Shi, Yongbin Wu, Qi Xiao, Youhua Chen (2026) Linda: an R package using Line transect-based nearest neighbor distance analysis to infer distributional aggregation pattern of species. Plant Diversity.
x=cbind(1,runif(100)) x=rbind(x,cbind(2,runif(100))) x=rbind(x,cbind(3,runif(100))) lxy=cbind(x,1) lxy[,2]=sort(lxy[,2]) #sequentially sampled in an economic way LNND(lxy) #in empirical data, because we assume individuals have been recorded in sequential order #so the original data do not need to be sorted. #By contrast, in simulated data, if we assumed individuals are recorded in sequential order #and in an economic way #sort() function should be used.x=cbind(1,runif(100)) x=rbind(x,cbind(2,runif(100))) x=rbind(x,cbind(3,runif(100))) lxy=cbind(x,1) lxy[,2]=sort(lxy[,2]) #sequentially sampled in an economic way LNND(lxy) #in empirical data, because we assume individuals have been recorded in sequential order #so the original data do not need to be sorted. #By contrast, in simulated data, if we assumed individuals are recorded in sequential order #and in an economic way #sort() function should be used.
find nearest neighbor distance for each distributional point from a single line transect and conduct hypothesis testing
NND(xy, L = NULL)NND(xy, L = NULL)
xy |
xy is two column matrix, the first is x coordinate, and the second is y coordinate. because for line transect sampling, individuals are collected from sequential sampling, so xy should be ordered in a time-forward way (backward is fine) In other words, rows of xy matrix should be sorted according to sampling sequential orders. |
L |
L is the length of the line transect, can be given or calculated from the original data (if L=NULL). L=NULL is recommended and set as a default, because the given line transect length might over-estimate the aggregation pattern! |
It returns the following quantities:
R |
the one-dimensional NND ratio, which is the average of the observed one-dimensional NND versus the expected NND for a single targeted line transect |
ra |
the average of the observed NND for all distributional points for a single targeted line transect |
re |
the expected NND under one-dimensional perfect regularity pattern for a single line transect. More details can be referred to Chen et al. (2025) |
sig |
standard error for the targeted line transect |
c |
the Z score value for testing significance |
p |
the p value for testing significance |
df |
sample size, i.e., the total number of distributional points for analysis |
L |
the estimated or given line transect length |
in empirical data provided by the users themselves, because we assume individuals have been recorded in xy matrix in a sequential order, so the original data xy do not need to be sorted and just be used as input directly.
Youhua Chen
Xiaoqin Shi, Yongbin Wu, Qi Xiao, Youhua Chen (2026) Linda: an R package using Line transect-based nearest neighbor distance analysis to infer distributional aggregation pattern of species. Plant Diversity.
xy=cbind(sort(runif(100)),1) #sequentially sampled in an economic way NND(xy) #in empirical data, because we assume individuals have been recorded in sequential order #so the original data do not need to be sorted. #By contrast, in simulated data, if we assumed individuals are recorded in sequential order #and in an economic way #sort() function should be used.xy=cbind(sort(runif(100)),1) #sequentially sampled in an economic way NND(xy) #in empirical data, because we assume individuals have been recorded in sequential order #so the original data do not need to be sorted. #By contrast, in simulated data, if we assumed individuals are recorded in sequential order #and in an economic way #sort() function should be used.
estimation of the inertia parameter pi, more details can be referred to Chen et al. (2023). This parameter has been closely related to Moran's I index, more details can be referred to Chen and Shen (2020).
pi.est(z)pi.est(z)
z |
z is a vector of species labels for sequentially sampled individuals when walking across a line transect |
suppose we collect five individuals of three species along a line transect in sequential oder as "ABCAA", then the vector z=c("A","B","C","A","A")
the estimation of the inertia parameter is returned, and this value is bounded between 0 and 1.
in empirical data provided by the users themselves, because we assume individuals have been recorded in the vector z in a sequential order, so the original dataset z do not need to be sorted and just be used as input directly.
Tsung-Jen Shen
Chen et al. (2023) Biodiversity survey and estimation for line-transect sampling. Frontiers in Plant Science, 14: 1159090. Chen and Shen (2020) Unifying conspecific-encounter index v and Morans' I index. Ecography, 43, 1902-1904.
z=sample(1:5,100,replace=TRUE) pi.est(z)z=sample(1:5,100,replace=TRUE) pi.est(z)
this is the line transect-derived conspecific encounter index, which is also the estimator of pi by Solow (2000). Note that conspecific-encounter index for line transect sampling is completely different to the conventional Simpson diversity index, which is proposed as a conspecific-encounter index under random sampling.
v.est(z)v.est(z)
z |
z is a vector of species labels for sequentially sampled individuals when walking across a line transect |
suppose we collect five individuals of three species along a line transect in sequential oder as "ABCAA", then the vector z=c("A","B","C","A","A")
the conspecific-encounter index value is returned, and this value is bounded between 0 and 1.
in empirical data provided by the users themselves, because we assume individuals have been recorded in the vector z in a sequential order, so the original dataset z do not need to be sorted and just be used as input directly.
Youhua Chen & Tsung-Jen Shen
Chen et al. (2019) Inferring multispecies distributional aggregation level from limited line transect-derived biodiversity data. Methods in Ecology and Evolution, 10, 1015-1023. Solow A (2000) The effect of dependence on estimating sample coverage. Environmetrics, 11, 245-249.
z=sample(1:5,100,replace=TRUE) v.est(z)z=sample(1:5,100,replace=TRUE) v.est(z)