R/test.W.R
test.W.Rd
This function is now deprecated. Please try the new listw.candidates
and
listw.select
functions.
test.W(
Y,
nb,
xy,
MEM.autocor = c("all", "positive", "negative"),
f = NULL,
...
)
A matrix with response variables (univariate or multivariate response)
An object of the class nb
created by functions of the
spdep
package
Coordinates of the samples, this argument is optional and is
required only if the argument f
is not null.
A string indicating if all MEM must be returned or only those corresponding to positive or negative autocorrelation
A function of the distance that can be used as a weighting spatial function. This argument is optional
Others arguments for the function f
. It defines the range
of parameters which will be tested
A list with the following elements:
A data.frame where each row correspond to one spatial weighting matrix tested. It contains value of parameteres tested and corrected AIC and number of orthogonal vectors for the best model.
A list containing results of scores.listw and ortho.AIC of the best spatial weighting matrix according to corrected AIC.
This function is a user-friendly way to compute and test eigenvectors for
various definitions of spatial weighting matrices. It combines calls to the
functions scores.listw
and ortho.AIC
. It allows to test various
definitions of the spatial weighting matrix and return results of
scores.listw
for the best one.
This functions allows to test one binary spatial weighting matrix
(if only Y and nb are provided). It allows also to test a weighting
function based on distances (if f is provided) and a weighting function
with different values of parameters if other arguments of f
are
provided.
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
if(require(ade4) & require(spdep)){
data(oribatid)
# Hellinger transformation
fau <- sqrt(oribatid$fau / outer(apply(oribatid$fau, 1, sum), rep(1, ncol(oribatid$fau)), "*"))
# remove gradient effect
faudt <- resid(lm(as.matrix(fau) ~ as.matrix(oribatid$xy)))
# test a binary spatial weighting matrix
nbtri <- tri2nb(as.matrix(oribatid$xy))
tri.res <- test.W(faudt, nbtri)
maxi <- max(unlist(nbdists(nbtri, as.matrix(oribatid$xy))))
# test a simple spatial weighting function of the distance
f1 <- function(x) {1-(x)/(maxi)}
tri.f1 <- test.W(faudt, nbtri, f = f1, xy = as.matrix(oribatid$xy))
# test a spatial weighting function with various values of parameters
f2 <- function(x,dmax,y) {1-(x^y)/(dmax)^y}
tri.f2 <- test.W(faudt,nbtri, f = f2, y = 2:10, dmax = maxi, xy = as.matrix(oribatid$xy))
}
#> Warning: This function is now deprecated. Please try the new 'listw.select' function.
#> Warning: This function is now deprecated. Please try the new 'mem.select' function.
#>
#>
#> AICc for the null model: -87.47112034786
#>
#> Best spatial model:
#> AICc NbVar
#> MEM5 -94.18844 7
#> Warning: This function is now deprecated. Please try the new 'listw.select' function.
#> Warning: This function is now deprecated. Please try the new 'mem.select' function.
#>
#>
#> AICc for the null model: -87.47112034786
#>
#> Best spatial model:
#> AICc NbVar
#> MEM32 -95.48955 6
#> Warning: This function is now deprecated. Please try the new 'listw.select' function.
#> Warning: This function is now deprecated. Please try the new 'mem.select' function.
#> Warning: This function is now deprecated. Please try the new 'mem.select' function.
#> Warning: This function is now deprecated. Please try the new 'mem.select' function.
#> Warning: This function is now deprecated. Please try the new 'mem.select' function.
#> Warning: This function is now deprecated. Please try the new 'mem.select' function.
#> Warning: This function is now deprecated. Please try the new 'mem.select' function.
#> Warning: This function is now deprecated. Please try the new 'mem.select' function.
#> Warning: This function is now deprecated. Please try the new 'mem.select' function.
#> Warning: This function is now deprecated. Please try the new 'mem.select' function.
#>
#>
#> AICc for the null model: -87.47112034786
#>
#> Best spatial model:
#> y dmax AICc NbVar
#> 1 2 3 -95.44519 6