Performing spatial-RLQ analysis with R
11 pages
English

Performing spatial-RLQ analysis with R

Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
11 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

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

Informations

Publié par
Nombre de lectures 308
Langue English

Extrait

Data
library(spdep)
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")
[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/environment.shp"
zip.file.extract("environment.shx",
"spatialrlqdata.zip")
[1] "/tmp/RtmpkpSFHd/environment.shx"
zip.file.extract("species.dbf",
"spatialrlqdata.zip")
[1] "/tmp/RtmpkpSFHd/species.dbf"
zip.file.extract("species.sbn",
"spatialrlqdata.zip")
[1] "/tmp/RtmpkpSFHd/species.sbn"
zip.file.extract("species.sbx",
"spatialrlqdata.zip")
[1] "/tmp/RtmpkpSFHd/species.sbx"
zip.file.extract("species.shp",
"spatialrlqdata.zip")
[1] "/tmp/RtmpkpSFHd/species.shp"
zip.file.extract("species.shx",
"spatialrlqdata.zip")
[1] "/tmp/RtmpkpSFHd/species.shx"
spshp = read.shape(paste(tempdir(), "/", "species", sep = ""))
Shapefile Type: Polygon
# of Shapes: 119
envshp = read.shape(paste(tempdir(), "/", "environment", sep = ""))
2
Shapefile Type: Polygon
# of Shapes: 54
Geographical units can be plotted. par(mfrow = c(1, 2)) plot(spshp) plot(envshp)
ThestudiedareaistheRhoˆne-AlpesRegion(France).Therstlecontains 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):
envdata <- envshp$att.data spdata <- spshp$att.data dim(envdata)
[1] 54 18
dim(spdata)
[1] 119 223
Environmental data must be modified. Mode of categorical variables ischar-acterand must be changed tofactor: mode(envdata[, 2])
[1] "numeric"
envdata[, 2]
[1] Moy Moy Maj Min [17] Maj Maj Maj Moy [33] Maj Maj Moy Maj [49] Moy Maj Maj Maj Levels: Maj Min Moy
Maj Maj Maj Maj
Maj Maj Maj Maj Moy Maj Moy Min Min Min Moy Maj Maj Maj Maj Maj Maj Maj Moy Maj Moy Maj Moy Moy Moy Maj Moy Maj Min Moy Moy Moy Maj Moy
3
summary(envdata[, 2])
Maj Min Moy 31 5 18
for (i in c(2:8, 15:18)) envdata[, i] <- as.factor(envdata[, i]) mode(envdata[, 2])
[1] "numeric"
envdata[, 2]
[1] Moy Moy Maj Min [17] Maj Maj Maj Moy [33] Maj Maj Moy Maj [49] Moy Maj Maj Maj Levels: Maj Min Moy
Maj Maj Maj Maj
summary(envdata[, 2])
Maj Min Moy 31 5 18
Maj Maj Moy Moy
Maj Maj Maj Moy Maj Moy Min Min Min Moy Maj Maj Maj Maj Maj Maj Moy Maj Moy Maj Moy Moy Maj Moy Maj Min Moy Moy Moy Maj
Mapsmust be converted intopolylistobjects for the analysis: class(spshp)
[1] "Map"
polysp = Map2poly(spshp) class(polysp)
[1] "polylist"
polyenv = Map2poly(envshp) plot(polyenv, col = "grey") plot(polysp, add = T)
4
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.
8
rowP <- sweep(spdata, 1, apply(spdata, 1, sum), "/") dudisp <- dudi.pca(rowP, row.w = coa1$cw, scannf = F, nf = 2) plot(polysp, heat.colors(10)[as.numeric(cut(dudisp$l1[, 1], 10))])
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)
Eigenvalues decomposition: eig covar sdR sdQ corr 1 91.39 9.56 2.783 4.631 0.7418 2 22.18 4.71 1.723 3.626 0.7540
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 dHistoirenaturelledeLyonetSoci´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.
11
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents