SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 1 Vol 2

COMPLETE SPATIAL RANDOMNESS

Name:
    COMPLETE SPATIAL RANDOMNESS
Type:
    Analysis Command
Purpose:
    Perform several tests for complete spatial randomness in the two-dimensional case.
Description:
    In spatial analysis, a common first step is to test the data for complete spatial randomness. If the data exhibits complete spatial randomness, this implies that there is no underlying structure in the data and therefore little to be gained from further analysis.

    In the univariate case, spatial randomness implies that the data points can be modeled with a uniform distribution. Likewise, in the two-dimensional case, spatial randomness implies that the data can be modeled with a bivariate uniform distribution with zero correlation between the two dimensions. So a quick graphical assessment of spatial randomness can be obtained by simply plotting the points. If there is complete spatial randomness, this plot should show no obvious structure.

    This command implements the following formal tests for complete spatial randomness:

    1. BIVARIATE CRAMER VON-MISES TEST

      The Cramer Von-Mises test is a common test for assessing distributional goodness of fit for a univariate dataset. Specifically, it can be used to test for univariate uniformity.

      Zimmerman (1993, see References below) describes an extension of the Cramer Von-Mises test for the case of bivariate uniformity. He modified the bivariate Cramer Von-Mises test so that it is invariant to which vertex of the enclosing rectangle is used as the origin.

      For this test, we have a set of n points defined in (X,Y). We also need the coordinates of the enclosing rectangle (if these are not given, they will be based on the data minimum and maximums). The test statistic is

        \( \begin{array}{lcl} \bar{w} & = & \frac{1}{4n}\sum_{i=1}^{n}{\sum_{i=1}^{n} {(1 - |u_{i} - u_{j}|) (1 - |v_{i} - v_{j}|)}} \\ & & - 0.5 \sum_{i=1}^{n}{(u_{i}^{2} - u_{i} - 0.5) (v_{i}^{2} - v_{i} - 0.5)} + \frac{n}{9} \end{array} \)

      where

        \( u_{i} = X_{i}/\mbox{XMAX} \)
        \( v_{i} = Y_{i}/\mbox{YMAX} \)

      The critical values for the test are taken from tables in the Zimmerman article and are provided for alpha levels 0.50, 0.75, 0.85, 0.90, 0.95, 0.98, and 0.99.

    2. MEAN NEAREST NEIGHBORS TEST

      The mean nearest neighbor distance test was first described by Clark and Evans (1954, see Refereces below). Dataplot implements a modified version of the Clark-Evans test due to Donnelly (1978) that is described in Zimmerman (1993).

      Given a set of N points (X,Y), the test statistic is

        \( T = \frac{\bar{Z} - \mu_{\bar{Z}}}{\sigma_{\bar{Z}}} \)

      where

        \( \bar{Z} = \frac{1}{n}\sum_{i=1}^{n}{Z_{i}} \)

        Zi is the distance from the i-th event to it's nearest neighbor

        \( \mu_{\bar{Z}} = 0.5 n^{-1/2} + 0.206 n^{-1} + 0.164 n^{-3/2} \)

        \( \sigma_{\bar{Z}} = 0.070 n^{-2} + 0.148 n^{-5/2} \)

      When there is complete spatial randomness, this statistic follows an approximately standard normal distribution.

    3. POLLARD TEST

      The Pollard test is also based on nearest neighbors. However, instead of the first nearest neighbor, we check the first through fifth nearest neighbors. The test implemented in Dataplot is a modified version of Pollard's test that is described in Fortin and Dale (2005).

      The Pollard test statistic is

        \( P_{j} = C_1 [n \ln(C_2) - C_3]/C_4 \)

      where

        \( C_1 = 12 j^{2} n \)

        \( C_2 = \sum_{i=1}^{n}{\frac{X_{ij}{2}}{n}} \)

        \( C_3 = \sum_{i=1}^{n}{\ln(X_{ij}^{2})} \)

        \( C_4 = (6 j n + n + 1) (n-1) \)

      and where

        j denotes the j-th nearest neighbor

        Xij is the distance from the i-th point to it's j-th nearest neighbor

        j is 1, 2, 3, 4, or 5

      Values of the test statistic near 1 indicate complete spatial randomness. Values less than 1 indicate overdispersion and values greater than 1 indicate underdispersion.

      (n-1) Pj has an approximately chi-square distribution with (n-1) degrees of freedom.

    Note that there are many ways in which the data can be non-random. In particular, a broad distinction is typically made between 1) random (i.e., complete spatial randomness); 2) underdispersed (clumped or aggregated); and 3) overdispersed (spaced or regular). In addition, non-randomness can be scale dependent. That is, non-randomness may appear either "locally" or "globably". For example, a set of points may appear random if examined in smaller subsets (i.e., local) but not if examined as a whole.

    A large number of tests have been developed to test for spatial randomness. These tests vary in what types of non-randomness they are sensitive to. According to Zimmerman, tests based on nearest neighbors tend to be sensitive to "local" non-randomness while being relatively insensitive to "global" characteristics. So these tests are quite good at detecting aggregation and regularity but not good at detecting heterogeneity. On the other hand, the bivariate Cramer Von Mises test is more senstive to global characteristics and less sensitive to local characteristics. So it tends to be good at detecting heterogeneity but not as good at detecting aggregation and regularity. The Pollard test expands the "local" neighborhood by looking at the first through fifth nearest neighbors rather than just the single nearest neighbor. So taken together, this combination of tests should be able to detect many different types of non-randomness.

Syntax:
    COMPLETE SPATIAL RANDOMNESS <x> <y>
                            <SUBSET/EXCEPT/FOR qualification>
    where <x> is a response variable;
                <y> is a factor identifier variable;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.
Examples:
    COMPLETE SPATIAL RANDOMNESS X Y
Note:
    For the bivariate Cramer Von-Mises test, the boundaries of the enclosing rectangle can be specified by entering the commands

      LET XMIN = <value>
      LET XMAX = <value>
      LET YMIN = <value>
      LET YMAX = <value>
Note:
    The following statistics are also supported:

      LET A = BIVARIATE CRAMER VON MISES TEST X Y
      LET A = BIVARIATE CRAMER VON MISES TEST CV95 X Y
      LET A = BIVARIATE CRAMER VON MISES TEST CV05 X Y

      LET A = MEAN NEAREST NEIGHBOR DISTANCE TEST X Y
      LET A = MEAN NEAREST NEIGHBOR DISTANCE CDF X Y
      LET A = MEAN NEAREST NEIGHBOR DISTANCE PVALUE X Y

      LET A = POLLARD <ONE/TWO/THREE/FOUR/FIVE> TEST X Y
      LET A = POLLARD <ONE/TWO/THREE/FOUR/FIVE> CDF X Y
      LET A = POLLARD <ONE/TWO/THREE/FOUR/FIVE> PVALUE X Y

    Dataplot statistics can be used in a number of commands. For details, enter

Default:
    None
Synonyms:
    None
Related Commands: Reference:
    Dale Zimmerman (1993), "A Bivariate Cramer-Von Mises Type of Test For Spatial Randomness", Journal of the Royal Statistical Society, Series C, Applied Statistics, Vol. 42, No. 1, pp. 43-54.

    Clark and Evans (1954), "Distance to Nearest Neighbor as a Measure of Spatial Relationships in Populations", Ecology, 35, pp. 23-30.

    Donnelly (1978), "Simulations to Determine the Variance and Edge-Effect of Total Nearest-Neighbor Distance", in Simulation Studies in Archaeology (ed. Hodder), pp. 91-95, London: Cambridge University Press.

    Fortin and Dale (2005), "Spatial Analysis: A Guide for Ecologists", Cambridge University Press, pp. 34-35.

    Pollard (1971), "On Distance Estimators of Density in Randomly Distributed Forests", Biometrics, 27, pp. 991-1002.

    Liu (2001), "A Comparison of Five Distance-Based Methods for Pattern Analysis", Journal of Vegetation Science, 12, pp. 411-416.

Applications:
    Spatial Analysis
Implementation Date:
    2014/1
Program:
     
    . Step 1:   Generate some random points.
    .
    let lowlim = data 0 0
    let upplim = data 1 1
    let n = 40
    let m = independent uniform random numbers lowlim upplim n
    let y = m1
    let x = m2
    . 
    . Step 2:   Plot the uniform random numbers
    .
    char circle
    char fill on
    char hw 0.5 0.375
    line blank
    plot y x
    .
    . Step 3:   Complete Spatial Randomness Test
    .
    set write decimals 3
    complete spatial randomness test y x
        
    The following output is generated
                 Bivariate Cramer Von-Mises Test
                 for Complete Spatial Randomness
      
     First Response Variable: Y
     Second Response Variable: X
      
     H0: Complete Spatial Randomness
     Ha: Not Complete Spatial Randomness
      
     Number of Observations:                              40
     Data Minimum for X:                               0.001
     Data Maximum for X:                               0.973
     Data Minimum for Y:                               0.035
     Data Maximum for Y:                               0.970
      
     Test Statistic Value:                             0.177
      
      
     Percent Points of the Reference Distribution
     -----------------------------------
       Percent Point               Value
     -----------------------------------
                0.01    =          0.043
                0.02    =          0.049
                0.05    =          0.057
                0.10    =          0.066
                0.15    =          0.075
                0.25    =          0.088
                0.50    =          0.122
                0.75    =          0.171
                0.85    =          0.206
                0.90    =          0.234
                0.95    =          0.281
                0.98    =          0.342
                0.99    =          0.389
      
     Conclusions (Two-Tailed Test)
     --------------------------------------------------------
                        Lower            Upper
       Alpha   Critical Value   Critical Value     Conclusion
     --------------------------------------------------------
         20%            0.066            0.234      Accept H0
         10%            0.057            0.281      Accept H0
          4%            0.049            0.342      Accept H0
          2%            0.043            0.389      Accept H0
      
      
                 Mean Nearest Neighbors Test
                 for Complete Spatial Randomness
      
     First Response Variable: Y
     Second Response Variable: X
      
     H0: Complete Spatial Randomness
     Ha: Not Complete Spatial Randomness
      
     Number of Observations:                              40
      
     Test Statistic Value:                            -0.028
     Test Statistic CDF:                               0.489
     Test Statistic P-Value:                           0.978
      
      
                 Two-Tailed Test for Complete Spatial Randomness
      
     H0: Complete Spatial Randomness
     ------------------------------------------------------------
                                                             Null
        Significance           Test       Critical     Hypothesis
               Level      Statistic    Value (+/-)     Conclusion
     ------------------------------------------------------------
                 50%         -0.028          0.674         ACCEPT
                 75%         -0.028          1.149         ACCEPT
                 80%         -0.028          1.282         ACCEPT
                 90%         -0.028          1.645         ACCEPT
                 95%         -0.028          1.960         ACCEPT
                 99%         -0.028          2.576         ACCEPT
               99.9%         -0.028          3.290         ACCEPT
      
      
                 Pollard Statistic Test (index = 1)
                  for Complete Spatial Randomness
      
     First Response Variable: Y
     Second Response Variable: X
      
     H0: Complete Spatial Randomness
     Ha: Not Complete Spatial Randomness
      
     Number of Observations:                              40
     Nearest Neighbor Index:                               1
      
     Test Statistic Value:                             1.014
     Adjusted Test Statistic Value:                   39.545
     Test Statistic CDF:                               0.489
     Test Statistic P-Value:                           0.978
      
      
                 Two-Tailed Test for Complete Spatial Randomness
      
     H0: Complete Spatial Randomness
     ---------------------------------------------------------------------------
                                             Lower          Upper           Null
        Significance           Test       Critical       Critical     Hypothesis
               Level      Statistic    Value (+/-)    Value (+/-)     Conclusion
     ---------------------------------------------------------------------------
                 50%         39.545         32.737         44.539         ACCEPT
                 75%         39.545         29.138         49.292         ACCEPT
                 80%         39.545         28.196         50.659         ACCEPT
                 90%         39.545         25.695         54.572         ACCEPT
                 95%         39.545         23.653         58.119         ACCEPT
                 99%         39.545         19.995         65.475         ACCEPT
               99.9%         39.545         16.272         74.724         ACCEPT
      
      
                 Pollard Statistic Test (index = 2)
                  for Complete Spatial Randomness
      
     First Response Variable: Y
     Second Response Variable: X
      
     H0: Complete Spatial Randomness
     Ha: Not Complete Spatial Randomness
      
     Number of Observations:                              40
     Nearest Neighbor Index:                               2
      
     Test Statistic Value:                             0.760
     Adjusted Test Statistic Value:                   29.628
     Test Statistic CDF:                               0.489
     Test Statistic P-Value:                           0.978
      
      
                 Two-Tailed Test for Complete Spatial Randomness
      
     H0: Complete Spatial Randomness
     ---------------------------------------------------------------------------
                                             Lower          Upper           Null
        Significance           Test       Critical       Critical     Hypothesis
               Level      Statistic    Value (+/-)    Value (+/-)     Conclusion
     ---------------------------------------------------------------------------
                 50%         29.628         32.737         44.539         REJECT
                 75%         29.628         29.138         49.292         ACCEPT
                 80%         29.628         28.196         50.659         ACCEPT
                 90%         29.628         25.695         54.572         ACCEPT
                 95%         29.628         23.653         58.119         ACCEPT
                 99%         29.628         19.995         65.475         ACCEPT
               99.9%         29.628         16.272         74.724         ACCEPT
      
      
                 Pollard Statistic Test (index = 3)
                  for Complete Spatial Randomness
      
     First Response Variable: Y
     Second Response Variable: X
      
     H0: Complete Spatial Randomness
     Ha: Not Complete Spatial Randomness
      
     Number of Observations:                              40
     Nearest Neighbor Index:                               3
      
     Test Statistic Value:                             0.998
     Adjusted Test Statistic Value:                   38.923
     Test Statistic CDF:                               0.489
     Test Statistic P-Value:                           0.978
      
      
                 Two-Tailed Test for Complete Spatial Randomness
      
     H0: Complete Spatial Randomness
     ---------------------------------------------------------------------------
                                             Lower          Upper           Null
        Significance           Test       Critical       Critical     Hypothesis
               Level      Statistic    Value (+/-)    Value (+/-)     Conclusion
     ---------------------------------------------------------------------------
                 50%         38.923         32.737         44.539         ACCEPT
                 75%         38.923         29.138         49.292         ACCEPT
                 80%         38.923         28.196         50.659         ACCEPT
                 90%         38.923         25.695         54.572         ACCEPT
                 95%         38.923         23.653         58.119         ACCEPT
                 99%         38.923         19.995         65.475         ACCEPT
               99.9%         38.923         16.272         74.724         ACCEPT
      
      
                 Pollard Statistic Test (index = 4)
                  for Complete Spatial Randomness
      
     First Response Variable: Y
     Second Response Variable: X
      
     H0: Complete Spatial Randomness
     Ha: Not Complete Spatial Randomness
      
     Number of Observations:                              40
     Nearest Neighbor Index:                               4
      
     Test Statistic Value:                             0.814
     Adjusted Test Statistic Value:                   31.750
     Test Statistic CDF:                               0.489
     Test Statistic P-Value:                           0.978
      
      
                 Two-Tailed Test for Complete Spatial Randomness
      
     H0: Complete Spatial Randomness
     ---------------------------------------------------------------------------
                                             Lower          Upper           Null
        Significance           Test       Critical       Critical     Hypothesis
               Level      Statistic    Value (+/-)    Value (+/-)     Conclusion
     ---------------------------------------------------------------------------
                 50%         31.750         32.737         44.539         REJECT
                 75%         31.750         29.138         49.292         ACCEPT
                 80%         31.750         28.196         50.659         ACCEPT
                 90%         31.750         25.695         54.572         ACCEPT
                 95%         31.750         23.653         58.119         ACCEPT
                 99%         31.750         19.995         65.475         ACCEPT
               99.9%         31.750         16.272         74.724         ACCEPT
      
      
                 Pollard Statistic Test (index = 5)
                  for Complete Spatial Randomness
      
     First Response Variable: Y
     Second Response Variable: X
      
     H0: Complete Spatial Randomness
     Ha: Not Complete Spatial Randomness
      
     Number of Observations:                              40
     Nearest Neighbor Index:                               5
      
     Test Statistic Value:                             0.867
     Adjusted Test Statistic Value:                   33.831
     Test Statistic CDF:                               0.489
     Test Statistic P-Value:                           0.978
      
      
                 Two-Tailed Test for Complete Spatial Randomness
      
     H0: Complete Spatial Randomness
     ---------------------------------------------------------------------------
                                             Lower          Upper           Null
        Significance           Test       Critical       Critical     Hypothesis
               Level      Statistic    Value (+/-)    Value (+/-)     Conclusion
     ---------------------------------------------------------------------------
                 50%         33.831         32.737         44.539         ACCEPT
                 75%         33.831         29.138         49.292         ACCEPT
                 80%         33.831         28.196         50.659         ACCEPT
                 90%         33.831         25.695         54.572         ACCEPT
                 95%         33.831         23.653         58.119         ACCEPT
                 99%         33.831         19.995         65.475         ACCEPT
               99.9%         33.831         16.272         74.724         ACCEPT
        
    . 
    . Step 4:   Demonstrate how to extract individual statistics
    .
    let tval  = mean nearest neighor distance test   x y
    let tcdf  = mean nearest neighor distance cdf    x y
    let tpval = mean nearest neighor distance pvalue x y
    print tval tcdf tpval
        
     PARAMETERS AND CONSTANTS--
    
        TVAL    --          0.489
        TCDF    --         -0.028
        TPVAL   --          0.978
        
    let bval  = bivariate cramer von mises test x y
    let cv95  = bivariate cramer von mises 95 critical value x y
    let cv05  = bivariate cramer von mises 05 critical value x y
    print bval cv95 cv05
        
     PARAMETERS AND CONSTANTS--
    
        BVAL    --          0.177
        CV95    --          0.281
        CV05    --          0.057
        
    let xmin = 0
    let xmax = 1
    let ymin = 0
    let ymax = 1
    let bval2  = bivariate cramer von mises test x y
        
     PARAMETERS AND CONSTANTS--
    
        BVAL2   --          0.145
        CV95    --          0.281
        CV05    --          0.057
    .
    let pol1     = pollard one test   x y
    let pol1cdf  = pollard one cdf    x y
    let pol1pval = pollard one pvalue x y
    print pol1 pol1cdf pol1pval
        
     PARAMETERS AND CONSTANTS--
    
        POL1    --          1.014
        POL1CDF --          0.554
        POL1PVAL--          0.891
        
    .
    let pol2     = pollard two test   x y
    let pol2cdf  = pollard two cdf    x y
    let pol2pval = pollard two pvalue x y
    print pol2 pol2cdf pol2pval
        
     PARAMETERS AND CONSTANTS--
    
        POL2    --          0.760
        POL2CDF --          0.139
        POL2PVAL--          0.279
        
    .
    let pol3     = pollard three test   x y
    let pol3cdf  = pollard three cdf    x y
    let pol3pval = pollard three pvalue x y
    print pol3 pol3cdf pol3pval
        
     PARAMETERS AND CONSTANTS--
    
        POL3    --          0.998
        POL3CDF --          0.527
        POL3PVAL--          0.947
        
    .
    let pol4     = pollard four test   x y
    let pol4cdf  = pollard four cdf    x y
    let pol4pval = pollard four pvalue x y
    print pol4 pol4cdf pol4pval
        
     PARAMETERS AND CONSTANTS--
    
        POL4    --          0.814
        POL4CDF --          0.211
        POL4PVAL--          0.423
        
    .
    let pol5     = pollard five test   x y
    let pol5cdf  = pollard five cdf    x y
    let pol5pval = pollard five pvalue x y
    print pol5 pol5cdf pol5pval
        
     PARAMETERS AND CONSTANTS--
    
        POL5    --          0.867
        POL5CDF --          0.296
        POL5PVAL--          0.591
        
        
Date created: 09/11/2014
Last updated: 12/11/2023

Please email comments on this WWW page to alan.heckert@nist.gov.