Description Usage Arguments Details Value Author(s) References See Also Examples
This function allows to generate spatially-constrained random variables preserving the global autocorrelation (Moran's I) and the spatial structures at multiple scales. Multiscale property is defined by the power spectrum (i.e. decomposition of the variance of the original variables) on a basis of orthonormal eigenvectors (Moran's Eigenvector Maps, MEM). The function provides methods for univariate randomization, joint randomization of a group of variables while keeping within-group correlations fixed and univariate randomization with a fixed correlation between original data and randomized replicates.
1 2  | 
x | 
 a   | 
listwORorthobasis | 
 an object of the class   | 
nrepet | 
 an   | 
method | 
 an character specifying which algorithm should be used to produce spatial replicates (see Details).  | 
cor.fixed | 
 if not missing, the level of correlation between the original variable and its randomized replicates  | 
nmax | 
 the number of trials used in the "triplet" procedure.  | 
simplify | 
 A logical value. If   | 
Three procedures are implemented in the function. The "pair" procedure is the more general as it can be applied in the three cases (univariate, univariate with fixed correlation and multivariate). This procedure preserves the power spectrum by pair of MEMs but not strictly the global autocorrelation level (Moran's I). The "singleton" procedure can be used for univariate and multivariate cases. It preserves strictly the global level of autocorrelation and the power spectrum. The "triplet" procedure can only be applied in the univariate case. It preserves the power spectrum by triplet of MEMs and strictly the global autocorrelation level.
Either a matrix (if simplify is TRUE) or a list with
randomized replicates.
Stephane Dray stephane.dray@univ-lyon1.fr and Helene H Wagner helene.wagner@utoronto.ca
Wagner, H.H. and Dray S. (2015) Generating spatially-constrained null models for irregularly spaced data using Moran spectral randomization methods
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38  | library(spdep)
x1 <- matrix(rnorm(81*5), nrow = 81)
lw1 <- nb2listw(cell2nb(9, 9))
moran.mc(x1[,1], lw1, 2)$statistic
## singleton
x1.1 <- msr(x1[,1], lw1, nrepet = 9, method = "singleton")
apply(x1.1, 2, function(x) moran.mc(x, listw = lw1, nsim = 2)$statistic)
## triplet
x1.2 <- msr(x1[,1], lw1, nrepet = 9, method = "triplet")
apply(x1.2, 2, function(x) moran.mc(x, listw = lw1, nsim = 2)$statistic)
## pair
x1.3 <- msr(x1[,1], lw1, nrepet = 9, method = "pair")
apply(x1.3, 2, function(x) moran.mc(x, listw = lw1, nsim = 2)$statistic)
## pair with cor.fixed
x1.4 <- msr(x1[,1], lw1, nrepet = 9, cor.fixed = 0.5)
apply(x1.4, 2, function(x) moran.mc(x, listw = lw1, nsim = 2)$statistic)
cor(x1[,1], x1.4)
## pair preserving correlations for multivariate data
x1.5 <- msr(x1, lw1, nrepet = 9, cor.fixed = 0.5)
cor(x1)
lapply(x1.5, cor)
apply(x1, 2, function(x) moran.mc(x, listw = lw1, nsim = 2)$statistic)
apply(x1.5[[1]], 2, function(x) moran.mc(x, listw = lw1, nsim = 2)$statistic)
## singleton preserving correlations for multivariate data
x1.6 <- msr(x1, lw1, nrepet = 9, method = "singleton")
cor(x1)
lapply(x1.6, cor)
apply(x1, 2, function(x) moran.mc(x, listw = lw1, nsim = 2)$statistic)
apply(x1.6[[1]], 2, function(x) moran.mc(x, listw = lw1, nsim = 2)$statistic)
 | 
Registered S3 methods overwritten by 'adegraphics':
  method         from
  biplot.dudi    ade4
  kplot.foucart  ade4
  kplot.mcoa     ade4
  kplot.mfa      ade4
  kplot.pta      ade4
  kplot.sepan    ade4
  kplot.statis   ade4
  scatter.coa    ade4
  scatter.dudi   ade4
  scatter.nipals ade4
  scatter.pco    ade4
  score.acm      ade4
  score.mix      ade4
  score.pca      ade4
  screeplot.dudi ade4
Registered S3 method overwritten by 'spdep':
  method   from
  plot.mst ape 
Registered S3 methods overwritten by 'adespatial':
  method             from       
  plot.multispati    adegraphics
  print.multispati   ade4       
  summary.multispati ade4       
Loading required package: sp
Loading required package: spData
To access larger datasets in this package, install the spDataLarge
package with: `install.packages('spDataLarge',
repos='https://nowosad.github.io/drat/', type='source')`
Loading required package: sf
Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
  statistic 
0.005473461 
[1] 0.005473461 0.005473461 0.005473461 0.005473461 0.005473461 0.005473461
[7] 0.005473461 0.005473461 0.005473461
[1] 0.005473461 0.005473461 0.005473461 0.005473461 0.005473461 0.005473461
[7] 0.005473461 0.005473461 0.005473461
[1]  0.0018640994 -0.0008526903  0.0048132034 -0.0016266943  0.0029023627
[6] -0.0043914763  0.0002661407 -0.0046162051 -0.0035681100
[1] -0.0002684298 -0.0037324849  0.0008879352 -0.0026023747 -0.0014087511
[6] -0.0057628513 -0.0023621150 -0.0020706085 -0.0002162435
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,]  0.5  0.5  0.5  0.5  0.5  0.5  0.5  0.5  0.5
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[1]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[2]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[3]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[4]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[5]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[6]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[7]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[8]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[9]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[1]  0.0054734606  0.1201329327 -0.0864690562 -0.0256945645 -0.0001781331
[1]  0.001789976  0.126765900 -0.082323912 -0.026963819  0.001891579
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[1]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[2]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[3]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[4]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[5]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[6]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[7]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[8]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[[9]]
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,]  1.00000000  0.19704292  0.02704586 -0.03659142  0.01186029
[2,]  0.19704292  1.00000000  0.06915438 -0.16207077 -0.16990708
[3,]  0.02704586  0.06915438  1.00000000 -0.15454345  0.14949111
[4,] -0.03659142 -0.16207077 -0.15454345  1.00000000  0.14745899
[5,]  0.01186029 -0.16990708  0.14949111  0.14745899  1.00000000
[1]  0.0054734606  0.1201329327 -0.0864690562 -0.0256945645 -0.0001781331
[1]  0.0054734606  0.1201329327 -0.0864690562 -0.0256945645 -0.0001781331
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.