R/scores.listw.R
mem.Rd
These functions compute MEM (i.e., eigenvectors of a doubly centered spatial weighting matrix). Corresponding eigenvalues are linearly related to Moran's index of spatial autocorrelation.
scores.listw(
listw,
wt = rep(1, length(listw$neighbours)),
MEM.autocor = c("non-null", "all", "positive", "negative"),
store.listw = FALSE
)
mem(
listw,
wt = rep(1, length(listw$neighbours)),
MEM.autocor = c("non-null", "all", "positive", "negative"),
store.listw = FALSE
)
orthobasis.listw(
listw,
wt = rep(1, length(listw$neighbours)),
MEM.autocor = c("non-null", "all", "positive", "negative"),
store.listw = FALSE
)
# S3 method for class 'orthobasisSp'
x[i, j, drop = TRUE]
An object of the class listw
created by functions of the
spdep
package
A vector of weights. It is used to orthogonalize the eigenvectors. It could be useful if MEM are used in weighted regression or canonical correspondence analysis
A string indicating if all MEMs must be returned or only
those corresponding to non-null, positive or negative autocorrelation. The
difference between options all
and non-null
is the following:
when there are several null eigenvalues, option all
removes only one
of the eigenvectors with null eigenvalues and returns (n-1) eigenvectors,
whereas non-null
does not return any of the eigenvectors with null
eigenvalues.
A logical indicating if the spatial weighting matrix
should be stored in the attribute listw
of the returned object
An object of class orthobasisSp
.
Elements to extract (integer or empty): index of rows (i) and columns (j).
A logical. If TRUE, object containing only one colum is converted in vector
An object of class orthobasisSp
, subclass orthobasis
.
The MEMs are stored as a data.frame
. It contains several attributes
(see ?attributes
) including:
listw
: The associated spatial
weighting matrix (if store.listw = TRUE
).
Testing the nullity of eigenvalues is based on E(i)/E(1) where E(i) is i-th eigenvalue and E(1) is the maximum absolute value of eigenvalues
Dray, S., Legendre, P., and Peres-Neto, P. R. (2006). Spatial modeling: a comprehensive framework for principal coordinate analysis of neighbor matrices (PCNM). Ecological Modelling 196, 483–493.
Griffith D. A. (1996) Spatial autocorrelation and eigenfunctions of the geographic weights matrix accompanying geo-referenced data. Canadian Geographer 40, 351–367.
if(require("ade4", quietly = TRUE) & require("spdep", quietly = TRUE)){
data(oribatid)
nbtri <- tri2nb(as.matrix(oribatid$xy))
sc.tri <- scores.listw(nb2listw(nbtri, style = "B"))
summary(sc.tri)
}
#> Orthonormal basis: data.frame with 70 rows and 69 columns
#> ----------------------------------------------------------------
#> Columns form a centred orthonormal basis (i.e. 1n-orthogonal)
#> for the inner product defined by the 'weights' attribute
#> ----------------------------------------------------------------
#>
#> Attributes:
#> - names: MEM1 ... MEM69
#> - row.names: 1 ... 70
#> - weights: 0.01428571 ... 0.01428571
#> - values: 0.07805391 ... -0.04134591
#> - class: orthobasisSp orthobasis data.frame
#> - call: scores.listw(listw = nb2listw(nbtri, style = "B"))
#>
if(require("adegraphics", quietly = TRUE)){
s.value(oribatid$xy,sc.tri[,1:9])
plot(sc.tri[,1:6], oribatid$xy, pSp.cex = 5, pSp.alpha = 0.5, pbackground.col = 'lightblue')
}
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'obj' in selecting a method for function 'coordinates': object 'sc.tri' not found