Performing spatial-RLQ analysis withStephane DrayFebruary 10, 2006Thisdocumentindicateshowtoperformspatial-RLQanalysis(Drayet al., 2002) in R. Commands are written in red and outputs arewritten in blue.Contents1 Introduction 12 Data 23 Spatial-RLQ analysis 61 IntroductionR is a statistical language which can be freely downloaded from internet (http://www.r-project.org/). The package spdep written by Roger Bivand is de-voted to the creation and to the manipulation of spatial weighting matrices.You have to install it and to load it into your R session:library(spdep)You need also the ade4 package (multivariate analyses) and the maptools pack-age (if data are stored in the shape le format (ArcView GIS):library(ade4)library(maptools)Lastly, download and source the le spatialrlq.R available in the softwaresection of my website.source("spatialrlq.R")2 DataWe illustrate the method using two data sets. The data consists in a zip archivecontaining two ArcView shape les (ESRI le format). Files are extracted anddata are loaded into R with the read.shape function of the maptools library.zip.file.extract("environment.dbf", "spatialrlqdata.zip")1[1] "/tmp/RtmpkpSFHd/environment.dbf"zip.file.extract("environment.sbn", "spatialrlqdata.zip")[1] "/tmp/RtmpkpSFHd/environment.sbn"zip.file.extract("environment.sbx", "spatialrlqdata.zip")[1] "/tmp/RtmpkpSFHd/environment.sbx"zip.file.extract("environment.shp", "spatialrlqdata.zip")[1] "/tmp/RtmpkpSFHd ...
R is a statistical language which can be freely downloaded f //www.r-project.org/package). The spdepwritten by voted to the creation and to the manipulation of spatial You have to install it and to load it into your R session:
1
We illustrate the method using two data sets. The data consists in a zip archive containing two ArcView shapefiles (ESRI file format). Files are extracted and data are loaded into R with theread.shapefunction of themaptoolslibrary.
2
"spatialrlqdata.zip")
zip.file.extract("environment.dbf",
Introduction
Contents
February 10, 2006
1
1
Performing spatial-RLQ analysis with
Introduction
3
2
1
6
2
St´ephaneDray
Spatial-RLQ analysis
Data
rom internet (http: Roger Bivand is de-weighting matrices.
You need also theade4package (multivariate analyses) and themaptoolspack-age (if data are stored in the shapefile format (ArcView GIS): library(ade4) library(maptools)
This document indicates how to perform spatial-RLQ analysis (Dray et al., 2002) in R. Commands are written in red and outputs are written in blue.
Lastly, download and source the filespatialrlq.Ravailable in the software section of my website. source("spatialrlq.R")
Geographical units can be plotted. par(mfrow = c(1, 2)) plot(spshp) plot(envshp)
ThestudiedareaistheRhoˆne-AlpesRegion(France).Thefirstfilecontains the distribution of 223 species of ground beetles in 119 quadrats (square of 20 km) (Coulon et al., 2001). The second data set contains the measurements of 18 environmental variables for 54 ecoregions (Lebreton, 1977):
Data can be plotted (e.g. first environmental variable):
plot(polyenv,
grey(as.numeric(cut(envdata[, 1], 10))/10))
with colors: plot(polyenv, heat.colors(10)[as.numeric(cut(envdata[, 1], 10))])
5
3
Spatial-RLQ analysis
The first step of spatial-RLQ analysis is to compute the neighborhood matrix between the two sampling schemes. Two options (argumenttype) are available to fill this matrix: binary or area. For this task you need theintersectpolys function available in the spatialrlq.R file:
cross1 <- intersectpolys(polyenv, polysp, type = "binary")
Loading General
required package: gpclib Polygon Clipper Library for R (version 1.3 ) Type ’class ? gpc.poly’ for help
dim(cross1)
[1] 54 119
Correspondence analysis can be applied to a neighborhood matrix (Lebart, 1984): coa1 <- dudi.coa(cross1, scannf = F, nf = 2) scatter(coa1)
Scores of correspondence analysis can be plotted in the geographical space: par(mfrow = c(2, 2)) plot(polyenv, heat.colors(10)[as.numeric(cut(coa1$l1[, 1], 10))], main = "first axis") plot(polysp, heat.colors(10)[as.numeric(cut(coa1$c1[, 1], 10))], main = "first axis") plot(polyenv, heat.colors(10)[as.numeric(cut(coa1$l1[, 2], 10))], main = "second axis") plot(polysp, heat.colors(10)[as.numeric(cut(coa1$c1[, 2], 10))], main = "second axis")
6
Environmental data contains quantitative and qualitative variables and can be analyzed bydudi.hillsmithwith weights taken from the correspondence analysis of the the neighborhood matrix. dudimil <- dudi.hillsmith(envdata, row.w = coa1$lw, scannf = F, nf = 2) scatter(dudimil)
7
First axis plotted in the geographical space plot(polyenv, heat.colors(10)[as.numeric(cut(dudimil$l1[, 1], 10))])
In order to remove unequal sampling effort among quadrats, species data have been transformed into row profiles. This new table is then analyzed with a centred PCA.
Spatial-RLQ analysis can then be applied to obtain a common ordination of the two data sets: dudirlq <- rlq(dudimil, coa1, dudisp, scannf = F, nf = 2) summary(dudirlq)
Inertia & coinertia R: inertia max ratio 1 7.743 8.274 0.9358 12 10.711 11.726 0.9135
Inertia & coinertia Q: inertia max ratio 1 21.45 22.94 0.9352 12 34.60 37.19 0.9303
Correlation L: corr max 1 0.7418 0.9761 2 0.7540 0.9688
plot(dudirlq)
ratio 0.7600 0.7783
9
Scores of RLQ analysis can be represented in the geographical space. par(mfrow = c(2, 2)) plot(polysp, heat.colors(10)[as.numeric(cut(dudirlq$mQ[, 1], 10))], main = "first axis") plot(polyenv, heat.colors(10)[as.numeric(cut(dudirlq$mR[, 1], 10))], main = "first axis") plot(polysp, heat.colors(10)[as.numeric(cut(dudirlq$mQ[, 2], 10))], main = "second axis") plot(polyenv, heat.colors(10)[as.numeric(cut(dudirlq$mR[, 2], 10))], main = "second axis")
10
References
J. Coulon, P. Marchal, R. Pupier, P. Richoux, R. Allemand, L. Genest, and J. Clary.acarep:s-elAˆhnond`eciciesetbiqusleeRsdre`epteol´Co.s´Mumeu d’HistoirenaturelledeLyonetSoci´et´elinn´eennedeLyon,Lyon,2001.
S. Dray, N. Pettorelli, and D. Chessel. Matching data sets from two different spatial samples.Journal of Vegetation Science, 13:867–874, 2002.
L. Lebart. Correspondence analysis of a graph structure.Bulletin Technique du CESIA, 2:5–19, 1984.
P. Lebreton.goqieuhRoˆenA-plns.AtlasornitholesrsruehciiplanoˆhesLxnauseoi. CentreOrnithologiqueRhoˆne-Alpes,DirectiondelaProtectiondelaNature, Lyon, 1977.