Learn R Programming

ecespa (version 1.1-17)

syrjala: Syrjala's test for the difference between the spatial distributions of two populations

Description

Computes a two-sample Cramer-von Mises (and Kolmogorov-Smirnov) type test for a difference between the spatial distributions of two populations. It is designed to be sensitive to differences in the way the populations are distributed across the study area but insensitive to differences in abundance between the two populations.

Usage

syrjala0(coords, var1, var2, nsim, R=FALSE)
syrjala(coords = NULL, var1 = NULL, var2 = NULL, nperm = 999)
syrjala.test(ppp1, ppp2, nsim = 999)
# S3 method for syrjala.test
plot(x, coline=1, ...)
# S3 method for ecespa.syrjala
plot(x, ...)

Value

Functions syrjala or syrjala0 (with the argument R=FALSE) return an object of class 'syrjala.test'. Functions syrjala.test or syrjala0 (with the argument R=TRUE) return an object of class 'ecespa.syrjala'. In Both cases, the result is a list with the following elements:

cvm.obs

(class syrjala.test). The observed (averaged) \(psi\) statistic for the CvM test.

cvm.sim

(class syrjala.test). A numeric vector with the nperm+1 simulated \(psi\)'s statistics (including cvm.obs).

ks.obs

(class syrjala.test). The observed (averaged) \(psi\) statistic for the K-S test.

ks.sim

(class syrjala.test). A numeric vector with the nperm+1 simulated \(psi\)'s statistics (including ks.obs).

datanames

(class syrjala.test). A character vector with the names of the two patterns, the spatial congruence of which is been analyzed.

nperm

(class syrjala.test). The number of permutations employed in the test (not counting the original data).

psi.obs

(class ecespa.syrjala).The observed (averaged) \(psi\) statistic.

psi.sim

(class ecespa.syrjala). A vector with the nsim simulated \(psi\)'s statistics.

datanames

(class ecespa.syrjala). A vector with the names of the two point patterns whose spatial congruence is been analyzed.

nsim

(class ecespa.syrjala). The number of permutations employed in the test.

Both S3 plot methods plot an histogram with the distribution of the simulated \(psi\)'s statistics and draws the observed \(psi\) as a vertical line.

Arguments

coords

A data.frame with `$x` and `$y` components.

var1

The first numeric variable

var2

The second numeric variable.

nperm

Number of permutations.

nsim

Number of permutations.

R

Logical. Should be computed using R approach?

ppp1

A marked point pattern, with the ppp format of spatstat, representing the values of some parameter measured on the corresponding sampling locations.

ppp2

A marked point pattern, with the ppp format of spatstat, representing the values of some other parameter measured on the same locations than ppp1.

x

An object of class 'syrjala.test' or 'ecespa.syrjala' resulting from syrjala or syrjala.test, respectively.

coline

color for drawing the statistic's line in the plot.

...

Graphical parameters passed to hist.

Warning

The test requires both populations being sampled in exactly the same sampling locations. Althoug this implementation employs ppp's as the supporting data format, this kind of data are not spatial point patterns. They cannot be analysed with the usual tools employed for marked point patterns.

Author

Jose M. Blanco-Moreno jmblanco@ub.edu for the Fortran implementation of Syrjala's original QBasic function, Marcelino de la Cruz Rot for the R version, the wrapping functions and the documentation

Details

The null hypothesis of Syrjala's test is that across the study area, the normalized distributions of the two populations are the same (Syrjala, 1996). Population density data are collected at \(K\) sampling locations on two populations. Let \((xk, yk)\) denote the coordinates of the \(kth\) sampling location (\( k= 1,...,K\) ); let \(d.i(xk, yk)\) denote the sample density at the \(Kth\) sampling location of the \(ith\) population. To construct a test that is independent of the population sizes, the observed density data is first normalized: $$gamma.i(xk, yk) = di(xk, yk)/Di,$$ where \(Di\) is the sum of \(d.i(xk, yk)\) observations across the \(K\) sampling locations. The value of the cumulative distribution function at the location \((xk, yk)\) for the \(ith\) population, denoted \(GAMMA.i(xk, yk)\), is the sum of all normalized density observations, \(gamma.i(xk, yk)\), whose location \((x, y)\) is such that \(x <= xk\) and \(y <= yk\). The statistic proposed by Syrjala to test the null hypothesis is the square of the difference between the cumulative distribution functions of the two populations, summed over all sampling locations, that is $$psi = sum{GAMMA.1(xk, yk) - GAMMA.2(xk, yk)}^2.$$ As \(psi\) is not invariant with respect to the 'corner' of the rectangle enclosing the study area that is chosen as the origin of the coordinate sytem, \(psi\) is computed four times, one with each corner as the origin, and the average \(psi\) is employed as the test statistic. The level of significance of the observed \(psi\) is determined from its position in the ordered set of test statistic values from all \(2^K\) pairwise permutations (that is approximated from a large number of randomly selected permutations).

References

Rey-Benayas, J.M., de la Montaña, E., Pérez-Camacho, L., de la Cruz, M., Moreno, D., Parejo, J.L. and Suárez-Seoane, S. 2010. Inter-annual dynamics and spatial congruence of a nocturnal bird assemblage inhabiting a Mediterranean agricultural mosaic. Ardeola,57(2): 303-320.

Syrjala, S. E. 1996. A statistical test for a difference between the spatial distributions of two populations. Ecology 77: 75-80. tools:::Rd_expr_doi("10.2307/2265656").

Examples

Run this code

   
   data(syr1); data(syr2); data(syr3)
   
   coords <- data.frame(x=syr1$x, y=syr1$y); var1<- syr1$marks; var2<- syr2$marks
   
   (stest<-syrjala(coords, var1, var2, 9999))
   plot(stest)
   
   
   if (FALSE) {
   
   plot(syrjala.test(syr1, syr2, nsim=999)) 
   
   plot(syrjala.test(syr1, syr3, nsim=999)) 
   
   syrjala0(coords, var1, var2, 9999)
   
   syrjala0(coords, var1, var2, 999, R=TRUE)
   
   
   coords <- expand.grid(x=1:10,y=1:10)
   var1 <- runif(100)
   var2 <- runif(100)
   syrjala(coords, var1, var2, 9999)
   
   
}

Run the code above in your browser using DataLab