test.W | R Documentation |

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,
...
)
```

`Y` |
A matrix with response variables (univariate or multivariate response) |

`nb` |
An object of the class |

`xy` |
Coordinates of the samples, this argument is optional and is
required only if the argument |

`MEM.autocor` |
A string indicating if all MEM must be returned or only those corresponding to positive or negative autocorrelation |

`f` |
A function of the distance that can be used as a weighting spatial function. This argument is optional |

`...` |
Others arguments for the function |

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.

A list with the following elements:

`all ` |
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. |

`best ` |
A list containing results of scores.listw and ortho.AIC of the best spatial weighting matrix according to corrected AIC. |

Stéphane Dray stephane.dray@univ-lyon1.fr

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

`ortho.AIC`

, `scores.listw`

```
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))
}
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.