[R-sig-eco] Selecting spatial variables to distance matrix in capscale

amommendes amommendes at hotmail.com
Thu Aug 22 00:05:59 CEST 2013


Dear list,

I've a phylobeta diversity matrix (distance matrix) and I intend to analyze
it with db-RDA (capscale {vegan}).
I'm trying to select spatial variables in order to assess the spatial
structure of this matrix with db-RDA (i.e. the spatial predictors at RHS of
the formula in capscale function).

Would be correct to apply a PCoA (cmdscale) in this distance matrix, in
order to test and select the best (smallest AICc) spatial weighting model
through test.W {spacemakeR} function? In other words, I would like use the
"site x principal coordinates matrix" as a "multivariate response matrix" in
test.W function (i.e. Y argument).

Here's a code with mite data to exemplify my doubt (however, in this
example, only three MEMs were selected):

library (vegan)
require (spacemakeR)

data(mite)
data(mite.xy)
d<- vegdist (mite, "bray")
d.pcoa.all<- cmdscale (d, k= attr(d, "Size") - 1, add=T)
d.pcoa<- d.pcoa.all$points # All PCoA's axes will be used, how in capscale.
And it'll be the Y argument in test.W function (i.e. multivariate response
matrix)

d.xy<- dist(mite.xy) # Geographic distances
thresh<- seq(give.thresh(d.xy), max(d.xy), le=20) # Vector of thresholds of
distances
list.nb<- lapply (thresh, dnearneigh, x=as.matrix (mite.xy), d1=0) # List of
neighbourhood matrices

# Testing neighbourhood matrices by test.W
mite.W<- lapply (list.nb, test.W, Y=d.pcoa, xy=mite.xy)
minAIC<- sapply(mite.W, function (x) min(x$best$AICc, na.rm=T))
min(minAIC) # Smallest AICc
which.min(minAIC) # Number of the best model among 20
thresh[which.min(minAIC)] #Geographic distance of best model among 20

# MEM's selected by the best spatial model (smallest AICc) through test.W
MEMid<- mite.W[[4]]$best$ord[1:which.min(mite.W[[4]]$best$AICc)]
sort(MEMid)
MEM.all<-mite.W[[4]]$best$vectors
MEM.selected<-mite.W[[4]]$best$vectors[,sort(c(MEMid))]
colnames(MEM.selected)<-sort(MEMid)

# Plotting MEM selected
par(mfrow=c(1,3))
for (i in 1:ncol(MEM.selected))
s.value(mite.xy, MEM.selected[,i],csize=0.8, clegend=1.5,pch=22, csub=2)

Thanks in advance,

Best,

Amom



--
View this message in context: http://r-sig-ecology.471788.n2.nabble.com/Selecting-spatial-variables-to-distance-matrix-in-capscale-tp7578362.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.



More information about the R-sig-ecology mailing list