Title: | Analysis of Ecological Data: Exploratory and Euclidean Methods in Environmental Sciences |
---|---|
Description: | Tools for multivariate data analysis. Several methods are provided for the analysis (i.e., ordination) of one-table (e.g., principal component analysis, correspondence analysis), two-table (e.g., coinertia analysis, redundancy analysis), three-table (e.g., RLQ analysis) and K-table (e.g., STATIS, multiple coinertia analysis). The philosophy of the package is described in Dray and Dufour (2007) <doi:10.18637/jss.v022.i04>. |
Authors: | Stéphane Dray [aut] , Anne-Béatrice Dufour [aut] , Jean Thioulouse [aut] , Daniel Chessel [ant], Thibaut Jombart [ctb], Sandrine Pavoine [ctb], Jean R. Lobry [ctb], Sébastien Ollier [ctb], Daniel Borcard [ctb], Pierre Legendre [ctb], Stéphanie Bougeard [ctb], Aurélie Siberchicot [ctb, cre] |
Maintainer: | Aurélie Siberchicot <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.7-23 |
Built: | 2025-01-17 06:40:45 UTC |
Source: | https://github.com/sdray/ade4 |
This package is developed in the Biometry and Evolutionary Biology Lab (UMR CNRS 5558) - University Lyon 1.
It contains Data Analysis functions to analyse Ecological and Environmental data in the framework of Euclidean Exploratory methods, hence the name ade4.
ade4 is characterized by (1) the implementation of graphical and statistical functions, (2) the availability of numerical data, (3) the redaction of technical and thematic documentation and (4) the inclusion of bibliographic references.
To cite ade4, please use citation("ade4")
.
Stéphane Dray, Anne-Béatrice Dufour, and Jean Thioulouse. Contributions from Daniel Borcard, Stéphanie Bougeard, Thibaut Jombart, Pierre Legendre, Jean R. Lobry, Sébastien Ollier, Sandrine Pavoine and Aurélie Siberchicot. Based on earlier work by Daniel Chessel.
Dray S and Dufour A (2007). “The ade4 Package: Implementing the Duality Diagram for Ecologists.” _Journal of Statistical Software_, *22*(4), pp. 1-20. doi: 10.18637/jss.v022.i04 (URL: http://doi.org/10.18637/jss.v022.i04).
See ade4 website: http://pbil.univ-lyon1.fr/ADE-4/
ade4TkGUI
, adegenet
, adehabitat
, adegraphics
This data set gathers three phylogenies with three sets of traits as reported by Abouheif (1999).
data(abouheif.eg)
data(abouheif.eg)
abouheif.eg
is a list containing the 6 following objects :
is a character string giving the first phylogenetic tree made up of 8 leaves.
is a numeric vector with 8 values.
is a character string giving the second phylogenetic tree made up of 7 leaves.
is a numeric vector with 7 values.
is a character string giving the third phylogenetic tree made up of 15 leaves.
is a numeric vector with 15 values.
Data taken from the phylogenetic independence program developed by Ehab Abouheif
Abouheif, E. (1999) A method for testing the assumption of phylogenetic independence in comparative data. Evolutionary Ecology Research, 1, 895–909.
data(abouheif.eg) par(mfrow=c(2,2)) symbols.phylog(newick2phylog(abouheif.eg$tre1), abouheif.eg$vec1, sub = "Body Mass (kg)", csi = 2, csub = 2) symbols.phylog(newick2phylog(abouheif.eg$tre2), abouheif.eg$vec2, sub = "Body Mass (kg)", csi = 2, csub = 2) dotchart.phylog(newick2phylog(abouheif.eg$tre1), abouheif.eg$vec1, sub = "Body Mass (kg)", cdot = 2, cnod = 1, possub = "topleft", csub = 2, ceti = 1.5) dotchart.phylog(newick2phylog(abouheif.eg$tre2), abouheif.eg$vec2, sub = "Body Mass (kg)", cdot = 2, cnod = 1, possub = "topleft", csub = 2, ceti = 1.5) par(mfrow = c(1,1)) w.phy=newick2phylog(abouheif.eg$tre3) dotchart.phylog(w.phy,abouheif.eg$vec3, clabel.n = 1)
data(abouheif.eg) par(mfrow=c(2,2)) symbols.phylog(newick2phylog(abouheif.eg$tre1), abouheif.eg$vec1, sub = "Body Mass (kg)", csi = 2, csub = 2) symbols.phylog(newick2phylog(abouheif.eg$tre2), abouheif.eg$vec2, sub = "Body Mass (kg)", csi = 2, csub = 2) dotchart.phylog(newick2phylog(abouheif.eg$tre1), abouheif.eg$vec1, sub = "Body Mass (kg)", cdot = 2, cnod = 1, possub = "topleft", csub = 2, ceti = 1.5) dotchart.phylog(newick2phylog(abouheif.eg$tre2), abouheif.eg$vec2, sub = "Body Mass (kg)", cdot = 2, cnod = 1, possub = "topleft", csub = 2, ceti = 1.5) par(mfrow = c(1,1)) w.phy=newick2phylog(abouheif.eg$tre3) dotchart.phylog(w.phy,abouheif.eg$vec3, clabel.n = 1)
Counts of individuals of Acacia ehrenbergiana from five parallel transects of 32 quadrats.
data(acacia)
data(acacia)
acacia
is a data frame with 15 variables :
se.T1, se.T2, se.T3, se.T4, se.T5 are five numeric vectors containing quadrats counts of
seedlings from transects 1 to 5 respectively;
sm.T1, sm.T2, sm.T3, sm.T4, sm.T5 are five numeric vectors containing quadrats counts of
small trees (crown < 1 in canopy) of transects 1 to 5 respectively;
la.T1, la.T2, la.T3, la.T4, la.T5 are five numeric vectors containing quadrats counts of
trees with large crown (crown > 1 in canopy) of transects 1 to 5 respectively.
Greig-Smith, P. and Chadwick, M.J. (1965) Data on pattern within plant communities. III. Acacia-Capparis semi-desert scrub in the Sudan. Journal of Ecology, 53, 465–474.
Hill, M.O. (1973) The intensity of spatial pattern in plant communities. Journal of Ecology, 61, 225–235.
data(acacia) if(adegraphicsLoaded()) { gg <- s1d.barchart(acacia, p1d.horizontal = FALSE, psub.position = "topleft", plabels.cex = 0, ylim = c(0,20)) } else { par(mfcol = c(5, 3)) par(mar = c(2, 2, 2, 2)) for(k in 1:15) { barplot(acacia[, k], ylim = c(0, 20), col = grey(0.8)) ade4:::scatterutil.sub(names(acacia)[k], 1.5, "topleft") } par(mfcol = c(1, 1)) }
data(acacia) if(adegraphicsLoaded()) { gg <- s1d.barchart(acacia, p1d.horizontal = FALSE, psub.position = "topleft", plabels.cex = 0, ylim = c(0,20)) } else { par(mfcol = c(5, 3)) par(mar = c(2, 2, 2, 2)) for(k in 1:15) { barplot(acacia[, k], ylim = c(0, 20), col = grey(0.8)) ade4:::scatterutil.sub(names(acacia)[k], 1.5, "topleft") } par(mfcol = c(1, 1)) }
add.scatter
is a function which defines a new plot area within an existing plot and displays an additional graphic inside this area. The additional graphic is determined by a function which is the first argument taken by add.scatter
. It can be used in various ways, for instance to add a screeplot to an ordination scatterplot (add.scatter.eig
).
The function add.scatter.eig
uses the following colors: black (represented axes), grey(axes retained in the analysis) and white (others).
add.scatter(func,posi = c("bottomleft","bottomright","topleft","topright"), ratio = 0.2, inset = 0.01, bg.col = 'white') add.scatter.eig(w, nf = NULL, xax, yax, posi = "bottomleft", ratio = .25, inset = 0.01, sub = "Eigenvalues", csub = 2 * ratio)
add.scatter(func,posi = c("bottomleft","bottomright","topleft","topright"), ratio = 0.2, inset = 0.01, bg.col = 'white') add.scatter.eig(w, nf = NULL, xax, yax, posi = "bottomleft", ratio = .25, inset = 0.01, sub = "Eigenvalues", csub = 2 * ratio)
func |
an - evaluated - function producing a graphic |
posi |
a character vector (only its first element being considered) giving the position of the added graph. Possible values are "bottomleft" (="bottom"),"bottomright","topleft" (="top"),"topright", and "none" (no plot). |
ratio |
the size of the added graph in proportion of the current plot region |
inset |
the inset from which the graph is drawn, in proportion of the whole plot region. Can be a vector of length 2, giving the inset in x and y. If atomic, same inset is used in x and y |
bg.col |
the color of the background of the added graph |
w |
numeric vector of eigenvalues |
nf |
the number of retained factors, NULL if not provided |
xax |
first represented axis |
yax |
second represented axis |
sub |
title of the screeplot |
csub |
size of the screeplot title |
add.scatter
uses par("plt")
to redefine the new plot region.
As stated in par
documentation, this produces to (sometimes
surprising) interactions with other parameters such as "mar".
In particular, such interactions are likely to reset the plot region
by default which would cause the additional graphic to take the whole
plot region. To avoid such inconvenient, add par([other
options], plt=par("plt"))
when using par
in your graphical
function (argument func
).
The matched call (invisible).
Thibaut Jombart [email protected]
data(microsatt) w <- dudi.coa(data.frame(t(microsatt$tab)), scann = FALSE, nf = 3) if(adegraphicsLoaded()) { a1 <- rnorm(100) b1 <- s1d.barchart(sort(a1), p1d.horizontal = FALSE, plot = FALSE) h1 <- s1d.hist(a1, pgrid.draw = FALSE, porigin.draw = FALSE, pbackground.col = "grey", plot = FALSE, ppoly.col = "white", ppoly.alpha = 1) g1 <- insert(h1, b1, posi = "topleft", plot = FALSE) a2 <- rnorm(100) b2 <- s1d.barchart(sort(a2), p1d.horizontal = FALSE, plot = FALSE) h2 <- s1d.hist(a2, pgrid.draw = FALSE, porigin.draw = FALSE, pbackground.col = "grey", plot = FALSE, ppoly.col = "white", ppoly.alpha = 1) g2 <- insert(h2, b2, posi = "topleft", inset = c(0.25, 0.01), plot = FALSE) a3 <- rnorm(100) b3 <- s1d.barchart(sort(a3), p1d.horizontal = FALSE, plot = FALSE) h3 <- s1d.hist(a3, pgrid.draw = FALSE, porigin.draw = FALSE, pbackground.col = "grey", plot = FALSE, ppoly.col = "white", ppoly.alpha = 1) g3 <- insert(h3, b3, posi = "bottomleft", inset = 0.4, ratio = 0.2, plot = FALSE) a4 <- rnorm(100) b4 <- s1d.barchart(sort(a4), p1d.horizontal = FALSE, plot = FALSE) h4 <- s1d.hist(a4, pgrid.draw = FALSE, porigin.draw = FALSE, pbackground.col = "grey", plot = FALSE, ppoly.col = "white", ppoly.alpha = 1) g4 <- insert(h3, b3, posi = "bottomright", ratio = 0.3, plot = FALSE) G1 <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2), plot = TRUE) g5 <- s.label(w$co, plot = FALSE) g6 <- plotEig(w$eig, w$nf, psub = list(text = "Eigenvalues"), pbackground = list(box = TRUE), plot = FALSE) G2 <- insert(g6, g5, posi = "bottomright", ratio = 0.25) } else { par(mfrow=c(2,2)) f1 <- function(a){ opar=par("mar","xaxt","yaxt","plt") on.exit(par(opar)) par(mar=rep(.1,4),xaxt="n",yaxt="n",plt=par("plt")) hist(a,xlab="",ylab="",main="",col="white",proba=TRUE) lines(seq(-4,4,le=50),dnorm(seq(-4,4,le=50)),col="red") } a <- rnorm(100) barplot(sort(a)) add.scatter(f1(a),posi="topleft",bg.col="grey") a <- rnorm(100) barplot(sort(a)) add.scatter(f1(a),posi="topleft",bg.col="grey",inset=c(.25,.01)) a <- rnorm(100) barplot(sort(a)) add.scatter(f1(a),posi="topleft",bg.col="grey",inset=.25,ratio=.1) a <- rnorm(100) barplot(sort(a)) add.scatter(f1(a),posi="bottomright",bg.col="grey",ratio=.3) par(mfrow=c(1,1)) s.label(w$co) add.scatter.eig(w$eig,w$nf,posi="bottomright",1,2) }
data(microsatt) w <- dudi.coa(data.frame(t(microsatt$tab)), scann = FALSE, nf = 3) if(adegraphicsLoaded()) { a1 <- rnorm(100) b1 <- s1d.barchart(sort(a1), p1d.horizontal = FALSE, plot = FALSE) h1 <- s1d.hist(a1, pgrid.draw = FALSE, porigin.draw = FALSE, pbackground.col = "grey", plot = FALSE, ppoly.col = "white", ppoly.alpha = 1) g1 <- insert(h1, b1, posi = "topleft", plot = FALSE) a2 <- rnorm(100) b2 <- s1d.barchart(sort(a2), p1d.horizontal = FALSE, plot = FALSE) h2 <- s1d.hist(a2, pgrid.draw = FALSE, porigin.draw = FALSE, pbackground.col = "grey", plot = FALSE, ppoly.col = "white", ppoly.alpha = 1) g2 <- insert(h2, b2, posi = "topleft", inset = c(0.25, 0.01), plot = FALSE) a3 <- rnorm(100) b3 <- s1d.barchart(sort(a3), p1d.horizontal = FALSE, plot = FALSE) h3 <- s1d.hist(a3, pgrid.draw = FALSE, porigin.draw = FALSE, pbackground.col = "grey", plot = FALSE, ppoly.col = "white", ppoly.alpha = 1) g3 <- insert(h3, b3, posi = "bottomleft", inset = 0.4, ratio = 0.2, plot = FALSE) a4 <- rnorm(100) b4 <- s1d.barchart(sort(a4), p1d.horizontal = FALSE, plot = FALSE) h4 <- s1d.hist(a4, pgrid.draw = FALSE, porigin.draw = FALSE, pbackground.col = "grey", plot = FALSE, ppoly.col = "white", ppoly.alpha = 1) g4 <- insert(h3, b3, posi = "bottomright", ratio = 0.3, plot = FALSE) G1 <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2), plot = TRUE) g5 <- s.label(w$co, plot = FALSE) g6 <- plotEig(w$eig, w$nf, psub = list(text = "Eigenvalues"), pbackground = list(box = TRUE), plot = FALSE) G2 <- insert(g6, g5, posi = "bottomright", ratio = 0.25) } else { par(mfrow=c(2,2)) f1 <- function(a){ opar=par("mar","xaxt","yaxt","plt") on.exit(par(opar)) par(mar=rep(.1,4),xaxt="n",yaxt="n",plt=par("plt")) hist(a,xlab="",ylab="",main="",col="white",proba=TRUE) lines(seq(-4,4,le=50),dnorm(seq(-4,4,le=50)),col="red") } a <- rnorm(100) barplot(sort(a)) add.scatter(f1(a),posi="topleft",bg.col="grey") a <- rnorm(100) barplot(sort(a)) add.scatter(f1(a),posi="topleft",bg.col="grey",inset=c(.25,.01)) a <- rnorm(100) barplot(sort(a)) add.scatter(f1(a),posi="topleft",bg.col="grey",inset=.25,ratio=.1) a <- rnorm(100) barplot(sort(a)) add.scatter(f1(a),posi="bottomright",bg.col="grey",ratio=.3) par(mfrow=c(1,1)) s.label(w$co) add.scatter.eig(w$eig,w$nf,posi="bottomright",1,2) }
aminoacyl
is a list containing the codon counts of 36 genes encoding yeast aminoacyl-tRNA-synthetase(S.Cerevisiae).
data(aminoacyl)
data(aminoacyl)
aminoacyl
is a list containing the 5 following objects:
is a vector giving the gene names.
is a vector giving the cellular localisation of the proteins (M = mitochondrial, C = cytoplasmic, I = indetermined, CI = cyto and mito).
is a vector containing the 64 triplets.
is a factor giving the amino acid names for each codon.
is a dataframe containing the codon counts for each gene.
Data prepared by D. Charif [email protected]
Chiapello H., Olivier E., Landes-Devauchelle C., Nitschké P. and Risler J.L (1999) Codon usage as a tool to predict the cellular localisation of eukariotic ribosomal proteins and aminoacyl-tRNA synthetases. Nucleic Acids Res., 27, 14, 2848–2851.
data(aminoacyl) aminoacyl$genes aminoacyl$usage.codon dudi.coa(aminoacyl$usage.codon, scannf = FALSE)
data(aminoacyl) aminoacyl$genes aminoacyl$usage.codon dudi.coa(aminoacyl$usage.codon, scannf = FALSE)
The analysis of molecular variance tests the differences among population and/or groups of populations in a way similar to ANOVA. It includes evolutionary distances among alleles.
amova(samples, distances, structures) ## S3 method for class 'amova' print(x, full = FALSE, ...)
amova(samples, distances, structures) ## S3 method for class 'amova' print(x, full = FALSE, ...)
samples |
a data frame with haplotypes (or genotypes) as rows, populations as columns and abundance as entries |
distances |
an object of class |
structures |
a data frame containing, in the jth row and the kth column, the name of the group of level k to which the jth population belongs |
x |
an object of class |
full |
a logical value indicating whether the original data ('distances', 'samples', 'structures') should be printed |
... |
further arguments passed to or from other methods |
Returns a list of class amova
call |
call |
results |
a data frame with the degrees of freedom, the sums of squares, and the mean squares. Rows represent levels of variability. |
componentsofcovariance |
a data frame containing the components of covariance and their contribution to the total covariance |
statphi |
a data frame containing the phi-statistics |
Sandrine Pavoine [email protected]
Excoffier, L., Smouse, P.E. and Quattro, J.M. (1992) Analysis of molecular variance inferred from metric distances among DNA haplotypes: application to human mitochondrial DNA restriction data. Genetics, 131, 479–491.
data(humDNAm) amovahum <- amova(humDNAm$samples, sqrt(humDNAm$distances), humDNAm$structures) amovahum
data(humDNAm) amovahum <- amova(humDNAm$samples, sqrt(humDNAm$distances), humDNAm$structures) amovahum
This data set gives the occurences for the allelic form on 8 loci in 10 populations of honeybees.
data(apis108)
data(apis108)
A data frame containing 180 rows (allelic forms on 8 loci) and 10 columns (populations of honeybees : El.Hermel, Al.Hoceima, Nimba, Celinda, Pretoria, Chalkidiki, Forli, Valenciennes, Umea and Seville).
Franck P., Garnery L., Solignac M. and Cornuet J.M. (2000) Molecular confirmation of a fourth lineage in honeybees from the Near-East. Apidologie, 31, 167–180.
data(apis108) str(apis108) names(apis108)
data(apis108) str(apis108) names(apis108)
The hierarchical apportionment of quadratic entropy defined by Rao (1982).
apqe(samples, dis = NULL, structures) ## S3 method for class 'apqe' print(x, full = FALSE, ...)
apqe(samples, dis = NULL, structures) ## S3 method for class 'apqe' print(x, full = FALSE, ...)
samples |
a data frame with haplotypes (or genotypes) as rows, populations as columns and abundance or presence-absence as entries |
dis |
an object of class |
structures |
a data frame that contains, in the jth row and the kth column, the name of the group of level k to which the jth population belongs |
x |
an object of class |
full |
a logical value that indicates whether the original data ('distances', 'samples', 'structures') should be printed |
... |
|
Returns a list of class apqe
call |
call |
results |
a data frame that contains the components of diversity. |
Sandrine Pavoine [email protected]
Rao, C.R. (1982) Diversity: its measurement, decomposition, apportionment and analysis. Sankhya: The Indian Journal of Statistics, A44, 1–22.
Pavoine S. and Dolédec S. (2005) The apportionment of quadratic entropy: a useful alternative for partitioning diversity in ecological data. Environmental and Ecological Statistics, 12, 125–138.
data(ecomor) ecomor.phylog <- taxo2phylog(ecomor$taxo) apqe(ecomor$habitat, ecomor.phylog$Wdist)
data(ecomor) ecomor.phylog <- taxo2phylog(ecomor$taxo) apqe(ecomor$habitat, ecomor.phylog$Wdist)
This dataset describe the distribution of 82 species of Alpine plants in 75 sites. Species traits and environmental variables are also measured.
data(aravo)
data(aravo)
aravo
is a list containing the following objects :
is a data.frame with the abundance values of 82 species (columns) in 75 sites (rows).
is a data.frame with the measurements of 6 environmental variables for the sites.
is data.frame with the measurements of 8 traits for the species.
is a vector with full species names.
The environmental variables are:
Aspect | Relative south aspect (opposite of the sine of aspect with flat coded 0) |
Slope | Slope inclination (degrees) |
Form | Microtopographic landform index: 1 (convexity); 2 (convex slope); 3 (right slope); 4 (concave slope); 5 (concavity) |
Snow | Mean snowmelt date (Julian day) averaged over 1997-1999 |
PhysD | Physical disturbance, i.e., percentage of unvegetated soil due to physical processes |
ZoogD | Zoogenic disturbance, i.e., quantity of unvegetated soil due to marmot activity: no; some; high |
The species traits for the plants are:
Height | Vegetative height (cm) |
Spread | Maximum lateral spread of clonal plants (cm) |
Angle | Leaf elevation angle estimated at the middle of the lamina |
Area | Area of a single leaf |
Thick | Maximum thickness of a leaf cross section (avoiding the midrib) |
SLA | Specific leaf area |
Nmass | Mass-based leaf nitrogen content |
Seed | Seed mass |
Choler, P. (2005) Consistent shifts in Alpine plant traits along a mesotopographical gradient. Arctic, Antarctic, and Alpine Research, 37,444–453.
data(aravo) coa1 <- dudi.coa(aravo$spe, scannf = FALSE, nf = 2) dudienv <- dudi.hillsmith(aravo$env, scannf = FALSE, nf = 2, row.w = coa1$lw) duditrait <- dudi.pca(aravo$traits, scannf = FALSE, nf = 2, row.w = coa1$cw) rlq1 <- rlq(dudienv, coa1, duditrait, scannf = FALSE, nf = 2) plot(rlq1)
data(aravo) coa1 <- dudi.coa(aravo$spe, scannf = FALSE, nf = 2) dudienv <- dudi.hillsmith(aravo$env, scannf = FALSE, nf = 2, row.w = coa1$lw) duditrait <- dudi.pca(aravo$traits, scannf = FALSE, nf = 2, row.w = coa1$cw) rlq1 <- rlq(dudienv, coa1, duditrait, scannf = FALSE, nf = 2) plot(rlq1)
This data set gives information about species of benthic macroinvertebrates in different sites and dates.
data(ardeche)
data(ardeche)
ardeche
is a list with 6 components.
is a data frame containing fauna table with 43 species (rows) and 35 samples (columns).
is a vector containing the repartition of samples for the 6 dates : july 1982, august 1982, november 1982, february 1983, april 1983 and july 1983.
is a vector containing the repartition of species in the 4 groups defining the species order.
is a date factor for samples (6 dates).
is a site factor for samples (6 sites).
is a species order factor (Ephemeroptera, Plecoptera, Coleoptera, Trichoptera).
The columns of the data frame ardeche$tab
define the samples by a number between 1 and 6 (the date)
and a letter between A and F (the site).
Cazes, P., Chessel, D., and Dolédec, S. (1988) L'analyse des correspondances internes d'un tableau partitionné : son usage en hydrobiologie. Revue de Statistique Appliquée, 36, 39–54.
data(ardeche) dudi1 <- dudi.coa(ardeche$tab, scan = FALSE) s.class(dudi1$co, ardeche$dat.fac) if(adegraphicsLoaded()) { s.label(dudi1$co, plab.cex = 0.5, add = TRUE) } else { s.label(dudi1$co, clab = 0.5, add.p = TRUE) }
data(ardeche) dudi1 <- dudi.coa(ardeche$tab, scan = FALSE) s.class(dudi1$co, ardeche$dat.fac) if(adegraphicsLoaded()) { s.label(dudi1$co, plab.cex = 0.5, add = TRUE) } else { s.label(dudi1$co, clab = 0.5, add.p = TRUE) }
'area' is a data frame with three variables.
The first variable is a factor defining the polygons.
The second and third variables are the xy coordinates of the
polygon vertices in the order where they are found.
area.plot : grey levels areas mapping
poly2area takes an object of class 'polylist' (maptools package) and returns a data frame of type area.
area2poly takes an object of type 'area' and returns a list of class 'polylist'
area2link takes an object of type 'area' and returns a proximity matrix which terms are given by
the length of the frontier between two polygons.
area.util.contour,area.util.xy and area.util.class are three utility functions.
area.plot(x, center = NULL, values = NULL, graph = NULL, lwdgraph = 2, nclasslegend = 8, clegend = 0.75, sub = "", csub = 1, possub = "topleft", cpoint = 0, label = NULL, clabel = 0, ...) area2poly(area) poly2area(polys) area2link(area) area.util.contour(area) area.util.xy(area)
area.plot(x, center = NULL, values = NULL, graph = NULL, lwdgraph = 2, nclasslegend = 8, clegend = 0.75, sub = "", csub = 1, possub = "topleft", cpoint = 0, label = NULL, clabel = 0, ...) area2poly(area) poly2area(polys) area2link(area) area.util.contour(area) area.util.xy(area)
x |
a data frame with three variables |
center |
a matrix with the same row number as x and two columns, the coordinates
of polygone centers. If NULL, it is computed with |
values |
if not NULL, a vector which values will be mapped to grey levels.
The values must be in the same order as the values in |
graph |
if not NULL, |
lwdgraph |
a line width to draw the neighbouring graph |
nclasslegend |
if |
clegend |
if not NULL, a character size for the legend, used with |
sub |
a string of characters to be inserted as sub-title |
csub |
a character size for the sub-titles, used with |
possub |
a string of characters indicating the sub-titles position ("topleft", "topright", "bottomleft", "bottomright") |
cpoint |
if positive, a character size for drawing the polygons vertices (check up),
used with |
label |
if not NULL, by default the levels of the factor that define the polygons
are used as labels. To change this value, use label. These labels must be in the same order than
|
clabel |
if not NULL, a character size for the polygon labels, |
polys |
a list belonging to the 'polylist' class in the spdep package |
area |
a data frame of class 'area' |
... |
further arguments passed to or from other methods |
poly2area returns a data frame 'factor,x,y'.
area2poly returns a list of class polylist
.
Daniel Chessel
data(elec88) par(mfrow = c(2, 2)) area.plot(elec88$area, cpoint = 1) area.plot(elec88$area, lab = elec88$lab$dep, clab = 0.75) area.plot(elec88$area, clab = 0.75) area.plot(elec88$area, graph = neig(area = elec88$area), sub = "Neighbourhood graph", possub = "topright") par(mfrow = c(1, 1)) ## Not run: par(mfrow = c(3, 3)) for(i in 1:9) { x <- elec88$tab[,i] area.plot(elec88$area, val = x, sub = names(elec88$tab)[i], csub = 3, cleg = 1.5) } par(mfrow = c(1, 1)) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { s.value(elec88$xy, elec88$tab, Sp = elec88$Spatial, method = "color", psub.text = names(elec88$tab), psub.cex = 3, pSp.col = "white", pgrid.draw = FALSE, porigin.include = FALSE) } } else { par(mfrow = c(3, 3)) for(i in 1:9) { x <- elec88$tab[, i] s.value(elec88$xy, elec88$tab[, i], contour = elec88$contour, meth = "greylevel", sub = names(elec88$tab)[i], csub = 3, cleg = 1.5, incl = FALSE) } par(mfrow = c(1, 1)) } if(!adegraphicsLoaded()) { data(irishdata) par(mfrow = c(2, 2)) w <- ade4:::area.util.contour(irishdata$area) xy <- ade4:::area.util.xy(irishdata$area) area.plot(irishdata$area, cpoint = 1) apply(w, 1, function(x) segments(x[1], x[2], x[3], x[4], lwd = 3)) area.plot(irishdata$area, clabel = 1) s.label(xy, area = irishdata$area, incl = FALSE, clab = 0, cpoi = 3, addax = FALSE, contour = w) s.label(xy, area = irishdata$area, incl = FALSE, addax = FALSE, contour = w) par(mfrow = c(1, 1)) } ## End(Not run) data(irishdata) w <- irishdata$area[c(42:53, 18:25), ] w w$poly <- as.factor(as.character(w$poly)) area.plot(w, clab = 2) points(68, 59, pch = 20, col = "red", cex = 3) points(68, 35, pch = 20, col = "red", cex = 3) points(45, 12, pch = 20, col = "red", cex = 3) sqrt((59 - 35) ^ 2) + sqrt((68 - 45) ^ 2 + (35 - 12) ^ 2) area2link(w)
data(elec88) par(mfrow = c(2, 2)) area.plot(elec88$area, cpoint = 1) area.plot(elec88$area, lab = elec88$lab$dep, clab = 0.75) area.plot(elec88$area, clab = 0.75) area.plot(elec88$area, graph = neig(area = elec88$area), sub = "Neighbourhood graph", possub = "topright") par(mfrow = c(1, 1)) ## Not run: par(mfrow = c(3, 3)) for(i in 1:9) { x <- elec88$tab[,i] area.plot(elec88$area, val = x, sub = names(elec88$tab)[i], csub = 3, cleg = 1.5) } par(mfrow = c(1, 1)) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { s.value(elec88$xy, elec88$tab, Sp = elec88$Spatial, method = "color", psub.text = names(elec88$tab), psub.cex = 3, pSp.col = "white", pgrid.draw = FALSE, porigin.include = FALSE) } } else { par(mfrow = c(3, 3)) for(i in 1:9) { x <- elec88$tab[, i] s.value(elec88$xy, elec88$tab[, i], contour = elec88$contour, meth = "greylevel", sub = names(elec88$tab)[i], csub = 3, cleg = 1.5, incl = FALSE) } par(mfrow = c(1, 1)) } if(!adegraphicsLoaded()) { data(irishdata) par(mfrow = c(2, 2)) w <- ade4:::area.util.contour(irishdata$area) xy <- ade4:::area.util.xy(irishdata$area) area.plot(irishdata$area, cpoint = 1) apply(w, 1, function(x) segments(x[1], x[2], x[3], x[4], lwd = 3)) area.plot(irishdata$area, clabel = 1) s.label(xy, area = irishdata$area, incl = FALSE, clab = 0, cpoi = 3, addax = FALSE, contour = w) s.label(xy, area = irishdata$area, incl = FALSE, addax = FALSE, contour = w) par(mfrow = c(1, 1)) } ## End(Not run) data(irishdata) w <- irishdata$area[c(42:53, 18:25), ] w w$poly <- as.factor(as.character(w$poly)) area.plot(w, clab = 2) points(68, 59, pch = 20, col = "red", cex = 3) points(68, 35, pch = 20, col = "red", cex = 3) points(45, 12, pch = 20, col = "red", cex = 3) sqrt((59 - 35) ^ 2) + sqrt((68 - 45) ^ 2 + (35 - 12) ^ 2) area2link(w)
This data set gives arrival times of 254 patients at an intensive care unit during one day.
data(arrival)
data(arrival)
arrival
is a list containing the 2 following objects :
is a vector giving the arrival times in the form HH:MM
is a vector giving the number of arrivals per hour for the day considered
Data taken from the Oriana software developed by Warren L. Kovach [email protected] starting from https://www.kovcomp.co.uk/oriana/index.html.
Fisher, N. I. (1993) Statistical Analysis of Circular Data. Cambridge University Press.
data(arrival) dotcircle(arrival$hours, pi/2 + pi/12)
data(arrival) dotcircle(arrival$hours, pi/2 + pi/12)
The function as.taxo
creates an object of class taxo
that is a sub-class of data.frame
.
Each column of the data frame must be a factor corresponding to a level j of the taxonomy (genus, family, ...).
The levels of factor j define some classes that must be completly included in classes of factor j+1.
A factor with exactly one level is not allowed. A factor with exactly one individual in each level is not allowed.
The function dist.taxo
compute taxonomic distances.
as.taxo(df) dist.taxo(taxo)
as.taxo(df) dist.taxo(taxo)
df |
a data frame |
taxo |
a data frame of class |
as.taxo
returns a data frame of class taxo
.
dist.taxo
returns a numeric of class dist
.
Daniel Chessel
Sébastien Ollier [email protected]
taxo2phylog
to transform an object of class taxo
into an object of class phylog
data(taxo.eg) tax <- as.taxo(taxo.eg[[1]]) tax.phy <- taxo2phylog(as.taxo(taxo.eg[[1]]),add.tools=TRUE) par(mfrow = c(1,2)) plot(tax.phy, clabel.l = 1.25, clabel.n = 1.25, f = 0.75) plot(taxo2phylog(as.taxo(taxo.eg[[1]][sample(15),])), clabel.l = 1.25, clabel.n = 1.25, f = 0.75) par(mfrow = c(1,1)) all(dist.taxo(tax)==tax.phy$Wdist)
data(taxo.eg) tax <- as.taxo(taxo.eg[[1]]) tax.phy <- taxo2phylog(as.taxo(taxo.eg[[1]]),add.tools=TRUE) par(mfrow = c(1,2)) plot(tax.phy, clabel.l = 1.25, clabel.n = 1.25, f = 0.75) plot(taxo2phylog(as.taxo(taxo.eg[[1]][sample(15),])), clabel.l = 1.25, clabel.n = 1.25, f = 0.75) par(mfrow = c(1,1)) all(dist.taxo(tax)==tax.phy$Wdist)
atlas
is a list containing three kinds of information about 23 regions (The French Alps) :
geographical coordinates, meteorology and bird presences.
data(atlas)
data(atlas)
atlas
is a list of 9 components:
is a convex hull of 23 geographical regions.
are the coordinates of the region centers and altitude (in meters).
is a vector of region names.
is a data frame with 7 variables: min and max temperature in january; min and max temperature in july; january, july and total rainfalls.
is a data frame with 15 variables (species).
is a data frame with 4 variables (x1, y1, x2, y2) for the contour display of The French Alps.
is a data frame with 3 variables altitude in percentage [0,800], ]800,1500] and ]1500,5000].
is the map of the 23 regions of The French Alps (an object of the class SpatialPolygons
of sp
).
is the contour of the map of the 23 regions of the French Alps (an object of the class SpatialPolygons
of sp
).
Extract from:
Lebreton, Ph. (1977) Les oiseaux nicheurs rhonalpins. Atlas ornithologique Rhone-Alpes.
Centre Ornithologique Rhone-Alpes, Universite Lyon 1, 69621 Villeurbanne.
Direction de la Protection de la Nature, Ministere de la Qualite de la Vie. 1–354.
data(atlas) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g11 <- s.Spatial(atlas$Spatial, pSp.col = "white", plot = FALSE) g12 <- s.label(atlas$area[, 2:3], plabels.cex = 0, plot = FALSE) g1 <- superpose(g11, g12, plot = FALSE) g2 <- s.label(atlas$xy, lab = atlas$names.district, Sp = atlas$Spatial, pgrid.dra = FALSE, pSp.col = "white", plot = FALSE) obj3 <- sp::SpatialPolygonsDataFrame(Sr = atlas$Spatial, data = atlas$meteo) g3 <- s.Spatial(obj3[, 1], nclass = 12, psub = list(position = "topleft", text = "Temp Mini January", cex = 2), plot = FALSE) g4 <- s.corcircle((dudi.pca(atlas$meteo, scann = FALSE)$co), plabels.cex = 1, plot = FALSE) G1 <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) obj5 <- sp::SpatialPolygonsDataFrame(Sr = atlas$Spatial, data = dudi.pca(atlas$meteo, scann = FALSE)$li) g5 <- s.Spatial(obj5[, 1], nclass = 12, psub = list(position = "topleft", text = "Principal Component Analysis analysis", cex = 1.5), plot = FALSE) coa1 <- dudi.coa(atlas$birds, scann = FALSE, nf = 1) obj6 <- sp::SpatialPolygonsDataFrame(Sr = atlas$Spatial, data = coa1$li) g6 <- s.Spatial(obj6[, 1], nclass = 12, psub = list(position = "topleft", text = "Correspondence analysis", cex = 1.5), plot = FALSE) g7 <- s.value(atlas$xy, coa1$li$Axis1, Sp = atlas$Spatial.contour, ppoints.cex = 2, porigin.include = FALSE, paxes.draw = FALSE, pSp.col = "white", plot = FALSE) g8 <- triangle.label(atlas$alti, plabels.cex = 0, plot = FALSE) G2 <- ADEgS(list(g5, g6, g7, g8), layout = c(2, 2)) } } else { op <- par(no.readonly = TRUE) par(mfrow = c(2, 2)) area.plot(atlas$area, cpoin = 1.5) area.plot(atlas$area, lab = atlas$names.district, clab = 1) x <- atlas$meteo$mini.jan names(x) <- row.names(atlas$meteo) area.plot(atlas$area, val = x, ncl = 12, sub = "Temp Mini January", csub = 2, cleg = 1) s.corcircle((dudi.pca(atlas$meteo, scann = FALSE)$co), clab = 1) area.plot(atlas$area, val = dudi.pca(atlas$meteo,scann=FALSE)$li[, 1], ncl = 12, sub = "Principal Component Analysis analysis", csub = 1.5, cleg = 1) birds.coa <- dudi.coa(atlas$birds, sca = FALSE, nf = 1) x <- birds.coa$li$Axis1 area.plot(atlas$area, val = x, ncl = 12, sub = "Correspondence analysis", csub = 1.5, cleg = 1) s.value(atlas$xy, x, contour = atlas$contour, csi = 2, incl = FALSE, addax = FALSE) triangle.plot(atlas$alti) par(op) par(mfrow = c(1, 1))}
data(atlas) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g11 <- s.Spatial(atlas$Spatial, pSp.col = "white", plot = FALSE) g12 <- s.label(atlas$area[, 2:3], plabels.cex = 0, plot = FALSE) g1 <- superpose(g11, g12, plot = FALSE) g2 <- s.label(atlas$xy, lab = atlas$names.district, Sp = atlas$Spatial, pgrid.dra = FALSE, pSp.col = "white", plot = FALSE) obj3 <- sp::SpatialPolygonsDataFrame(Sr = atlas$Spatial, data = atlas$meteo) g3 <- s.Spatial(obj3[, 1], nclass = 12, psub = list(position = "topleft", text = "Temp Mini January", cex = 2), plot = FALSE) g4 <- s.corcircle((dudi.pca(atlas$meteo, scann = FALSE)$co), plabels.cex = 1, plot = FALSE) G1 <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) obj5 <- sp::SpatialPolygonsDataFrame(Sr = atlas$Spatial, data = dudi.pca(atlas$meteo, scann = FALSE)$li) g5 <- s.Spatial(obj5[, 1], nclass = 12, psub = list(position = "topleft", text = "Principal Component Analysis analysis", cex = 1.5), plot = FALSE) coa1 <- dudi.coa(atlas$birds, scann = FALSE, nf = 1) obj6 <- sp::SpatialPolygonsDataFrame(Sr = atlas$Spatial, data = coa1$li) g6 <- s.Spatial(obj6[, 1], nclass = 12, psub = list(position = "topleft", text = "Correspondence analysis", cex = 1.5), plot = FALSE) g7 <- s.value(atlas$xy, coa1$li$Axis1, Sp = atlas$Spatial.contour, ppoints.cex = 2, porigin.include = FALSE, paxes.draw = FALSE, pSp.col = "white", plot = FALSE) g8 <- triangle.label(atlas$alti, plabels.cex = 0, plot = FALSE) G2 <- ADEgS(list(g5, g6, g7, g8), layout = c(2, 2)) } } else { op <- par(no.readonly = TRUE) par(mfrow = c(2, 2)) area.plot(atlas$area, cpoin = 1.5) area.plot(atlas$area, lab = atlas$names.district, clab = 1) x <- atlas$meteo$mini.jan names(x) <- row.names(atlas$meteo) area.plot(atlas$area, val = x, ncl = 12, sub = "Temp Mini January", csub = 2, cleg = 1) s.corcircle((dudi.pca(atlas$meteo, scann = FALSE)$co), clab = 1) area.plot(atlas$area, val = dudi.pca(atlas$meteo,scann=FALSE)$li[, 1], ncl = 12, sub = "Principal Component Analysis analysis", csub = 1.5, cleg = 1) birds.coa <- dudi.coa(atlas$birds, sca = FALSE, nf = 1) x <- birds.coa$li$Axis1 area.plot(atlas$area, val = x, ncl = 12, sub = "Correspondence analysis", csub = 1.5, cleg = 1) s.value(atlas$xy, x, contour = atlas$contour, csi = 2, incl = FALSE, addax = FALSE) triangle.plot(atlas$alti) par(op) par(mfrow = c(1, 1))}
This data set contains information about genetic variability of Atya innocous and Atya scabra in Guadeloupe (France).
data(atya)
data(atya)
atya
is a list with the following components:
a data frame with the coordinates of the 31 sites
a data frame with 22 variables collected on 31 sites
a neighborhood object (class nb
defined in package spdep
)
Fievet, E., Eppe, F. and Dolédec, S. (2001) Etude de la variabilité morphométrique et génétique des populations de Cacadors (Atya innocous et Atya scabra) de l'île de Basse-Terre. Direction Régionale de L'Environnement Guadeloupe, Laboratoire des hydrosystèmes fluviaux, Université Lyon 1.
## Not run: data(atya) if(requireNamespace("pixmap", quietly = TRUE)) { atya.digi <- pixmap::read.pnm(system.file("pictures/atyadigi.pnm", package = "ade4")) atya.carto <- pixmap::read.pnm(system.file("pictures/atyacarto.pnm", package = "ade4")) par(mfrow = c(1, 2)) pixmap:::plot(atya.digi) pixmap:::plot(atya.carto) points(atya$xy, pch = 20, cex = 2) } if(requireNamespace("spdep", quietly = TRUE)) { plot(atya$nb, atya$xy, col = "red", add = TRUE, lwd = 2) par(mfrow = c(1,1)) } ## End(Not run)
## Not run: data(atya) if(requireNamespace("pixmap", quietly = TRUE)) { atya.digi <- pixmap::read.pnm(system.file("pictures/atyadigi.pnm", package = "ade4")) atya.carto <- pixmap::read.pnm(system.file("pictures/atyacarto.pnm", package = "ade4")) par(mfrow = c(1, 2)) pixmap:::plot(atya.digi) pixmap:::plot(atya.carto) points(atya$xy, pch = 20, cex = 2) } if(requireNamespace("spdep", quietly = TRUE)) { plot(atya$nb, atya$xy, col = "red", add = TRUE, lwd = 2) par(mfrow = c(1,1)) } ## End(Not run)
This data set contains information about spatial distribution of bird species in a zone surrounding the river Rhône near Lyon (France).
data(avijons)
data(avijons)
avijons
is a list with the following components:
a data frame with the coordinates of the sites
an object of class area
a data frame with the abundance of 64 bird species in 91 sites
a vector of strings of character with the species names in french
an object of the class SpatialPolygons
of sp
,
containing the map
Bournaud, M., Amoros, C., Chessel, D., Coulet, M., Doledec, S., Michelot, J.L., Pautou, G., Rostan, J.C., Tachet, H. and Thioulouse, J. (1990). Peuplements d'oiseaux et propriétés des écocomplexes de la plaine du Rhône : descripteurs de fonctionnement global et gestion des berges. Rapport programme S.R.E.T.I.E., Ministère de l'Environnement CORA et URA CNRS 367, Univ. Lyon I.
Thioulouse, J., Chessel, D. and Champely, S. (1995) Multivariate analysis of spatial patterns: a unified approach to local and global structures. Environmental and Ecological Statistics, 2, 1–14.
See a data description at http://pbil.univ-lyon1.fr/R/pdf/pps051.pdf (in French).
data(avijons) w1 <- dudi.coa(avijons$fau, scannf = FALSE)$li area.plot(avijons$area, center = avijons$xy, val = w1[, 1], clab = 0.75, sub = "CA Axis 1", csub = 3) ## Not run: data(avijons) if(!adegraphicsLoaded()) { if(requireNamespace("pixmap", quietly = TRUE)) { pnm.eau <- pixmap::read.pnm(system.file("pictures/avijonseau.pnm", package = "ade4")) pnm.rou <- pixmap::read.pnm(system.file("pictures/avijonsrou.pnm", package = "ade4")) pnm.veg <- pixmap::read.pnm(system.file("pictures/avijonsveg.pnm", package = "ade4")) pnm.vil <- pixmap::read.pnm(system.file("pictures/avijonsvil.pnm", package = "ade4")) jons.coa <- dudi.coa(avijons$fau, scan = FALSE, nf = 4) par(mfcol = c(3, 2)) s.value(avijons$xy, jons.coa$li[, 1], pixmap = pnm.rou, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+ROADS", csub = 3) s.value(avijons$xy, jons.coa$li[, 1], pixmap = pnm.veg, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+TREES", csub = 3) s.value(avijons$xy, jons.coa$li[, 1], pixmap = pnm.eau, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+WATER", csub = 3) s.value(avijons$xy, jons.coa$li[, 2], pixmap = pnm.rou, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+ROADS", csub = 3) s.value(avijons$xy, jons.coa$li[, 2], pixmap = pnm.veg, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+TREES", csub = 3) s.value(avijons$xy, jons.coa$li[, 2], pixmap = pnm.eau, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+WATER", csub = 3) par(mfrow = c(1, 1)) } if(requireNamespace("spdep", quietly = TRUE) & requireNamespace("pixmap", quietly = TRUE) & requireNamespace("adespatial", quietly = TRUE)) { link1 <- area2link(avijons$area) lw1 <- apply(link1, 1, function(x) x[x > 0]) neig1 <- neig(mat01 = 1*(link1 > 0)) nb1 <- neig2nb(neig1) listw1 <- spdep::nb2listw(nb1,lw1) jons.ms <- adespatial::multispati(jons.coa, listw1, scan = FALSE, nfp = 3, nfn = 2) summary(jons.ms) par(mfrow = c(2, 2)) barplot(jons.coa$eig) barplot(jons.ms$eig) s.corcircle(jons.ms$as) plot(jons.coa$li[, 1], jons.ms$li[, 1]) par(mfrow = c(1, 1)) par(mfcol = c(3, 2)) s.value(avijons$xy, jons.ms$li[, 1], pixmap = pnm.rou, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+ROADS", csub = 3) s.value(avijons$xy, jons.ms$li[, 1], pixmap = pnm.veg, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+TREES", csub = 3) s.value(avijons$xy, jons.ms$li[, 1], pixmap = pnm.eau, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+WATER", csub = 3) s.value(avijons$xy, jons.ms$li[, 2], pixmap = pnm.rou, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+ROADS", csub = 3) s.value(avijons$xy, jons.ms$li[, 2], pixmap = pnm.veg, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+TREES", csub = 3) s.value(avijons$xy, jons.ms$li[, 2], pixmap = pnm.eau, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+WATER", csub = 3) par(mfrow = c(1, 1)) }} ## End(Not run)
data(avijons) w1 <- dudi.coa(avijons$fau, scannf = FALSE)$li area.plot(avijons$area, center = avijons$xy, val = w1[, 1], clab = 0.75, sub = "CA Axis 1", csub = 3) ## Not run: data(avijons) if(!adegraphicsLoaded()) { if(requireNamespace("pixmap", quietly = TRUE)) { pnm.eau <- pixmap::read.pnm(system.file("pictures/avijonseau.pnm", package = "ade4")) pnm.rou <- pixmap::read.pnm(system.file("pictures/avijonsrou.pnm", package = "ade4")) pnm.veg <- pixmap::read.pnm(system.file("pictures/avijonsveg.pnm", package = "ade4")) pnm.vil <- pixmap::read.pnm(system.file("pictures/avijonsvil.pnm", package = "ade4")) jons.coa <- dudi.coa(avijons$fau, scan = FALSE, nf = 4) par(mfcol = c(3, 2)) s.value(avijons$xy, jons.coa$li[, 1], pixmap = pnm.rou, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+ROADS", csub = 3) s.value(avijons$xy, jons.coa$li[, 1], pixmap = pnm.veg, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+TREES", csub = 3) s.value(avijons$xy, jons.coa$li[, 1], pixmap = pnm.eau, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+WATER", csub = 3) s.value(avijons$xy, jons.coa$li[, 2], pixmap = pnm.rou, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+ROADS", csub = 3) s.value(avijons$xy, jons.coa$li[, 2], pixmap = pnm.veg, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+TREES", csub = 3) s.value(avijons$xy, jons.coa$li[, 2], pixmap = pnm.eau, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+WATER", csub = 3) par(mfrow = c(1, 1)) } if(requireNamespace("spdep", quietly = TRUE) & requireNamespace("pixmap", quietly = TRUE) & requireNamespace("adespatial", quietly = TRUE)) { link1 <- area2link(avijons$area) lw1 <- apply(link1, 1, function(x) x[x > 0]) neig1 <- neig(mat01 = 1*(link1 > 0)) nb1 <- neig2nb(neig1) listw1 <- spdep::nb2listw(nb1,lw1) jons.ms <- adespatial::multispati(jons.coa, listw1, scan = FALSE, nfp = 3, nfn = 2) summary(jons.ms) par(mfrow = c(2, 2)) barplot(jons.coa$eig) barplot(jons.ms$eig) s.corcircle(jons.ms$as) plot(jons.coa$li[, 1], jons.ms$li[, 1]) par(mfrow = c(1, 1)) par(mfcol = c(3, 2)) s.value(avijons$xy, jons.ms$li[, 1], pixmap = pnm.rou, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+ROADS", csub = 3) s.value(avijons$xy, jons.ms$li[, 1], pixmap = pnm.veg, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+TREES", csub = 3) s.value(avijons$xy, jons.ms$li[, 1], pixmap = pnm.eau, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F1+WATER", csub = 3) s.value(avijons$xy, jons.ms$li[, 2], pixmap = pnm.rou, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+ROADS", csub = 3) s.value(avijons$xy, jons.ms$li[, 2], pixmap = pnm.veg, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+TREES", csub = 3) s.value(avijons$xy, jons.ms$li[, 2], pixmap = pnm.eau, inclu = FALSE, grid = FALSE, addax = FALSE, cleg = 0, sub = "F2+WATER", csub = 3) par(mfrow = c(1, 1)) }} ## End(Not run)
avimedi
is a list containing the information about 302 sites :
frequencies of 51 bird species ; two factors (habitats and Mediterranean origin).
data(avimedi)
data(avimedi)
This list contains the following objects:
is a data frame 302 sites - 51 bird species.
is a data frame 302 sites - 2 factors : reg
with two levels Provence (Pr
,
South of France) and Corsica (Co
) ;
str
with six levels describing the vegetation from a very low matorral (1) up to a mature forest of holm oaks (6).
is a vector 51 latin names.
Blondel, J., Chessel, D., & Frochot, B. (1988) Bird species impoverishment, niche expansion, and density inflation in mediterranean island habitats. Ecology, 69, 1899–1917.
## Not run: data(avimedi) coa1 <- dudi.coa(avimedi$fau, scan = FALSE, nf = 3) bet1 <- bca(coa1, avimedi$plan$str, scan = FALSE) wit1 <- wca(coa1, avimedi$plan$reg, scan=FALSE) pcaiv1 <- pcaiv(coa1, avimedi$plan, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.class(coa1$li, avimedi$plan$str:avimedi$plan$reg, psub.text = "Correspondences Analysis", plot = FALSE) g2 <- s.class(bet1$ls, avimedi$plan$str, psub.text = "Between Analysis", plot = FALSE) g3 <- s.class(wit1$li, avimedi$plan$str, psub.text = "Within Analysis", plot = FALSE) g41 <- s.match(pcaiv1$li, pcaiv1$ls, plabels.cex = 0, psub.text = "Canonical Correspondences Analysis", plot = FALSE) g42 <- s.class(pcaiv1$li, avimedi$plan$str:avimedi$plan$reg, plot = FALSE) g4 <- superpose(g41, g42, plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2,2)) s.class(coa1$li,avimedi$plan$str:avimedi$plan$reg, sub = "Correspondences Analysis") s.class(bet1$ls, avimedi$plan$str, sub = "Between Analysis") s.class(wit1$li, avimedi$plan$str, sub = "Within Analysis") s.match(pcaiv1$li, pcaiv1$ls, clab = 0, sub = "Canonical Correspondences Analysis") s.class(pcaiv1$li, avimedi$plan$str:avimedi$plan$reg, add.plot = TRUE) par(mfrow=c(1,1)) } ## End(Not run)
## Not run: data(avimedi) coa1 <- dudi.coa(avimedi$fau, scan = FALSE, nf = 3) bet1 <- bca(coa1, avimedi$plan$str, scan = FALSE) wit1 <- wca(coa1, avimedi$plan$reg, scan=FALSE) pcaiv1 <- pcaiv(coa1, avimedi$plan, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.class(coa1$li, avimedi$plan$str:avimedi$plan$reg, psub.text = "Correspondences Analysis", plot = FALSE) g2 <- s.class(bet1$ls, avimedi$plan$str, psub.text = "Between Analysis", plot = FALSE) g3 <- s.class(wit1$li, avimedi$plan$str, psub.text = "Within Analysis", plot = FALSE) g41 <- s.match(pcaiv1$li, pcaiv1$ls, plabels.cex = 0, psub.text = "Canonical Correspondences Analysis", plot = FALSE) g42 <- s.class(pcaiv1$li, avimedi$plan$str:avimedi$plan$reg, plot = FALSE) g4 <- superpose(g41, g42, plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2,2)) s.class(coa1$li,avimedi$plan$str:avimedi$plan$reg, sub = "Correspondences Analysis") s.class(bet1$ls, avimedi$plan$str, sub = "Between Analysis") s.class(wit1$li, avimedi$plan$str, sub = "Within Analysis") s.match(pcaiv1$li, pcaiv1$ls, clab = 0, sub = "Canonical Correspondences Analysis") s.class(pcaiv1$li, avimedi$plan$str:avimedi$plan$reg, add.plot = TRUE) par(mfrow=c(1,1)) } ## End(Not run)
This data set is a list of information about 51 sites : bird species and environmental variables.
A data frame contains biological traits for each species.
data(aviurba)
data(aviurba)
This list contains the following objects:
is a data frame 51 sites 40 bird species.
is a data frame 51 sites 11 environmental variables (see details).
is a data frame 40 species 4 biological traits (see details).
is a vector of the species names in french.
is a vector of the species names in latin.
is a factor : the species families.
aviurba$mil
contains for each site, 11 habitat attributes describing the degree of urbanization.
The presence or absence of farms or villages, small buildings, high buildings, industry, fields, grassland, scrubby areas,
deciduous woods, coniferous woods, noisy area are noticed. At least, the vegetation cover (variable 11) is a factor with 8 levels
from a minimum cover (R5) up to a maximum (R100).
aviurba$traits
contains four factors : feeding habit (insectivor, granivore, omnivore), feeding stratum (ground, aerial, foliage and scrub),
breeding stratum (ground, building, scrub, foliage) and migration strategy (resident, migrant).
Dolédec, S., Chessel, D., Ter Braak,C. J. F. and Champely S. (1996) Matching species traits to environmental variables: a new three-table ordination method. Environmental and Ecological Statistics, 3, 143–166.
data(aviurba) a1 <- dudi.coa(aviurba$fau, scan = FALSE, nf=4) a2 <- dudi.acm(aviurba$mil, row.w = a1$lw, scan = FALSE, nf = 4) plot(coinertia(a1, a2, scan = FALSE))
data(aviurba) a1 <- dudi.coa(aviurba$fau, scan = FALSE, nf=4) a2 <- dudi.acm(aviurba$mil, row.w = a1$lw, scan = FALSE, nf = 4) plot(coinertia(a1, a2, scan = FALSE))
bacteria
is a list containing 43 species and genomic informations : codons, amino acid and bases.
data(bacteria)
data(bacteria)
This list contains the following objects:
is a factor with the amino acid names for each codon.
is a data frame 43 species 64 codons.
is a data frame 43 species 21 amino acid.
is a data frame 43 species 4 bases.
Data prepared by J. Lobry [email protected] starting from https://www.jcvi.org/.
data(bacteria) names(bacteria$espcodon) names(bacteria$espaa) names(bacteria$espbase) sum(bacteria$espcodon) # 22,619,749 codons if(adegraphicsLoaded()) { g <- scatter(dudi.coa(bacteria$espcodon, scann = FALSE), posi = "bottomleft") } else { scatter(dudi.coa(bacteria$espcodon, scann = FALSE), posi = "bottomleft") }
data(bacteria) names(bacteria$espcodon) names(bacteria$espaa) names(bacteria$espbase) sum(bacteria$espcodon) # 22,619,749 codons if(adegraphicsLoaded()) { g <- scatter(dudi.coa(bacteria$espcodon, scann = FALSE), posi = "bottomleft") } else { scatter(dudi.coa(bacteria$espcodon, scann = FALSE), posi = "bottomleft") }
banque
gives the results of a bank survey onto 810 customers.
data(banque)
data(banque)
This data frame contains the following columns:
csp: "Socio-professional categories" a factor with levels
agric
Farmers
artis
Craftsmen, Shopkeepers, Company directors
cadsu
Executives and higher intellectual professions
inter
Intermediate professions
emplo
Other white-collar workers
ouvri
Manual workers
retra
Pensionners
inact
Non working population
etudi
Students
duree: "Time relations with the customer" a factor with levels
dm2
<2 years
d24
[2 years, 4 years[
d48
[4 years, 8 years[
d812
[8 years, 12 years[
dp12
>= 12 years
oppo: "Stopped a check?" a factor with levels
non
no
oui
yes
age: "Customer's age" a factor with levels
ai25
[18 years, 25 years[
ai35
[25 years, 35 years[
ai45
[35 years, 45 years[
ai55
[45 years, 55 years[
ai75
[55 years, 75 years[
sexe: "Customer's gender" a factor with levels
hom
Male
fem
Female
interdit: "No checkbook allowed" a factor with levels
non
no
oui
yes
cableue: "Possess a bank card?" a factor with levels
non
no
oui
yes
assurvi: "Contrat of life insurance?" a factor with levels
non
no
oui
yes
soldevu: "Balance of the current accounts" a factor with levels
p4
credit balance > 20000
p3
credit balance 12000-20000
p2
credit balance 4000-12000
p1
credit balance >0-4000
n1
debit balance 0-4000
n2
debit balance >4000
eparlog: "Savings and loan association account amount" a factor with levels
for
> 20000
fai
>0 and <20000
nul
nulle
eparliv: "Savings bank amount" a factor with levels
for
> 20000
fai
>0 and <20000
nul
nulle
credhab: "Home loan owner" a factor with levels
non
no
oui
yes
credcon: "Consumer credit amount" a factor with levels
nul
none
fai
>0 and <20000
for
> 20000
versesp: "Check deposits" a factor with levels
oui
yes
non
no
retresp: "Cash withdrawals" a factor with levels
fai
< 2000
moy
2000-5000
for
> 5000
remiche: "Endorsed checks amount" a factor with levels
for
>10000
moy
10000-5000
fai
1-5000
nul
none
preltre: "Treasury Department tax deductions" a factor with levels
nul
none
fai
<1000
moy
>1000
prelfin: "Financial institution deductions" a factor with levels
nul
none
fai
<1000
moy
>1000
viredeb: "Debit transfer amount" a factor with levels
nul
none
fai
<2500
moy
2500-5000
for
>5000
virecre: "Credit transfer amount" a factor with levels
for
>10000
moy
10000-5000
fai
<5000
nul
aucun
porttit: "Securities portfolio estimations" a factor with levels
nul
none
fai
< 20000
moy
20000-100000
for
>100000
anonymous
data(banque) banque.acm <- dudi.acm(banque, scannf = FALSE, nf = 3) apply(banque.acm$cr, 2, mean) banque.acm$eig[1:banque.acm$nf] # the same thing if(adegraphicsLoaded()) { g <- s.arrow(banque.acm$c1, plabels.cex = 0.75) } else { s.arrow(banque.acm$c1, clab = 0.75) }
data(banque) banque.acm <- dudi.acm(banque, scannf = FALSE, nf = 3) apply(banque.acm$cr, 2, mean) banque.acm$eig[1:banque.acm$nf] # the same thing if(adegraphicsLoaded()) { g <- s.arrow(banque.acm$c1, plabels.cex = 0.75) } else { s.arrow(banque.acm$c1, clab = 0.75) }
This data set is a list containing relations between sites and fish species linked to dates.
data(baran95)
data(baran95)
This list contains the following objects:
is a data frame 95 seinings and 33 fish species.
is a data frame 2 factors : date and site. The date
has 6 levels (april 1993, june 1993,
august 1993, october 1993, december 1993 and february 1994) and the sites
are defined by 4 distances to the
Atlantic Ocean (km03, km17, km33 and km46).
is a vector of species latin names.
Baran, E. (1995) Dynamique spatio-temporelle des peuplements de Poissons estuariens en Guinée (Afrique de l'Ouest). Thèse de Doctorat, Université de Bretagne Occidentale. Data collected by net fishing sampling in the Fatala river estuary.
See a data description at http://pbil.univ-lyon1.fr/R/pdf/pps027.pdf (in French).
data(baran95) w <- dudi.pca(log(baran95$fau + 1), scal = FALSE, scann = FALSE, nf = 3) w1 <- wca(w, baran95$plan$date, scann = FALSE) fatala <- ktab.within(w1) stat1 <- statis(fatala, scan = FALSE, nf = 3) mfa1 <- mfa(fatala, scan = FALSE, nf = 3) if(adegraphicsLoaded()) { g1 <- s.class(stat1$C.Co, baran95$plan$site, facets = baran95$plan$date, pellipses.axes.draw = FALSE, ppoints.cex = 0.5, plot = FALSE) n1 <- length(g1@ADEglist) g2 <- ADEgS(lapply(1:n1, function(i) s.label(stat1$C.Co, plabels.cex = 0, ppoints.cex = 0.5, plot = FALSE)), positions = g1@positions, plot = FALSE) G1 <- superpose(g2, g1, plot = TRUE) G2 <- kplot(stat1, arrow = FALSE, traject = FALSE, class = baran95$plan$site, col.plabels.cex = 0, ppoints.cex = 0.5) g3 <- s.class(mfa1$co, baran95$plan$site, facets = baran95$plan$date, pellipses.axes.draw = FALSE, ppoints.cex = 0.5, plot = FALSE) n2 <- length(g3@ADEglist) g4 <- ADEgS(lapply(1:n2, function(i) s.label(mfa1$co, plabels.cex = 0, ppoints.cex = 0.5, plot = FALSE)), positions = g3@positions, plot = FALSE) G3 <- superpose(g4, g3, plot = TRUE) } else { par(mfrow = c(3, 2)) w2 <- split(stat1$C.Co, baran95$plan$date) w3 <- split(baran95$plan$site, baran95$plan$date) for (j in 1:6) { s.label(stat1$C.Co[,1:2], clab = 0, sub = tab.names(fatala)[j], csub = 3) s.class(w2[[j]][, 1:2], w3[[j]], clab = 2, axese = FALSE, add.plot = TRUE) } par(mfrow = c(1, 1)) kplot(stat1, arrow = FALSE, traj = FALSE, clab = 2, uni = TRUE, class = baran95$plan$site) #simpler par(mfrow = c(3, 2)) w4 <- split(mfa1$co, baran95$plan$date) for (j in 1:6) { s.label(mfa1$co[, 1:2], clab = 0, sub = tab.names(fatala)[j], csub = 3) s.class(w4[[j]][, 1:2], w3[[j]], clab = 2, axese = FALSE, add.plot = TRUE) } par(mfrow = c(1, 1)) }
data(baran95) w <- dudi.pca(log(baran95$fau + 1), scal = FALSE, scann = FALSE, nf = 3) w1 <- wca(w, baran95$plan$date, scann = FALSE) fatala <- ktab.within(w1) stat1 <- statis(fatala, scan = FALSE, nf = 3) mfa1 <- mfa(fatala, scan = FALSE, nf = 3) if(adegraphicsLoaded()) { g1 <- s.class(stat1$C.Co, baran95$plan$site, facets = baran95$plan$date, pellipses.axes.draw = FALSE, ppoints.cex = 0.5, plot = FALSE) n1 <- length(g1@ADEglist) g2 <- ADEgS(lapply(1:n1, function(i) s.label(stat1$C.Co, plabels.cex = 0, ppoints.cex = 0.5, plot = FALSE)), positions = g1@positions, plot = FALSE) G1 <- superpose(g2, g1, plot = TRUE) G2 <- kplot(stat1, arrow = FALSE, traject = FALSE, class = baran95$plan$site, col.plabels.cex = 0, ppoints.cex = 0.5) g3 <- s.class(mfa1$co, baran95$plan$site, facets = baran95$plan$date, pellipses.axes.draw = FALSE, ppoints.cex = 0.5, plot = FALSE) n2 <- length(g3@ADEglist) g4 <- ADEgS(lapply(1:n2, function(i) s.label(mfa1$co, plabels.cex = 0, ppoints.cex = 0.5, plot = FALSE)), positions = g3@positions, plot = FALSE) G3 <- superpose(g4, g3, plot = TRUE) } else { par(mfrow = c(3, 2)) w2 <- split(stat1$C.Co, baran95$plan$date) w3 <- split(baran95$plan$site, baran95$plan$date) for (j in 1:6) { s.label(stat1$C.Co[,1:2], clab = 0, sub = tab.names(fatala)[j], csub = 3) s.class(w2[[j]][, 1:2], w3[[j]], clab = 2, axese = FALSE, add.plot = TRUE) } par(mfrow = c(1, 1)) kplot(stat1, arrow = FALSE, traj = FALSE, clab = 2, uni = TRUE, class = baran95$plan$site) #simpler par(mfrow = c(3, 2)) w4 <- split(mfa1$co, baran95$plan$date) for (j in 1:6) { s.label(mfa1$co[, 1:2], clab = 0, sub = tab.names(fatala)[j], csub = 3) s.class(w4[[j]][, 1:2], w3[[j]], clab = 2, axese = FALSE, add.plot = TRUE) } par(mfrow = c(1, 1)) }
Performs a particular case of a Principal Component Analysis with respect to Instrumental Variables (pcaiv), in which there is only a single factor as explanatory variable.
## S3 method for class 'dudi' bca(x, fac, scannf = TRUE, nf = 2, ...)
## S3 method for class 'dudi' bca(x, fac, scannf = TRUE, nf = 2, ...)
x |
a duality diagram, object of class |
fac |
a factor partitioning the rows of |
scannf |
a logical value indicating whether the eigenvalues barplot should be displayed |
nf |
if scannf FALSE, a numeric value indicating the number of kept axes |
... |
further arguments passed to or from other methods |
Returns a list of class dudi
, subclass 'between' containing
tab |
a data frame class-variables containing the means per class for each variable |
cw |
a numeric vector of the column weigths |
lw |
a numeric vector of the class weigths |
eig |
a numeric vector with all the eigenvalues |
rank |
the rank of the analysis |
nf |
an integer value indicating the number of kept axes |
c1 |
a data frame with the column normed scores |
l1 |
a data frame with the class normed scores |
co |
a data frame with the column coordinates |
li |
a data frame with the class coordinates |
call |
the matching call |
ratio |
the bewteen-class inertia percentage |
ls |
a data frame with the row coordinates |
as |
a data frame containing the projection of inertia axes onto between axes |
To avoid conflict names with the base:::within
function, the
function within
is now deprecated and removed. To be
consistent, the between
function is also deprecated and
is replaced by the method bca.dudi
of the new generic bca
function.
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Dolédec, S. and Chessel, D. (1987) Rythmes saisonniers et composantes stationnelles en milieu aquatique I- Description d'un plan d'observations complet par projection de variables. Acta Oecologica, Oecologia Generalis, 8, 3, 403–426.
data(meaudret) pca1 <- dudi.pca(meaudret$env, scan = FALSE, nf = 4) pca2 <- dudi.pca(meaudret$spe, scal = FALSE, scan = FALSE, nf = 4) bet1 <- bca(pca1, meaudret$design$site, scan = FALSE, nf = 2) bet2 <- bca(pca2, meaudret$design$site, scan = FALSE, nf = 2) if(adegraphicsLoaded()) { g1 <- s.class(pca1$li, meaudret$design$site, psub.text = "Principal Component Analysis (env)", plot = FALSE) g2 <- s.class(pca2$li, meaudret$design$site, psub.text = "Principal Component Analysis (spe)", plot = FALSE) g3 <- s.class(bet1$ls, meaudret$design$site, psub.text = "Between sites PCA (env)", plot = FALSE) g4 <- s.class(bet2$ls, meaudret$design$site, psub.text = "Between sites PCA (spe)", plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2, 2)) s.class(pca1$li, meaudret$design$site, sub = "Principal Component Analysis (env)", csub = 1.75) s.class(pca2$li, meaudret$design$site, sub = "Principal Component Analysis (spe)", csub = 1.75) s.class(bet1$ls, meaudret$design$site, sub = "Between sites PCA (env)", csub = 1.75) s.class(bet2$ls, meaudret$design$site, sub = "Between sites PCA (spe)", csub = 1.75) par(mfrow = c(1, 1)) } coib <- coinertia(bet1, bet2, scann = FALSE) plot(coib)
data(meaudret) pca1 <- dudi.pca(meaudret$env, scan = FALSE, nf = 4) pca2 <- dudi.pca(meaudret$spe, scal = FALSE, scan = FALSE, nf = 4) bet1 <- bca(pca1, meaudret$design$site, scan = FALSE, nf = 2) bet2 <- bca(pca2, meaudret$design$site, scan = FALSE, nf = 2) if(adegraphicsLoaded()) { g1 <- s.class(pca1$li, meaudret$design$site, psub.text = "Principal Component Analysis (env)", plot = FALSE) g2 <- s.class(pca2$li, meaudret$design$site, psub.text = "Principal Component Analysis (spe)", plot = FALSE) g3 <- s.class(bet1$ls, meaudret$design$site, psub.text = "Between sites PCA (env)", plot = FALSE) g4 <- s.class(bet2$ls, meaudret$design$site, psub.text = "Between sites PCA (spe)", plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2, 2)) s.class(pca1$li, meaudret$design$site, sub = "Principal Component Analysis (env)", csub = 1.75) s.class(pca2$li, meaudret$design$site, sub = "Principal Component Analysis (spe)", csub = 1.75) s.class(bet1$ls, meaudret$design$site, sub = "Between sites PCA (env)", csub = 1.75) s.class(bet2$ls, meaudret$design$site, sub = "Between sites PCA (spe)", csub = 1.75) par(mfrow = c(1, 1)) } coib <- coinertia(bet1, bet2, scann = FALSE) plot(coib)
Performs a between-class analysis after a coinertia analysis
## S3 method for class 'coinertia' bca(x, fac, scannf = TRUE, nf = 2, ...)
## S3 method for class 'coinertia' bca(x, fac, scannf = TRUE, nf = 2, ...)
x |
a coinertia analysis (object of class coinertia) obtained by the function coinertia |
fac |
a factor partitioning the rows in classes |
scannf |
a logical value indicating whether the eigenvalues barplot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
... |
further arguments passed to or from other methods |
This analysis is equivalent to do a between-class analysis on each initial dudi, and a coinertia analysis on the two between analyses. This function returns additional outputs for the interpretation.
An object of the class betcoi
. Outputs are described by the
print
function
To avoid conflict names with the base:::within
function, the
function within
is now deprecated and removed. To be
consistent, the betweencoinertia
function is also deprecated and
is replaced by the method bca.coinertia
of the new generic bca
function.
Stéphane Dray [email protected] and Jean Thioulouse [email protected]
Franquet E., Doledec S., and Chessel D. (1995) Using multivariate analyses for separating spatial and temporal effects within species-environment relationships. Hydrobiologia, 300, 425–431.
data(meaudret) pca1 <- dudi.pca(meaudret$env, scan = FALSE, nf = 4) pca2 <- dudi.pca(meaudret$spe, scal = FALSE, scan = FALSE, nf = 4) bet1 <- bca(pca1, meaudret$design$site, scan = FALSE, nf = 2) bet2 <- bca(pca2, meaudret$design$site, scan = FALSE, nf = 2) coib <- coinertia(bet1, bet2, scannf = FALSE) coi <- coinertia(pca1, pca2, scannf = FALSE, nf = 3) coi.b <- bca(coi,meaudret$design$site, scannf = FALSE) ## coib and coi.b are equivalent plot(coi.b)
data(meaudret) pca1 <- dudi.pca(meaudret$env, scan = FALSE, nf = 4) pca2 <- dudi.pca(meaudret$spe, scal = FALSE, scan = FALSE, nf = 4) bet1 <- bca(pca1, meaudret$design$site, scan = FALSE, nf = 2) bet2 <- bca(pca2, meaudret$design$site, scan = FALSE, nf = 2) coib <- coinertia(bet1, bet2, scannf = FALSE) coi <- coinertia(pca1, pca2, scannf = FALSE, nf = 3) coi.b <- bca(coi,meaudret$design$site, scannf = FALSE) ## coib and coi.b are equivalent plot(coi.b)
Performs a particular RLQ analysis where a partition of sites (rows of R) is taken into account. The between-class RLQ analysis search for linear combinations of traits and environmental variables maximizing the covariances between the traits and the average environmental conditions of classes.
## S3 method for class 'rlq' bca(x, fac, scannf = TRUE, nf = 2, ...) ## S3 method for class 'betrlq' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'betrlq' print(x, ...)
## S3 method for class 'rlq' bca(x, fac, scannf = TRUE, nf = 2, ...) ## S3 method for class 'betrlq' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'betrlq' print(x, ...)
x |
an object of class rlq (created by the |
fac |
a factor partitioning the rows of R |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
xax |
the column number for the x-axis |
yax |
the column number for the y-axis |
... |
further arguments passed to or from other methods |
The bca.rlq
function returns an object of class 'betrlq'
(sub-class of 'dudi'). See the outputs of the print
function
for more details.
Stéphane Dray [email protected]
Wesuls, D., Oldeland, J. and Dray, S. (2012) Disentangling plant trait responses to livestock grazing from spatio-temporal variation: the partial RLQ approach. Journal of Vegetation Science, 23, 98–113.
data(piosphere) afcL <- dudi.coa(log(piosphere$veg + 1), scannf = FALSE) acpR <- dudi.pca(piosphere$env, scannf = FALSE, row.w = afcL$lw) acpQ <- dudi.hillsmith(piosphere$traits, scannf = FALSE, row.w = afcL$cw) rlq1 <- rlq(acpR, afcL, acpQ, scannf = FALSE) brlq1 <- bca(rlq1, fac = piosphere$habitat, scannf = FALSE) brlq1 plot(brlq1)
data(piosphere) afcL <- dudi.coa(log(piosphere$veg + 1), scannf = FALSE) acpR <- dudi.pca(piosphere$env, scannf = FALSE, row.w = afcL$lw) acpQ <- dudi.hillsmith(piosphere$traits, scannf = FALSE, row.w = afcL$cw) rlq1 <- rlq(acpR, afcL, acpQ, scannf = FALSE) brlq1 <- bca(rlq1, fac = piosphere$habitat, scannf = FALSE) brlq1 plot(brlq1)
Outputs and graphical representations of the results of a between-class analysis.
## S3 method for class 'between' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'between' print(x, ...) ## S3 method for class 'betcoi' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'betcoi' print(x, ...) ## S3 method for class 'between' summary(object, ...)
## S3 method for class 'between' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'between' print(x, ...) ## S3 method for class 'betcoi' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'betcoi' print(x, ...) ## S3 method for class 'between' summary(object, ...)
x , object
|
an object of class |
xax , yax
|
the column index of the x-axis and the y-axis |
... |
further arguments passed to or from other methods |
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Stéphane Dray [email protected]
Dolédec, S. and Chessel, D. (1987) Rythmes saisonniers et composantes stationnelles en milieu aquatique I- Description d'un plan d'observations complet par projection de variables. Acta Oecologica, Oecologia Generalis, 8, 3, 403–426.
data(meaudret) pca1 <- dudi.pca(meaudret$env, scan = FALSE, nf = 4) pca2 <- dudi.pca(meaudret$spe, scal = FALSE, scan = FALSE, nf = 4) bet1 <- bca(pca1, meaudret$design$site, scan = FALSE, nf = 2) bet2 <- bca(pca2, meaudret$design$site, scan = FALSE, nf = 2) if(adegraphicsLoaded()) { g1 <- s.class(pca1$li, meaudret$design$site, psub.text = "Principal Component Analysis (env)", plot = FALSE) g2 <- s.class(pca2$li, meaudret$design$site, psub.text = "Principal Component Analysis (spe)", plot = FALSE) g3 <- s.class(bet1$ls, meaudret$design$site, psub.text = "Between sites PCA (env)", plot = FALSE) g4 <- s.class(bet2$ls, meaudret$design$site, psub.text = "Between sites PCA (spe)", plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2, 2)) s.class(pca1$li, meaudret$design$site, sub = "Principal Component Analysis (env)", csub = 1.75) s.class(pca2$li, meaudret$design$site, sub = "Principal Component Analysis (spe)", csub = 1.75) s.class(bet1$ls, meaudret$design$site, sub = "Between sites PCA (env)", csub = 1.75) s.class(bet2$ls, meaudret$design$site, sub = "Between sites PCA (spe)", csub = 1.75) par(mfrow = c(1,1)) } coib <- coinertia(bet1, bet2, scann = FALSE) plot(coib)
data(meaudret) pca1 <- dudi.pca(meaudret$env, scan = FALSE, nf = 4) pca2 <- dudi.pca(meaudret$spe, scal = FALSE, scan = FALSE, nf = 4) bet1 <- bca(pca1, meaudret$design$site, scan = FALSE, nf = 2) bet2 <- bca(pca2, meaudret$design$site, scan = FALSE, nf = 2) if(adegraphicsLoaded()) { g1 <- s.class(pca1$li, meaudret$design$site, psub.text = "Principal Component Analysis (env)", plot = FALSE) g2 <- s.class(pca2$li, meaudret$design$site, psub.text = "Principal Component Analysis (spe)", plot = FALSE) g3 <- s.class(bet1$ls, meaudret$design$site, psub.text = "Between sites PCA (env)", plot = FALSE) g4 <- s.class(bet2$ls, meaudret$design$site, psub.text = "Between sites PCA (spe)", plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2, 2)) s.class(pca1$li, meaudret$design$site, sub = "Principal Component Analysis (env)", csub = 1.75) s.class(pca2$li, meaudret$design$site, sub = "Principal Component Analysis (spe)", csub = 1.75) s.class(bet1$ls, meaudret$design$site, sub = "Between sites PCA (env)", csub = 1.75) s.class(bet2$ls, meaudret$design$site, sub = "Between sites PCA (spe)", csub = 1.75) par(mfrow = c(1,1)) } coib <- coinertia(bet1, bet2, scann = FALSE) plot(coib)
bf88
is a list of 6 data frames corresponding to 6 stages of vegetation.
Each data frame gives some bird species informations for 4 counties.
data(bf88)
data(bf88)
A list of six data frames with 79 rows (bird species) and 4 columns (counties).
The 6 arrays (S1 to S6) are the 6 stages of vegetation.
The attribut 'nomesp' of this list is a vector of species French names.
Blondel, J. and Farre, H. (1988) The convergent trajectories of bird communities along ecological successions in european forests. Oecologia (Berlin), 75, 83–93.
data(bf88) fou1 <- foucart(bf88, scann = FALSE, nf = 3) fou1 if(adegraphicsLoaded()) { g1 <- scatter(fou1, plot = FALSE) g2 <- s.traject(fou1$Tco, fou1$TC[, 1], plines.lty = 1:length(levels(fou1$TC[, 1])), plot = FALSE) g3 <- s.traject(fou1$Tco, fou1$TC[, 2], plines.lty = 1:length(levels(fou1$TC[, 2])), plot = FALSE) g41 <- s.label(fou1$Tco, plot = FALSE) g42 <- s.label(fou1$co, plab.cex = 2, plot = FALSE) g4 <- superpose(g41, g42, plot = FALSE) G1 <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) G2 <- kplot(fou1, row.plab.cex = 0, psub.cex = 2) } else { par(mfrow = c(2,2)) scatter(fou1) s.traject(fou1$Tco, fou1$TC[, 1]) s.traject(fou1$Tco, fou1$TC[, 2]) s.label(fou1$Tco) s.label(fou1$co, add.p = TRUE, clab = 2) par(mfrow = c(1, 1)) kplot(fou1, clab.c = 2, clab.r = 0, csub = 3) }
data(bf88) fou1 <- foucart(bf88, scann = FALSE, nf = 3) fou1 if(adegraphicsLoaded()) { g1 <- scatter(fou1, plot = FALSE) g2 <- s.traject(fou1$Tco, fou1$TC[, 1], plines.lty = 1:length(levels(fou1$TC[, 1])), plot = FALSE) g3 <- s.traject(fou1$Tco, fou1$TC[, 2], plines.lty = 1:length(levels(fou1$TC[, 2])), plot = FALSE) g41 <- s.label(fou1$Tco, plot = FALSE) g42 <- s.label(fou1$co, plab.cex = 2, plot = FALSE) g4 <- superpose(g41, g42, plot = FALSE) G1 <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) G2 <- kplot(fou1, row.plab.cex = 0, psub.cex = 2) } else { par(mfrow = c(2,2)) scatter(fou1) s.traject(fou1$Tco, fou1$TC[, 1]) s.traject(fou1$Tco, fou1$TC[, 2]) s.label(fou1$Tco) s.label(fou1$co, add.p = TRUE, clab = 2) par(mfrow = c(1, 1)) kplot(fou1, clab.c = 2, clab.r = 0, csub = 3) }
This function creates a doubly centred matrix.
bicenter.wt(X, row.wt = rep(1, nrow(X)), col.wt = rep(1, ncol(X)))
bicenter.wt(X, row.wt = rep(1, nrow(X)), col.wt = rep(1, ncol(X)))
X |
a matrix with n rows and p columns |
row.wt |
a vector of positive or null weights of length n |
col.wt |
a vector of positive or null weights of length p |
returns a doubly centred matrix
Daniel Chessel
w <- matrix(1:6, 3, 2) bicenter.wt(w, c(0.2,0.6,0.2), c(0.3,0.7)) w <- matrix(1:20, 5, 4) sum(bicenter.wt(w, runif(5), runif(4))^2)
w <- matrix(1:6, 3, 2) bicenter.wt(w, c(0.2,0.6,0.2), c(0.3,0.7)) w <- matrix(1:20, 5, 4) sum(bicenter.wt(w, runif(5), runif(4))^2)
The bordeaux
data frame gives the opinions of 200 judges in a blind tasting of five different types of claret
(red wine from the Bordeaux area in the south western parts of France).
data(bordeaux)
data(bordeaux)
This data frame has 5 rows (the wines) and 4 columns (the judgements) divided in excellent, good, mediocre and boring.
van Rijckevorsel, J. (1987) The application of fuzzy coding and horseshoes in multiple correspondence analysis. DSWO Press, Leiden (p. 32)
data(bordeaux) bordeaux score(dudi.coa(bordeaux, scan = FALSE))
data(bordeaux) bordeaux score(dudi.coa(bordeaux, scan = FALSE))
This data set gives ecological and biological characteristics of 131 species of aquatic insects.
data(bsetal97)
data(bsetal97)
bsetal97
is a list of 8 components.
is a vector of the names of aquatic insects.
is a data frame containing the taxonomy of species: genus, family and order.
is a data frame containing 10 biological traits for a total of 41 modalities.
is a vector of the numbers of items for each biological trait.
is a vector of the names of the biological traits.
is a data frame with 7 ecological traits for a total of 34 modalities.
is a vector of the numbers of items for each ecological trait.
is a vector of the names of the ecological traits.
The 10 variables of the data frame bsetal97$biol
are called in bsetal97$biol.blo.names
and the number of modalities per variable given in bsetal97$biol.blo
. The variables are:
female size - the body length from the front of the head to the end of the abdomen (7 length modalities),
egg length - the egg size (6 modalities), egg number - count of eggs actually oviposited,
generations per year (3 modalities: , 2, > 2),
oviposition period - the length of time during which oviposition occurred (3 modalities:
months,
between 2 and 5 months, > 5 months), incubation time - the time between oviposition and hatching of the larvae
(3 modalities:
weeks, between 4 and 12 weeks, > 12 weeks), egg shape (1-spherical, 2-oval, 3-cylindrical),
egg attachment - physiological feature of the egg and of the female (4 modalities), clutch structure (1-single eggs, 2-grouped eggs,
3-egg masses), clutch number (3 modalities : 1, 2, > 2).
The 7 variables of the data frame bsetal97$ecol
are called in bsetal97$ecol.blo.names
and the number of modalities per variable given in bsetal97$ecol.blo
. The variables are:
oviposition site - position relative to the water (7 modalities), substratum type for eggs - the substratum to which
the eggs are definitely attached (6 modalities), egg deposition - the position of the eggs during the oviposition process (4 modalities),
gross habitat - the general habitat use of the species such as temporary waters or estuaries (8 modalities), saturation variance -
the exposure of eggs to the risk of dessication (2 modalities), time of day (1-morning, 2-day, 3-evening, 4-night),
season - time of the year (1-Spring, 2-Summer, 3-Automn).
Statzner, B., Hoppenhaus, K., Arens, M.-F. and Richoux, P. (1997) Reproductive traits, habitat use and templet theory: a synthesis of world-wide data on aquatic insects. Freshwater Biology, 38, 109–135.
See a data description at http://pbil.univ-lyon1.fr/R/pdf/pps029.pdf (in French).
data(bsetal97) X <- prep.fuzzy.var(bsetal97$biol, bsetal97$biol.blo) Y <- prep.fuzzy.var(bsetal97$ecol, bsetal97$ecol.blo) plot(coinertia(dudi.fca(X, scan = FALSE), dudi.fca(Y, scan = FALSE), scan = FALSE))
data(bsetal97) X <- prep.fuzzy.var(bsetal97$biol, bsetal97$biol.blo) Y <- prep.fuzzy.var(bsetal97$ecol, bsetal97$ecol.blo) plot(coinertia(dudi.fca(X, scan = FALSE), dudi.fca(Y, scan = FALSE), scan = FALSE))
This data set contains informations about Buech basin characteristics.
data(buech)
data(buech)
buech
is a list with the following components:
a data frame with 10 environmental variables collected on 31 sites in Juin (1984)
a data frame with 10 environmental variables collected on 31 sites in September (1984)
a data frame with the coordinates of the sites
a data frame for background map
the neighbouring graph between sites, object of the class nb
an object of the class SpatialPolygons
of sp
,
containing the map
Variables of buech$tab1
and buech$tab2
are the following ones:
pH ;
Conductivity ( S/cm) ;
Carbonate (water hardness (mg/l CaCO3)) ;
hardness (total water hardness (mg/l CaCO3)) ;
Bicarbonate (alcalinity (mg/l HCO3-)) ;
Chloride (alcalinity (mg/l Cl-)) ;
Suspens (particles in suspension (mg/l)) ;
Organic (organic particles (mg/l)) ;
Nitrate (nitrate rate (mg/l NO3-)) ;
Ammonia (amoniac rate (mg/l NH4-))
Vespini, F. (1985) Contribution à l'étude hydrobiologique du Buech, rivière non aménagée de Haute-Provence. Thèse de troisième cycle, Université de Provence.
Vespini, F., Légier, P. and Champeau, A. (1987) Ecologie d'une rivière non aménagée des Alpes du Sud : Le Buëch (France) I. Evolution longitudinale des descripteurs physiques et chimiques. Annales de Limnologie, 23, 151–164.
data(buech) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g1 <- s.label(buech$xy, Sp = buech$Spatial, nb = buech$nb, pSp.col = "transparent", plot = FALSE) g2 <- s.value(buech$xy, buech$tab2$Suspens - buech$tab1$Suspens, Sp = buech$Spatial, nb = buech$nb, pSp.col = "transparent", plot = FALSE) G <- cbindADEg(g1, g2, plot = TRUE) } }
data(buech) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g1 <- s.label(buech$xy, Sp = buech$Spatial, nb = buech$nb, pSp.col = "transparent", plot = FALSE) g2 <- s.value(buech$xy, buech$tab2$Suspens - buech$tab1$Suspens, Sp = buech$Spatial, nb = buech$nb, pSp.col = "transparent", plot = FALSE) G <- cbindADEg(g1, g2, plot = TRUE) } }
This data set contains environmental and genetics informations about 16 Euphydryas editha butterfly colonies studied in California and Oregon.
data(butterfly)
data(butterfly)
butterfly
is a list with the following components:
a data frame with the two coordinates of the 16 Euphydryas editha butterfly colonies
a environmental data frame of 16 sites - 4 variables
a genetics data frame of 16 sites - 6 allele frequencies
a data frame for background map (California map)
an object of the class SpatialPolygons
of sp
,
containing the map
McKechnie, S.W., Ehrlich, P.R. and White, R.R. (1975). Population genetics of Euphydryas butterflies. I. Genetic variation and the neutrality hypothesis. Genetics, 81, 571–594.
Manly, B.F. (1994) Multivariate Statistical Methods. A primer. Second edition. Chapman & Hall, London. 1–215.
data(butterfly) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g1 <- s.label(butterfly$xy, Sp = butterfly$Spatial, pSp.col = "white", porigin.include = FALSE, plot = FALSE) g2 <- table.value(dist(butterfly$xy), plot = FALSE) g3 <- s.value(butterfly$xy, dudi.pca(butterfly$envir, scan = FALSE)$li[, 1], Sp = butterfly$Spatial, pori.inc = FALSE, pSp.col = "transparent", ppoints.cex = 2, plot = FALSE) ## mt <- mantel.randtest(dist(butterfly$xy), dist(butterfly$gen), 99) G <- ADEgS(list(g1, g2, g3), layout = c(2, 2), plot = TRUE) } } else { par(mfrow = c(2, 2)) s.label(butterfly$xy, contour = butterfly$contour, inc = FALSE) table.dist(dist(butterfly$xy), labels = row.names(butterfly$xy)) # depends of mva s.value(butterfly$xy, dudi.pca(butterfly$envir, scan = FALSE)$li[,1], contour = butterfly$contour, inc = FALSE, csi = 3) plot(mantel.randtest(dist(butterfly$xy), dist(butterfly$gen), 99), main = "genetic/spatial") par(mfrow = c(1,1)) }
data(butterfly) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g1 <- s.label(butterfly$xy, Sp = butterfly$Spatial, pSp.col = "white", porigin.include = FALSE, plot = FALSE) g2 <- table.value(dist(butterfly$xy), plot = FALSE) g3 <- s.value(butterfly$xy, dudi.pca(butterfly$envir, scan = FALSE)$li[, 1], Sp = butterfly$Spatial, pori.inc = FALSE, pSp.col = "transparent", ppoints.cex = 2, plot = FALSE) ## mt <- mantel.randtest(dist(butterfly$xy), dist(butterfly$gen), 99) G <- ADEgS(list(g1, g2, g3), layout = c(2, 2), plot = TRUE) } } else { par(mfrow = c(2, 2)) s.label(butterfly$xy, contour = butterfly$contour, inc = FALSE) table.dist(dist(butterfly$xy), labels = row.names(butterfly$xy)) # depends of mva s.value(butterfly$xy, dudi.pca(butterfly$envir, scan = FALSE)$li[,1], contour = butterfly$contour, inc = FALSE, csi = 3) plot(mantel.randtest(dist(butterfly$xy), dist(butterfly$gen), 99), main = "genetic/spatial") par(mfrow = c(1,1)) }
These functions allow to study the variations in diversity among communities (as in dpcoa) taking into account a partition in classes
bwca.dpcoa(x, fac, cofac, scannf = TRUE, nf = 2, ...) ## S3 method for class 'dpcoa' bca(x, fac, scannf = TRUE, nf = 2, ...) ## S3 method for class 'dpcoa' wca(x, fac, scannf = TRUE, nf = 2, ...) ## S3 method for class 'betwit' randtest(xtest, nrepet = 999, ...) ## S3 method for class 'betwit' summary(object, ...) ## S3 method for class 'witdpcoa' print(x, ...) ## S3 method for class 'betdpcoa' print(x, ...)
bwca.dpcoa(x, fac, cofac, scannf = TRUE, nf = 2, ...) ## S3 method for class 'dpcoa' bca(x, fac, scannf = TRUE, nf = 2, ...) ## S3 method for class 'dpcoa' wca(x, fac, scannf = TRUE, nf = 2, ...) ## S3 method for class 'betwit' randtest(xtest, nrepet = 999, ...) ## S3 method for class 'betwit' summary(object, ...) ## S3 method for class 'witdpcoa' print(x, ...) ## S3 method for class 'betdpcoa' print(x, ...)
x |
an object of class |
fac |
a factor partitioning the collections in classes |
scannf |
a logical value indicating whether the eigenvalues barplot should be displayed |
nf |
if scannf FALSE, a numeric value indicating the number of kept axes |
... |
further arguments passed to or from other methods |
cofac |
a cofactor partitioning the collections in classes used as a covariable |
nrepet |
the number of permutations |
xtest , object
|
an object of class |
Objects of class betdpcoa
, witdpcoa
or betwit
Stéphane Dray [email protected]
Dray, S., Pavoine, S. and Aguirre de Carcer, D. (2015) Considering external information to improve the phylogenetic comparison of microbial communities: a new approach based on constrained Double Principal Coordinates Analysis (cDPCoA). Molecular Ecology Resources, 15, 242–249. doi:10.1111/1755-0998.12300
## Not run: ## First example of Dray et al (2015) paper con <- url("https://pbil.univ-lyon1.fr/datasets/dray/MER2014/soilmicrob.rda") load(con) close(con) ## Partial CCA coa <- dudi.coa(soilmicrob$OTU, scannf = FALSE) wcoa <- wca(coa, soilmicrob$env$pH, scannf = FALSE) wbcoa <- bca(wcoa,soilmicrob$env$VegType, scannf = FALSE) ## Classical DPCoA dp <- dpcoa(soilmicrob$OTU, soilmicrob$dphy, RaoDecomp = FALSE, scannf = FALSE) ## Between DPCoA (focus on the effect of vegetation type) bdp <- bca(dp, fac = soilmicrob$env$VegType , scannf = FALSE) bdp$ratio ## 0.2148972 randtest(bdp) ## p = 0.001 ## Within DPCoA (remove the effect of pH) wdp <- wca(dp, fac = soilmicrob$env$pH, scannf = FALSE) wdp$ratio ## 0.5684348 ## Between Within-DPCoA (remove the effect of pH and focus on vegetation type) wbdp <- bwca.dpcoa(dp, fac = soilmicrob$env$VegType, cofac = soilmicrob$env$pH, scannf = FALSE) wbdp$ratio ## 0.05452813 randtest(wbdp) ## p = 0.001 ## End(Not run)
## Not run: ## First example of Dray et al (2015) paper con <- url("https://pbil.univ-lyon1.fr/datasets/dray/MER2014/soilmicrob.rda") load(con) close(con) ## Partial CCA coa <- dudi.coa(soilmicrob$OTU, scannf = FALSE) wcoa <- wca(coa, soilmicrob$env$pH, scannf = FALSE) wbcoa <- bca(wcoa,soilmicrob$env$VegType, scannf = FALSE) ## Classical DPCoA dp <- dpcoa(soilmicrob$OTU, soilmicrob$dphy, RaoDecomp = FALSE, scannf = FALSE) ## Between DPCoA (focus on the effect of vegetation type) bdp <- bca(dp, fac = soilmicrob$env$VegType , scannf = FALSE) bdp$ratio ## 0.2148972 randtest(bdp) ## p = 0.001 ## Within DPCoA (remove the effect of pH) wdp <- wca(dp, fac = soilmicrob$env$pH, scannf = FALSE) wdp$ratio ## 0.5684348 ## Between Within-DPCoA (remove the effect of pH and focus on vegetation type) wbdp <- bwca.dpcoa(dp, fac = soilmicrob$env$VegType, cofac = soilmicrob$env$pH, scannf = FALSE) wbdp$ratio ## 0.05452813 randtest(wbdp) ## p = 0.001 ## End(Not run)
This function computes the smallest positive constant that makes Euclidean a distance matrix and applies it.
cailliez(distmat, print = FALSE, tol = 1e-07, cor.zero = TRUE)
cailliez(distmat, print = FALSE, tol = 1e-07, cor.zero = TRUE)
distmat |
an object of class |
print |
if TRUE, prints the eigenvalues of the matrix |
tol |
a tolerance threshold for zero |
cor.zero |
if TRUE, zero distances are not modified |
an object of class dist
containing a Euclidean distance matrix.
Daniel Chessel
Stéphane Dray [email protected]
Cailliez, F. (1983) The analytical solution of the additive constant problem. Psychometrika, 48, 305–310.
Legendre, P. and Anderson, M.J. (1999) Distance-based redundancy analysis: testing multispecies responses in multifactorial ecological experiments. Ecological Monographs, 69, 1–24.
Legendre, P., and Legendre, L. (1998) Numerical ecology, 2nd English edition edition. Elsevier Science BV, Amsterdam.
data(capitales) d0 <- capitales$dist is.euclid(d0) # FALSE d1 <- cailliez(d0, TRUE) # Cailliez constant = 2429.87867 is.euclid(d1) # TRUE plot(d0, d1) abline(lm(unclass(d1)~unclass(d0))) print(coefficients(lm(unclass(d1)~unclass(d0))), dig = 8) # d1 = d + Cte is.euclid(d0 + 2428) # FALSE is.euclid(d0 + 2430) # TRUE the smallest constant
data(capitales) d0 <- capitales$dist is.euclid(d0) # FALSE d1 <- cailliez(d0, TRUE) # Cailliez constant = 2429.87867 is.euclid(d1) # TRUE plot(d0, d1) abline(lm(unclass(d1)~unclass(d0))) print(coefficients(lm(unclass(d1)~unclass(d0))), dig = 8) # d1 = d + Cte is.euclid(d0 + 2428) # FALSE is.euclid(d0 + 2430) # TRUE the smallest constant
This data set gives the road distances between 15 European capitals and their coordinates.
data(capitales)
data(capitales)
capitales
is a list with the following components:
a data frame containing the coordinates of capitals
a data frame containing three variables, designed to be used in area.plot function
a list of pixmap objects, each one symbolizing a capital
an object of the class SpatialPolygons
of sp
,
containing the map
a dist object the road distances between 15 European capitals
data(capitales) attr(capitales$dist, "Labels") index <- pmatch(tolower(attr(capitales$dist, "Labels")), names(capitales$logo)) w1 <- capitales$area if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g1 <- s.label(capitales$xy, lab = rownames(capitales$xy), porigin.include = FALSE, plot = FALSE) g2 <- s.logo(capitales$xy[sort(rownames(capitales$xy)), ], capitales$logo, Sp = capitales$Spatial, pbackground.col = "lightblue", pSp.col = "white", pgrid.draw = FALSE, plot = FALSE) g3 <- table.value(capitales$dist, ptable.margin = list(b = 5, l = 5, t = 15, r = 15), ptable.x.tck = 3, ptable.y.tck = 3, plot = FALSE) g4 <- s.logo(pcoscaled(lingoes(capitales$dist)), capitales$logo[index], plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } } else { if(requireNamespace("pixmap", quietly = TRUE)) { par(mfrow = c(2, 2)) s.label(capitales$xy, lab = attr(capitales$dist, "Labels"), include.origin = FALSE) area.plot(w1) rect(min(w1$x), min(w1$y), max(w1$x), max(w1$y), col = "lightblue") invisible(lapply(split(w1, w1$id), function(x) polygon(x[, -1], col = "white"))) s.logo(capitales$xy, capitales$logo, klogo = index, add.plot = TRUE, include.origin = FALSE, clogo = 0.5) # depends on pixmap table.dist(capitales$dist, lab = attr(capitales$dist, "Labels")) # depends on mva s.logo(pcoscaled(lingoes(capitales$dist)), capitales$logo, klogo = index, clogo = 0.5) # depends on pixmap par(mfrow = c(1, 1)) } }
data(capitales) attr(capitales$dist, "Labels") index <- pmatch(tolower(attr(capitales$dist, "Labels")), names(capitales$logo)) w1 <- capitales$area if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g1 <- s.label(capitales$xy, lab = rownames(capitales$xy), porigin.include = FALSE, plot = FALSE) g2 <- s.logo(capitales$xy[sort(rownames(capitales$xy)), ], capitales$logo, Sp = capitales$Spatial, pbackground.col = "lightblue", pSp.col = "white", pgrid.draw = FALSE, plot = FALSE) g3 <- table.value(capitales$dist, ptable.margin = list(b = 5, l = 5, t = 15, r = 15), ptable.x.tck = 3, ptable.y.tck = 3, plot = FALSE) g4 <- s.logo(pcoscaled(lingoes(capitales$dist)), capitales$logo[index], plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } } else { if(requireNamespace("pixmap", quietly = TRUE)) { par(mfrow = c(2, 2)) s.label(capitales$xy, lab = attr(capitales$dist, "Labels"), include.origin = FALSE) area.plot(w1) rect(min(w1$x), min(w1$y), max(w1$x), max(w1$y), col = "lightblue") invisible(lapply(split(w1, w1$id), function(x) polygon(x[, -1], col = "white"))) s.logo(capitales$xy, capitales$logo, klogo = index, add.plot = TRUE, include.origin = FALSE, clogo = 0.5) # depends on pixmap table.dist(capitales$dist, lab = attr(capitales$dist, "Labels")) # depends on mva s.logo(pcoscaled(lingoes(capitales$dist)), capitales$logo, klogo = index, clogo = 0.5) # depends on pixmap par(mfrow = c(1, 1)) } }
This data set describes the phylogeny of carnivora as reported by Diniz-Filho et al. (1998). It also gives the body mass of these 19 species.
data(carni19)
data(carni19)
carni19
is a list containing the 2 following objects :
is a character string giving the phylogenetic tree in Newick format.
is a numeric vector which values correspond to the body mass of the 19 species (log scale).
Diniz-Filho, J. A. F., de Sant'Ana, C.E.R. and Bini, L.M. (1998) An eigenvector method for estimating phylogenetic inertia. Evolution, 52, 1247–1262.
data(carni19) carni19.phy <- newick2phylog(carni19$tre) par(mfrow = c(1,2)) symbols.phylog(carni19.phy,carni19$bm-mean(carni19$bm)) dotchart.phylog(carni19.phy, carni19$bm, clabel.l=0.75) par(mfrow = c(1,1))
data(carni19) carni19.phy <- newick2phylog(carni19$tre) par(mfrow = c(1,2)) symbols.phylog(carni19.phy,carni19$bm-mean(carni19$bm)) dotchart.phylog(carni19.phy, carni19$bm, clabel.l=0.75) par(mfrow = c(1,1))
This data set describes the phylogeny of 70 carnivora as reported by Diniz-Filho and Torres (2002). It also gives the geographic range size and body size corresponding to these 70 species.
data(carni70)
data(carni70)
carni70
is a list containing the 2 following objects:
is a character string giving the phylogenetic tree in Newick format. Branch lengths are expressed as divergence times (millions of years)
is a data frame with 70 species and two traits: size (body size (kg)) ; range (geographic range size (km)).
Diniz-Filho, J. A. F., and N. M. Tôrres. (2002) Phylogenetic comparative methods and the geographic range size-body size relationship in new world terrestrial carnivora. Evolutionary Ecology, 16, 351–367.
## Not run: if (requireNamespace("adephylo", quietly = TRUE) & requireNamespace("ape", quietly = TRUE)) { data(carni70) carni70.phy <- newick2phylog(carni70$tre) plot(carni70.phy) size <- scalewt(log(carni70$tab))[,1] names(size) <- row.names(carni70$tab) symbols.phylog(carni70.phy,size) tre <- ape::read.tree(text = carni70$tre) adephylo::orthogram(size, tre = tre) yrange <- scalewt(carni70$tab[,2]) names(yrange) <- row.names(carni70$tab) symbols.phylog(carni70.phy,yrange) adephylo::orthogram(as.vector(yrange), tre = tre) if(adegraphicsLoaded()) { g1 <- s.label(cbind.data.frame(size, yrange), plabel.cex = 0) g2 <- addhist(g1) } else { s.hist(cbind.data.frame(size, yrange), clabel = 0) } } ## End(Not run)
## Not run: if (requireNamespace("adephylo", quietly = TRUE) & requireNamespace("ape", quietly = TRUE)) { data(carni70) carni70.phy <- newick2phylog(carni70$tre) plot(carni70.phy) size <- scalewt(log(carni70$tab))[,1] names(size) <- row.names(carni70$tab) symbols.phylog(carni70.phy,size) tre <- ape::read.tree(text = carni70$tre) adephylo::orthogram(size, tre = tre) yrange <- scalewt(carni70$tab[,2]) names(yrange) <- row.names(carni70$tab) symbols.phylog(carni70.phy,yrange) adephylo::orthogram(as.vector(yrange), tre = tre) if(adegraphicsLoaded()) { g1 <- s.label(cbind.data.frame(size, yrange), plabel.cex = 0) g2 <- addhist(g1) } else { s.hist(cbind.data.frame(size, yrange), clabel = 0) } } ## End(Not run)
This data set describes the taxonomic and phylogenetic relationships of 49 carnivora and herbivora species as reported by Garland and Janis (1993) and Garland et al. (1993). It also gives seven traits corresponding to these 49 species.
data(carniherbi49)
data(carniherbi49)
carniherbi49
is a list containing the 5 following objects :
is a data frame with 49 species and 2 columns : 'fam', a factor family with 14 levels and 'ord', a factor order with 3 levels.
is a character string giving the phylogenetic tree in Newick format as reported by Garland et al. (1993).
is a character string giving the phylogenetic tree in Newick format as reported by Garland and Janis (1993).
is a data frame with 49 species and 2 traits: 'bodymass' (body mass (kg)) and 'homerange' (home range (km)).
is a data frame with 49 species and 5 traits: 'clade' (dietary with two levels Carnivore
and Herbivore
), 'runningspeed' (maximal sprint running speed (km/h)), 'bodymass' (body mass (kg)),
'hindlength' (hind limb length (cm)) and 'mtfratio' (metatarsal/femur ratio).
Garland, T., Dickerman, A. W., Janis, C. M. and Jones, J. A. (1993) Phylogenetic analysis of covariance by computer simulation. Systematics Biology, 42, 265–292.
Garland, T. J. and Janis, C.M. (1993) Does metatarsal-femur ratio predict maximal running speed in cursorial mammals? Journal of Zoology, 229, 133–151.
## Not run: data(carniherbi49) par(mfrow=c(1,3)) plot(newick2phylog(carniherbi49$tre1), clabel.leaves = 0, f.phylog = 2, sub ="article 1") plot(newick2phylog(carniherbi49$tre2), clabel.leaves = 0, f.phylog = 2, sub = "article 2") taxo <- as.taxo(carniherbi49$taxo) plot(taxo2phylog(taxo), clabel.nodes = 1.2, clabel.leaves = 1.2) par(mfrow = c(1,1)) ## End(Not run)
## Not run: data(carniherbi49) par(mfrow=c(1,3)) plot(newick2phylog(carniherbi49$tre1), clabel.leaves = 0, f.phylog = 2, sub ="article 1") plot(newick2phylog(carniherbi49$tre2), clabel.leaves = 0, f.phylog = 2, sub = "article 2") taxo <- as.taxo(carniherbi49$taxo) plot(taxo2phylog(taxo), clabel.nodes = 1.2, clabel.leaves = 1.2) par(mfrow = c(1,1)) ## End(Not run)
This data set is a data frame with 74 rows (mice) and 15 columns (loci enzymatic polymorphism of the DNA mitochondrial). Each value contains 6 characters coding for two allelles. The missing values are coding by '000000'.
data(casitas)
data(casitas)
The 74 individuals of casitas
belong to 4 groups:
24 mice of the sub-species Mus musculus domesticus
11 mice of the sub-species Mus musculus castaneus
9 mice of the sub-species Mus musculus musculus
30 mice from a population of the lake Casitas (California)
Exemple du logiciel GENETIX.
Belkhir k. et al. GENETIX, logiciel sous WindowsTM pour la génétique des populations.
Laboratoire Génome, Populations, Interactions CNRS UMR 5000, Université de Montpellier II, Montpellier (France).
https://kimura.univ-montp2.fr/genetix/
Orth, A., T. Adama, W. Din and F. Bonhomme. (1998) Hybridation naturelle entre deux sous espèces de souris domestique Mus musculus domesticus et Mus musculus castaneus près de Lake Casitas (Californie). Genome, 41, 104–110.
data(casitas) str(casitas) names(casitas)
data(casitas) str(casitas) names(casitas)
This data set gives the age, the fecundity and the number of litters for 26 groups of cats.
data(chatcat)
data(chatcat)
chatcat
is a list of two objects :
is a data frame with 3 factors (age, feco, nport).
is a vector of numbers.
One row of tab
corresponds to one group of cats.
The value in eff
is the number of cats in this group.
Pontier, D. (1984) Contribution à la biologie et à la génétique des populations de chats domestiques (Felis catus). Thèse de 3ème cycle. Université Lyon 1, p. 67.
data(chatcat) summary(chatcat$tab) w <- acm.disjonctif(chatcat$tab) # Disjonctive table names(w) <- c(paste("A", 1:5, sep = ""), paste("B", 1:5, sep = ""), paste("C", 1:2, sep = "")) w <- t(w*chatcat$num) %*% as.matrix(w) w <- data.frame(w) w # BURT table
data(chatcat) summary(chatcat$tab) w <- acm.disjonctif(chatcat$tab) # Disjonctive table names(w) <- c(paste("A", 1:5, sep = ""), paste("B", 1:5, sep = ""), paste("C", 1:2, sep = "")) w <- t(w*chatcat$num) %*% as.matrix(w) w <- data.frame(w) w # BURT table
This data set is a contingency table of age classes and fecundity classes of cats Felis catus.
data(chats)
data(chats)
chats
is a data frame with 8 rows and 8 columns.
The 8 rows are age classes (age1, ..., age8).
The 8 columns are fecundity classes (f0, f12, f34, ..., fcd).
The values are cats numbers (contingency table).
Legay, J.M. and Pontier, D. (1985) Relation âge-fécondité dans les populations de Chats domestiques, Felis catus. Mammalia, 49, 395–402.
data(chats) chatsw <- as.table(t(chats)) chatscoa <- dudi.coa(data.frame(t(chats)), scann = FALSE) if(adegraphicsLoaded()) { g1 <- table.value(chatsw, ppoints.cex = 1.3, meanX = TRUE, ablineX = TRUE, plabel.cex = 1.5, plot = FALSE) g2 <- table.value(chatsw, ppoints.cex = 1.3, meanY = TRUE, ablineY = TRUE, plabel.cex = 1.5, plot = FALSE) g3 <- table.value(chatsw, ppoints.cex = 1.3, coordsx = chatscoa$c1[, 1], coordsy = chatscoa$l1[, 1], meanX = TRUE, ablineX = TRUE, plot = FALSE) g4 <- table.value(chatsw, ppoints.cex = 1.3, meanY = TRUE, ablineY = TRUE, coordsx = chatscoa$c1[, 1], coordsy = chatscoa$l1[, 1], plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2, 2)) table.cont(chatsw, abmean.x = TRUE, csi = 2, abline.x = TRUE, clabel.r = 1.5, clabel.c = 1.5) table.cont(chatsw, abmean.y = TRUE, csi = 2, abline.y = TRUE, clabel.r = 1.5, clabel.c = 1.5) table.cont(chatsw, x = chatscoa$c1[, 1], y = chatscoa$l1[, 1], abmean.x = TRUE, csi = 2, abline.x = TRUE, clabel.r = 1.5, clabel.c = 1.5) table.cont(chatsw, x = chatscoa$c1[, 1], y = chatscoa$l1[, 1], abmean.y = TRUE, csi = 2, abline.y = TRUE, clabel.r = 1.5, clabel.c = 1.5) par(mfrow = c(1, 1)) }
data(chats) chatsw <- as.table(t(chats)) chatscoa <- dudi.coa(data.frame(t(chats)), scann = FALSE) if(adegraphicsLoaded()) { g1 <- table.value(chatsw, ppoints.cex = 1.3, meanX = TRUE, ablineX = TRUE, plabel.cex = 1.5, plot = FALSE) g2 <- table.value(chatsw, ppoints.cex = 1.3, meanY = TRUE, ablineY = TRUE, plabel.cex = 1.5, plot = FALSE) g3 <- table.value(chatsw, ppoints.cex = 1.3, coordsx = chatscoa$c1[, 1], coordsy = chatscoa$l1[, 1], meanX = TRUE, ablineX = TRUE, plot = FALSE) g4 <- table.value(chatsw, ppoints.cex = 1.3, meanY = TRUE, ablineY = TRUE, coordsx = chatscoa$c1[, 1], coordsy = chatscoa$l1[, 1], plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2, 2)) table.cont(chatsw, abmean.x = TRUE, csi = 2, abline.x = TRUE, clabel.r = 1.5, clabel.c = 1.5) table.cont(chatsw, abmean.y = TRUE, csi = 2, abline.y = TRUE, clabel.r = 1.5, clabel.c = 1.5) table.cont(chatsw, x = chatscoa$c1[, 1], y = chatscoa$l1[, 1], abmean.x = TRUE, csi = 2, abline.x = TRUE, clabel.r = 1.5, clabel.c = 1.5) table.cont(chatsw, x = chatscoa$c1[, 1], y = chatscoa$l1[, 1], abmean.y = TRUE, csi = 2, abline.y = TRUE, clabel.r = 1.5, clabel.c = 1.5) par(mfrow = c(1, 1)) }
This data set gives six different weights of 23 charolais and zebu oxen.
data(chazeb)
data(chazeb)
chazeb
is a list of 2 components.
is a data frame with 23 rows and 6 columns.
is a factor with two levels "cha" and "zeb".
Tomassone, R., Danzard, M., Daudin, J. J. and Masson J. P. (1988) Discrimination et classement, Masson, Paris. p. 43
data(chazeb) if(!adegraphicsLoaded()) plot(discrimin(dudi.pca(chazeb$tab, scan = FALSE), chazeb$cla, scan = FALSE))
data(chazeb) if(!adegraphicsLoaded()) plot(discrimin(dudi.pca(chazeb$tab, scan = FALSE), chazeb$cla, scan = FALSE))
This data set contains a list of three components: spatial map, allellic profiles and sample sizes.
data(chevaine)
data(chevaine)
This data set is a list of three components:
a data frame with 27 populations and 9 allelic frequencies (4 locus)
a list containing all the elements to build a spatial map
a numeric containing the numbers of fish samples per station
Guinand B., Bouvet Y. and Brohon B. (1996) Spatial aspects of genetic differentiation of the European chub in the Rhone River basin. Journal of Fish Biology, 49, 714–726.
See a data description at http://pbil.univ-lyon1.fr/R/pdf/pps054.pdf (in French).
data(chevaine) names(chevaine) str(chevaine)
data(chevaine) names(chevaine) str(chevaine)
This data set contains information about potential risk factors for losses in broiler chickens
data(chickenk)
data(chickenk)
A list with 5 components:
a data frame with 351 observations and 4 variables which describe the losses (dependent dataset Y)
a data frame with 351 observations and 5 variables which describe the farm structure (explanatory dataset)
a data frame with 351 observations and 4 variables which describe the flock characteristics at placement (explanatory dataset)
a data frame with 351 observations and 6 variables which describe the flock characteristics during the rearing period (explanatory dataset)
a data frame with 351 observations and 5 variables which describe the transport, lairage conditions, slaughterhouse and inspection features (explanatory dataset)
Lupo C., le Bouquin S., Balaine L., Michel V., Peraste J., Petetin I., Colin P. and Chauvin C. (2009) Feasibility of screening broiler chicken flocks for risk markers as an aid for meat inspection. Epidemiology and Infection, 137, 1086-1098
data(chickenk) kta1 <- ktab.list.df(chickenk)
data(chickenk) kta1 <- ktab.list.df(chickenk)
The clementines
is a data set containing the fruit production of 20 clementine trees during 15 years.
data(clementines)
data(clementines)
A data frame with 15 rows and 20 columns
Tisné-Agostini, D. (1988) Description par analyse en composantes principales de l'évolution de la production du clémentinier en association avec 12 types de porte-greffe. Rapport technique, DEA Analyse et modélisation des systèmes biologiques, Université Lyon 1.
data(clementines) op <- par(no.readonly = TRUE) par(mfrow = c(5, 4)) par(mar = c(2, 2, 1, 1)) for(i in 1:20) { w0 <- 1:15 plot(w0, clementines[, i], type = "b") abline(lm(clementines[, i] ~ w0)) } par(op) pca1 <- dudi.pca(clementines, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.corcircle(pca1$co, plab.cex = 0.75) g2 <- s1d.barchart(pca1$li[, 1], p1d.hori = FALSE) } else { s.corcircle(pca1$co, clab = 0.75) barplot(pca1$li[, 1]) } op <- par(no.readonly = TRUE) par(mfrow = c(5, 4)) par(mar = c(2, 2, 1, 1)) clem0 <- pca1$tab croi <- 1:15 alter <- c(rep(c(1, -1), 7), 1) for(i in 1:20) { y <- clem0[,i] plot(w0, y, type = "b", ylim = c(-2, 2)) z <- predict(lm(clem0[, i] ~ croi * alter)) points(w0, z, pch = 20, cex = 2) for(j in 1:15) segments(j, y[j], j, z[j]) } par(op) par(mfrow = c(1, 1))
data(clementines) op <- par(no.readonly = TRUE) par(mfrow = c(5, 4)) par(mar = c(2, 2, 1, 1)) for(i in 1:20) { w0 <- 1:15 plot(w0, clementines[, i], type = "b") abline(lm(clementines[, i] ~ w0)) } par(op) pca1 <- dudi.pca(clementines, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.corcircle(pca1$co, plab.cex = 0.75) g2 <- s1d.barchart(pca1$li[, 1], p1d.hori = FALSE) } else { s.corcircle(pca1$co, clab = 0.75) barplot(pca1$li[, 1]) } op <- par(no.readonly = TRUE) par(mfrow = c(5, 4)) par(mar = c(2, 2, 1, 1)) clem0 <- pca1$tab croi <- 1:15 alter <- c(rep(c(1, -1), 7), 1) for(i in 1:20) { y <- clem0[,i] plot(w0, y, type = "b", ylim = c(-2, 2)) z <- predict(lm(clem0[, i] ~ croi * alter)) points(w0, z, pch = 20, cex = 2) for(j in 1:15) segments(j, y[j], j, z[j]) } par(op) par(mfrow = c(1, 1))
cnc2003
is a data frame with 94 rows (94 departments from continental Metropolitan France)and 12 variables.
data(cnc2003)
data(cnc2003)
This data frame contains the following variables:
is the population department in million inhabitants.
is the number of movie theater visitors in million.
is the takings from ticket offices.
is the number of proposed shows in thousands.
is the number of equipped communes in movie theaters (units).
is the number of active movie theaters (units).
is the number of active screens.
is the number of proposed seats.
is the number of movie theaters offering "Art and Essay" movies.
is the number of active multiplexes.
is the name of the department.
is the administrative region of the department.
National Center of Cinematography (CNC), september 2003
This dataset is compatible with elec88
and presid2002
data(cnc2003) sco.quant(cnc2003$popu, cnc2003[,2:10], abline = TRUE, csub = 3)
data(cnc2003) sco.quant(cnc2003$popu, cnc2003[,2:10], abline = TRUE, csub = 3)
The coinertia analysis performs a double inertia analysis of two tables.
coinertia(dudiX, dudiY, scannf = TRUE, nf = 2) ## S3 method for class 'coinertia' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'coinertia' print(x, ...) ## S3 method for class 'coinertia' summary(object, ...)
coinertia(dudiX, dudiY, scannf = TRUE, nf = 2) ## S3 method for class 'coinertia' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'coinertia' print(x, ...) ## S3 method for class 'coinertia' summary(object, ...)
dudiX |
a duality diagram providing from one of the functions dudi.coa, dudi.pca, ... |
dudiY |
a duality diagram providing from one of the functions dudi.coa, dudi.pca, ... |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
x , object
|
an object of class 'coinertia' |
xax , yax
|
the numbers of the x-axis and the y-axis |
... |
further arguments passed to or from other methods |
Returns a list of class 'coinertia', sub-class 'dudi' containing:
call |
call |
rank |
rank |
nf |
a numeric value indicating the number of kept axes |
RV |
a numeric value, the RV coefficient |
eig |
a numeric vector with all the eigenvalues |
lw |
a numeric vector with the rows weigths (crossed table) |
cw |
a numeric vector with the columns weigths (crossed table) |
tab |
a crossed table (CT) |
li |
CT row scores (cols of dudiY) |
l1 |
Principal components (loadings for cols of dudiY) |
co |
CT col scores (cols of dudiX) |
c1 |
Principal axes (cols of dudiX) |
lX |
Row scores (rows of dudiX) |
mX |
Normed row scores (rows of dudiX) |
lY |
Row scores (rows of dudiY) |
mY |
Normed row scores (rows of dudiY) |
aX |
Correlations between dudiX axes and coinertia axes |
aY |
Correlations between dudiY axes and coinertia axes |
IMPORTANT : dudi1
and dudi2
must have identical row weights.
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Dolédec, S. and Chessel, D. (1994) Co-inertia analysis: an alternative method for studying species-environment relationships.
Freshwater Biology, 31, 277–294.
Dray, S., Chessel, D. and J. Thioulouse (2003) Co-inertia analysis and the linking of the ecological data tables. Ecology, 84, 11, 3078–3089.
data(doubs) dudi1 <- dudi.pca(doubs$env, scale = TRUE, scan = FALSE, nf = 3) dudi2 <- dudi.pca(doubs$fish, scale = FALSE, scan = FALSE, nf = 2) coin1 <- coinertia(dudi1,dudi2, scan = FALSE, nf = 2) coin1 summary(coin1) if(adegraphicsLoaded()) { g1 <- s.arrow(coin1$l1, plab.cex = 0.7) g2 <- s.arrow(coin1$c1, plab.cex = 0.7) g3 <- s.corcircle(coin1$aX, plot = FALSE) g4 <- s.corcircle(coin1$aY, plot = FALSE) cbindADEg(g3, g4, plot = TRUE) g5 <- plot(coin1) } else { s.arrow(coin1$l1, clab = 0.7) s.arrow(coin1$c1, clab = 0.7) par(mfrow = c(1,2)) s.corcircle(coin1$aX) s.corcircle(coin1$aY) par(mfrow = c(1,1)) plot(coin1) }
data(doubs) dudi1 <- dudi.pca(doubs$env, scale = TRUE, scan = FALSE, nf = 3) dudi2 <- dudi.pca(doubs$fish, scale = FALSE, scan = FALSE, nf = 2) coin1 <- coinertia(dudi1,dudi2, scan = FALSE, nf = 2) coin1 summary(coin1) if(adegraphicsLoaded()) { g1 <- s.arrow(coin1$l1, plab.cex = 0.7) g2 <- s.arrow(coin1$c1, plab.cex = 0.7) g3 <- s.corcircle(coin1$aX, plot = FALSE) g4 <- s.corcircle(coin1$aY, plot = FALSE) cbindADEg(g3, g4, plot = TRUE) g5 <- plot(coin1) } else { s.arrow(coin1$l1, clab = 0.7) s.arrow(coin1$c1, clab = 0.7) par(mfrow = c(1,2)) s.corcircle(coin1$aX) s.corcircle(coin1$aY) par(mfrow = c(1,1)) plot(coin1) }
This data set coleo (coleoptera) is a a fuzzy biological traits table.
data(coleo)
data(coleo)
coleo
is a list of 5 components.
is a data frame with 110 rows (species) and 32 columns (categories).
is a vector of species names.
is a vector of fuzzy variables names.
is a factor species family.
is a vector containing the number of categories of each trait.
Bournaud, M., Richoux, P. and Usseglio-Polatera, P. (1992) An approach to the synthesis of qualitative ecological information from aquatic coleoptera communities. Regulated rivers: Research and Management, 7, 165–180.
data(coleo) op <- par(no.readonly = TRUE) coleo.fuzzy <- prep.fuzzy.var(coleo$tab, coleo$col.blocks) fca1 <- dudi.fca(coleo.fuzzy, sca = FALSE, nf = 3) indica <- factor(rep(names(coleo$col), coleo$col)) if(adegraphicsLoaded()) { glist <- list() for(i in levels(indica)) { df <- coleo$tab[, which(indica == i)] names(df) <- coleo$moda.names[which(indica == i)] glist[i] <- s.distri(fca1$l1, df, psub.text = as.character(i), ellipseSize = 0, starSize = 0.5, plot = FALSE, storeData = TRUE) } G <- ADEgS(glist, layout = c(3, 3)) } else { par(mfrow = c(3, 3)) for(j in levels(indica)) s.distri(fca1$l1, coleo$tab[, which(indica == j)], clab = 1.5, sub = as.character(j), cell = 0, csta = 0.5, csub = 3, label = coleo$moda.names[which(indica == j)]) par(op) par(mfrow = c(1, 1)) }
data(coleo) op <- par(no.readonly = TRUE) coleo.fuzzy <- prep.fuzzy.var(coleo$tab, coleo$col.blocks) fca1 <- dudi.fca(coleo.fuzzy, sca = FALSE, nf = 3) indica <- factor(rep(names(coleo$col), coleo$col)) if(adegraphicsLoaded()) { glist <- list() for(i in levels(indica)) { df <- coleo$tab[, which(indica == i)] names(df) <- coleo$moda.names[which(indica == i)] glist[i] <- s.distri(fca1$l1, df, psub.text = as.character(i), ellipseSize = 0, starSize = 0.5, plot = FALSE, storeData = TRUE) } G <- ADEgS(glist, layout = c(3, 3)) } else { par(mfrow = c(3, 3)) for(j in levels(indica)) s.distri(fca1$l1, coleo$tab[, which(indica == j)], clab = 1.5, sub = as.character(j), cell = 0, csta = 0.5, csub = 3, label = coleo$moda.names[which(indica == j)]) par(op) par(mfrow = c(1, 1)) }
Functions to combine and adjust the outputs of the fourthcorner
and
randtest.rlq
functions created using permutational models 2 and
4 (sequential approach).
combine.randtest.rlq(obj1, obj2, ...) combine.4thcorner(four1,four2) p.adjust.4thcorner(x, p.adjust.method.G = p.adjust.methods, p.adjust.method.D = p.adjust.methods, p.adjust.D = c("global", "levels"))
combine.randtest.rlq(obj1, obj2, ...) combine.4thcorner(four1,four2) p.adjust.4thcorner(x, p.adjust.method.G = p.adjust.methods, p.adjust.method.D = p.adjust.methods, p.adjust.D = c("global", "levels"))
four1 |
an object of the class 4thcorner created with modeltype = 2 (or 4) |
four2 |
an object of the class 4thcorner created with modeltype = 4 (or 2) |
obj1 |
an object created with |
obj2 |
an object created with |
x |
an object of the class 4thcorner |
p.adjust.method.G |
a string indicating a method for multiple
adjustment used for output tabG, see |
p.adjust.method.D |
a string indicating a method for multiple
adjustment used for output tabD/tabD2, see |
p.adjust.D |
a string indicating if multiple adjustment for tabD/tabD2 should be done globally or only between levels of a factor ("levels", as in the original paper of Legendre et al. 1997) |
... |
further arguments passed to or from other methods |
The functions combines the outputs of two objects (created by
fourthcorner
and randtest.rlq
functions) as described in
Dray and Legendre (2008) and ter Braak et al (2012).
The functions return objects of the same class than their argument. They simply create a new object where pvalues are equal to the maximum of pvalues of the two arguments.
Stéphane Dray [email protected]
Dray, S. and Legendre, P. (2008) Testing the species traits-environment relationships: the fourth-corner problem revisited. Ecology, 89, 3400–3412.
ter Braak, C., Cormont, A., and Dray, S. (2012) Improved testing of species traits-environment relationships in the fourth corner problem. Ecology, 93, 1525–1526.
rlq
, fourthcorner
, p.adjust.methods
data(aravo) four2 <- fourthcorner(aravo$env, aravo$spe, aravo$traits, nrepet=99,modeltype=2) four4 <- fourthcorner(aravo$env, aravo$spe, aravo$traits, nrepet=99,modeltype=4) four.comb <- combine.4thcorner(four2,four4) ## or directly : ## four.comb <- fourthcorner(aravo$env, aravo$spe, aravo$traits, nrepet=99,modeltype=6) summary(four.comb) plot(four.comb, stat = "G")
data(aravo) four2 <- fourthcorner(aravo$env, aravo$spe, aravo$traits, nrepet=99,modeltype=2) four4 <- fourthcorner(aravo$env, aravo$spe, aravo$traits, nrepet=99,modeltype=4) four.comb <- combine.4thcorner(four2,four4) ## or directly : ## four.comb <- fourthcorner(aravo$env, aravo$spe, aravo$traits, nrepet=99,modeltype=6) summary(four.comb) plot(four.comb, stat = "G")
The mantelkdist and RVkdist functions apply to blocks of distance matrices the mantel.rtest and RV.rtest functions.
mantelkdist (kd, nrepet = 999, ...) RVkdist (kd, nrepet = 999, ...) ## S3 method for class 'corkdist' plot(x, whichinrow = NULL, whichincol = NULL, gap = 4, nclass = 10,...)
mantelkdist (kd, nrepet = 999, ...) RVkdist (kd, nrepet = 999, ...) ## S3 method for class 'corkdist' plot(x, whichinrow = NULL, whichincol = NULL, gap = 4, nclass = 10,...)
kd |
a list of class |
nrepet |
the number of permutations |
x |
an objet of class |
whichinrow |
a vector of integers to select the graphs in rows (if NULL all the graphs are computed) |
whichincol |
a vector of integers to select the graphs in columns (if NULL all the graphs are computed) |
gap |
an integer to determinate the space between two graphs |
nclass |
a number of intervals for the histogram |
... |
further arguments passed to or from other methods |
The corkdist
class has some generic functions print
, plot
and summary
. The plot shows bivariate scatterplots between semi-matrices of distances or histograms of simulated values with an error position.
a list of class corkdist
containing for each pair of distances an object of class randtest
(permutation tests).
Daniel Chessel
Stéphane Dray [email protected]
data(friday87) fri.w <- ktab.data.frame(friday87$fau, friday87$fau.blo, tabnames = friday87$tab.names) fri.kc <- lapply(1:10, function(x) dist.binary(fri.w[[x]], 10)) names(fri.kc) <- substr(friday87$tab.names, 1, 4) fri.kd <- kdist(fri.kc) fri.mantel <- mantelkdist(kd = fri.kd, nrepet = 999) plot(fri.mantel, 1:5, 1:5) plot(fri.mantel, 1:5, 6:10) plot(fri.mantel, 6:10, 1:5) plot(fri.mantel, 6:10, 6:10) s.corcircle(dudi.pca(as.data.frame(fri.kd), scan = FALSE)$co) plot(RVkdist(fri.kd), 1:5, 1:5) data(yanomama) m1 <- mantelkdist(kdist(yanomama), 999) m1 summary(m1) plot(m1)
data(friday87) fri.w <- ktab.data.frame(friday87$fau, friday87$fau.blo, tabnames = friday87$tab.names) fri.kc <- lapply(1:10, function(x) dist.binary(fri.w[[x]], 10)) names(fri.kc) <- substr(friday87$tab.names, 1, 4) fri.kd <- kdist(fri.kc) fri.mantel <- mantelkdist(kd = fri.kd, nrepet = 999) plot(fri.mantel, 1:5, 1:5) plot(fri.mantel, 1:5, 6:10) plot(fri.mantel, 6:10, 1:5) plot(fri.mantel, 6:10, 6:10) s.corcircle(dudi.pca(as.data.frame(fri.kd), scan = FALSE)$co) plot(RVkdist(fri.kd), 1:5, 1:5) data(yanomama) m1 <- mantelkdist(kdist(yanomama), 999) m1 summary(m1) plot(m1)
This data set gives a morphological description of 28 species of the genus Corvus split in two habitat types and phylogeographic stocks.
data(corvus)
data(corvus)
corvus
is data frame with 28 observations (the species) and 4 variables :
: wing length (mm)
: bill length (mm)
: habitat with two levels clos
and open
: phylogeographic stock with three levels amer
(America), orien
(Oriental-Australian),
pale
(Paleoarctic-African)
Laiolo, P. and Rolando, A. (2003) The evolution of vocalisations in the genus Corvus: effects of phylogeny, morphology and habitat. Evolutionary Ecology, 17, 111–123.
data(corvus) if(adegraphicsLoaded()) { g1 <- s.label(corvus[, 1:2], plab.cex = 0, porigin.include = FALSE, pgrid.draw = FALSE, paxes.draw = TRUE, paxes.asp = "full", xlab = names(corvus)[2], ylab = names(corvus)[2], plot = FALSE) g2 <- s.class(corvus[, 1:2], corvus[, 4]:corvus[, 3], plot = FALSE) G <- superpose(g1, g2, plot = TRUE) } else { plot(corvus[, 1:2]) s.class(corvus[, 1:2], corvus[, 4]:corvus[, 3], add.p = TRUE) }
data(corvus) if(adegraphicsLoaded()) { g1 <- s.label(corvus[, 1:2], plab.cex = 0, porigin.include = FALSE, pgrid.draw = FALSE, paxes.draw = TRUE, paxes.asp = "full", xlab = names(corvus)[2], ylab = names(corvus)[2], plot = FALSE) g2 <- s.class(corvus[, 1:2], corvus[, 4]:corvus[, 3], plot = FALSE) G <- superpose(g1, g2, plot = TRUE) } else { plot(corvus[, 1:2]) s.class(corvus[, 1:2], corvus[, 4]:corvus[, 3], add.p = TRUE) }
Analysis of a series of pairs of ecological tables. This function uses Partial Triadic Analysis (pta) and coinertia to do the computations.
costatis(KTX, KTY, scannf = TRUE)
costatis(KTX, KTY, scannf = TRUE)
KTX |
an objet of class ktab |
KTY |
an objet of class ktab |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
This function takes 2 ktabs. It does a PTA (partial triadic analysis: pta) on each ktab, and does a coinertia analysis (coinertia) on the compromises of the two PTAs.
a list of class coinertia, subclass dudi. See coinertia
IMPORTANT : KTX and KTY must have the same k-tables structure, the same number of columns, and the same column weights.
Jean Thioulouse [email protected]
Thioulouse J. (2011). Simultaneous analysis of a sequence of paired ecological tables: a comparison of several methods. Annals of Applied Statistics, 5, 2300-2325.
data(meau) wit1 <- withinpca(meau$env, meau$design$season, scan = FALSE, scal = "total") pcaspe <- dudi.pca(meau$spe, scale = FALSE, scan = FALSE, nf = 2) wit2 <- wca(pcaspe, meau$design$season, scan = FALSE, nf = 2) kta1 <- ktab.within(wit1, colnames = rep(c("S1","S2","S3","S4","S5","S6"), 4)) kta2 <- ktab.within(wit2, colnames = rep(c("S1","S2","S3","S4","S5","S6"), 4)) costatis1 <- costatis(kta1, kta2, scan = FALSE) plot(costatis1)
data(meau) wit1 <- withinpca(meau$env, meau$design$season, scan = FALSE, scal = "total") pcaspe <- dudi.pca(meau$spe, scale = FALSE, scan = FALSE, nf = 2) wit2 <- wca(pcaspe, meau$design$season, scan = FALSE, nf = 2) kta1 <- ktab.within(wit1, colnames = rep(c("S1","S2","S3","S4","S5","S6"), 4)) kta2 <- ktab.within(wit2, colnames = rep(c("S1","S2","S3","S4","S5","S6"), 4)) costatis1 <- costatis(kta1, kta2, scan = FALSE) plot(costatis1)
Performs a Monte-Carlo test on a Costatis analysis.
costatis.randtest(KTX, KTY, nrepet = 999, ...)
costatis.randtest(KTX, KTY, nrepet = 999, ...)
KTX |
an objet of class ktab |
KTY |
an objet of class ktab |
nrepet |
the number of permutations |
... |
further arguments passed to or from other methods |
a list of the class randtest
Jean Thioulouse [email protected]
Thioulouse J. (2011). Simultaneous analysis of a sequence of paired ecological tables: a comparison of several methods. Annals of Applied Statistics, 5, 2300-2325.
data(meau) wit1 <- withinpca(meau$env, meau$design$season, scan = FALSE, scal = "total") pcaspe <- dudi.pca(meau$spe, scale = FALSE, scan = FALSE, nf = 2) wit2 <- wca(pcaspe, meau$design$season, scan = FALSE, nf = 2) kta1 <- ktab.within(wit1, colnames = rep(c("S1","S2","S3","S4","S5","S6"), 4)) kta2 <- ktab.within(wit2, colnames = rep(c("S1","S2","S3","S4","S5","S6"), 4)) costatis1 <- costatis(kta1, kta2, scan = FALSE) costatis.randtest(kta1, kta2)
data(meau) wit1 <- withinpca(meau$env, meau$design$season, scan = FALSE, scal = "total") pcaspe <- dudi.pca(meau$spe, scale = FALSE, scan = FALSE, nf = 2) wit2 <- wca(pcaspe, meau$design$season, scan = FALSE, nf = 2) kta1 <- ktab.within(wit1, colnames = rep(c("S1","S2","S3","S4","S5","S6"), 4)) kta2 <- ktab.within(wit2, colnames = rep(c("S1","S2","S3","S4","S5","S6"), 4)) costatis1 <- costatis(kta1, kta2, scan = FALSE) costatis.randtest(kta1, kta2)
Compute Dagnelie test of multivariate normality on a data table of n objects (rows) and p variables (columns), with n > (p+1).
dagnelie.test(x)
dagnelie.test(x)
x |
Multivariate data table ( |
Dagnelie's goodness-of-fit test of multivariate normality is applicable to
multivariate data. Mahalanobis generalized distances are computed between each object and the multivariate centroid of all objects. Dagnelie’s approach is that, for multinormal data, the generalized distances should be normally distributed. The function computes a Shapiro-Wilk test of normality of the Mahalanobis distances; this is our improvement of Dagnelie’s method.
The null hypothesis (H0) is that the data are multinormal, a situation where the Mahalanobis distances should be normally distributed. In that case, the test should not reject H0, subject to type I error at the selected significance level.
Numerical simulations by D. Borcard have shown that the test had correct levels of type I error for values of n between 3p and 8p, where n is the number of objects and p is the number of variables in the data
matrix (simulations with 1 <= p <= 100). Outside that range of n values, the results were too liberal, meaning that the test rejected too often the null hypothesis of normality. For p = 2, the simulations showed the test to be valid for 6 <= n <= 13 and too liberal outside that range. If H0 is not rejected in a situation where the test is too liberal, the result is trustworthy.
Calculation of the Mahalanobis distances requires that n > p+1 (actually, n > rank+1). With fewer objects (n), all points are at equal Mahalanobis distances from the centroid in the resulting space, which has min(rank,(n-1))
dimensions. For data matrices that happen to be collinear, the function uses ginv
for inversion.
This test is not meant to be used with univariate data; in simulations, the type I error rate was higher than the 5% significance level for all values of n. Function shapiro.test
should be used in that situation.
A list containing the following results:
Shapiro.Wilk |
W statistic and p-value |
dim |
dimensions of the data matrix, n and p |
rank |
the rank of the covariance matrix |
D |
Vector containing the Mahalanobis distances of the objects to the multivariate centroid |
Daniel Borcard and Pierre Legendre
Dagnelie, P. 1975. L'analyse statistique a plusieurs variables.
Les Presses agronomiques de Gembloux, Gembloux, Belgium.
Legendre, P. and L. Legendre. 2012. Numerical ecology, 3rd English
edition. Elsevier Science BV, Amsterdam, The Netherlands.
# Example 1: 2 variables, n = 100 n <- 100; p <- 2 mat <- matrix(rnorm(n*p), n, p) (out <- dagnelie.test(mat)) # Example 2: 10 variables, n = 50 n <- 50; p <- 10 mat <- matrix(rnorm(n*p), n, p) (out <- dagnelie.test(mat)) # Example 3: 10 variables, n = 100 n <- 100; p <- 10 mat <- matrix(rnorm(n*p), n, p) (out <- dagnelie.test(mat)) # Plot a histogram of the Mahalanobis distances hist(out$D) # Example 4: 10 lognormal random variables, n = 50 n <- 50; p <- 10 mat <- matrix(round(exp(rnorm((n*p), mean = 0, sd = 2.5))), n, p) (out <- dagnelie.test(mat)) # Plot a histogram of the Mahalanobis distances hist(out$D)
# Example 1: 2 variables, n = 100 n <- 100; p <- 2 mat <- matrix(rnorm(n*p), n, p) (out <- dagnelie.test(mat)) # Example 2: 10 variables, n = 50 n <- 50; p <- 10 mat <- matrix(rnorm(n*p), n, p) (out <- dagnelie.test(mat)) # Example 3: 10 variables, n = 100 n <- 100; p <- 10 mat <- matrix(rnorm(n*p), n, p) (out <- dagnelie.test(mat)) # Plot a histogram of the Mahalanobis distances hist(out$D) # Example 4: 10 lognormal random variables, n = 50 n <- 50; p <- 10 mat <- matrix(round(exp(rnorm((n*p), mean = 0, sd = 2.5))), n, p) (out <- dagnelie.test(mat)) # Plot a histogram of the Mahalanobis distances hist(out$D)
The functions/data/methods listed below are deprecated.
The R code of the deprecated functions are stored for memory in the file ade4-deprecated.R
.
- between
: replaced by bca
- betweencoinertia
: replaced by bca.coinertia
- char2genet
: replaced by df2genind
and genind2genpop
in the adegenet
package
- count2genet
: replaced by df2genind
and genind2genpop
in the adegenet
package
- dist.genet
: replaced by dist.genpop
in the adegenet
package
- EH
: replaced by EH
in the adiv
package
- freq2genet
: replaced by df2genind
and genind2genpop
in the adegenet
package
- fuzzygenet
: replaced by df2genind
in the adegenet
package
- multispati
: replaced by multispati
in the adespatial
package
- multispati.rtest
- multispati.randtest
- optimEH
: replaced by optimEH
in the adiv
package
- orisaved
: replaced by orisaved
in the adiv
package
- orthogram
: replaced by orthogram
in the adephylo
package
- plot.multispati
: replaced by plot.multispati
in the adespatial
package
- print.multispati
: replaced by print.multispati
in the adespatial
package
- randEH
: replaced by randEH
in the adiv
package
- summary.multispati
: replaced by summary.multispati
in the adespatial
package
- within
: replaced by wca
- withincoinertia
: replaced by wca.coinertia
This data set gives the exam results of 104 students in the second year of a French University onto 9 subjects.
data(deug)
data(deug)
deug
is a list of three components.
is a data frame with 104 students and 9 subjects : Algebra, Analysis, Proba, Informatic, Economy, Option1, Option2, English, Sport.
is a factor of 104 components giving the final exam levels (A+, A, B, B-, C-, D).
is a vector of required marks by subject to get exactly 10/20 with a coefficient.
University of Lyon 1
data(deug) # decentred PCA pca1 <- dudi.pca(deug$tab, scal = FALSE, center = deug$cent, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.class(pca1$li, deug$result, plot = FALSE) g2 <- s.arrow(40 * pca1$c1, plot = FALSE) G <- superpose(g1, g2, plot = TRUE) } else { s.class(pca1$li, deug$result) s.arrow(40 * pca1$c1, add.plot = TRUE) }
data(deug) # decentred PCA pca1 <- dudi.pca(deug$tab, scal = FALSE, center = deug$cent, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.class(pca1$li, deug$result, plot = FALSE) g2 <- s.arrow(40 * pca1$c1, plot = FALSE) G <- superpose(g1, g2, plot = TRUE) } else { s.class(pca1$li, deug$result) s.arrow(40 * pca1$c1, add.plot = TRUE) }
Calculates the root square of Rao's dissimilarity coefficient between samples.
disc(samples, dis = NULL, structures = NULL)
disc(samples, dis = NULL, structures = NULL)
samples |
a data frame with elements as rows, samples as columns, and abundance, presence-absence or frequencies as entries |
dis |
an object of class |
structures |
a data frame containing, in the jth row and the kth column, the name of the group of level k to which the jth population belongs. |
Returns a list of objects of class dist
Sandrine Pavoine [email protected]
Rao, C.R. (1982) Diversity and dissimilarity coefficients: a unified approach. Theoretical Population Biology, 21, 24–43.
data(humDNAm) humDNA.dist <- disc(humDNAm$samples, sqrt(humDNAm$distances), humDNAm$structures) humDNA.dist is.euclid(humDNA.dist$samples) is.euclid(humDNA.dist$regions) ## Not run: data(ecomor) dtaxo <- dist.taxo(ecomor$taxo) ecomor.dist <- disc(ecomor$habitat, dtaxo) ecomor.dist is.euclid(ecomor.dist) ## End(Not run)
data(humDNAm) humDNA.dist <- disc(humDNAm$samples, sqrt(humDNAm$distances), humDNAm$structures) humDNA.dist is.euclid(humDNA.dist$samples) is.euclid(humDNA.dist$regions) ## Not run: data(ecomor) dtaxo <- dist.taxo(ecomor$taxo) ecomor.dist <- disc(ecomor$habitat, dtaxo) ecomor.dist is.euclid(ecomor.dist) ## End(Not run)
performs a linear discriminant analysis.
discrimin(dudi, fac, scannf = TRUE, nf = 2) ## S3 method for class 'discrimin' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'discrimin' print(x, ...)
discrimin(dudi, fac, scannf = TRUE, nf = 2) ## S3 method for class 'discrimin' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'discrimin' print(x, ...)
dudi |
a duality diagram, object of class |
fac |
a factor defining the classes of discriminant analysis |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
x |
an object of class 'discrimin' |
xax |
the column number of the x-axis |
yax |
the column number of the y-axis |
... |
further arguments passed to or from other methods |
returns a list of class 'discrimin' containing :
nf |
a numeric value indicating the number of kept axes |
eig |
a numeric vector with all the eigenvalues |
fa |
a matrix with the loadings: the canonical weights |
li |
a data frame which gives the canonical scores |
va |
a matrix which gives the cosines between the variables and the canonical scores |
cp |
a matrix which gives the cosines between the components and the canonical scores |
gc |
a data frame which gives the class scores |
Daniel Chessel
Anne-Béatrice Dufour [email protected]
lda
in package MASS
data(chazeb) dis1 <- discrimin(dudi.pca(chazeb$tab, scan = FALSE), chazeb$cla, scan = FALSE) dis1 if(!adegraphicsLoaded()) plot(dis1) data(skulls) plot(discrimin(dudi.pca(skulls, scan = FALSE), gl(5,30), scan = FALSE))
data(chazeb) dis1 <- discrimin(dudi.pca(chazeb$tab, scan = FALSE), chazeb$cla, scan = FALSE) dis1 if(!adegraphicsLoaded()) plot(dis1) data(skulls) plot(discrimin(dudi.pca(skulls, scan = FALSE), gl(5,30), scan = FALSE))
performs a discriminant correspondence analysis.
discrimin.coa(df, fac, scannf = TRUE, nf = 2)
discrimin.coa(df, fac, scannf = TRUE, nf = 2)
df |
a data frame containing positive or null values |
fac |
a factor defining the classes of discriminant analysis |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
a list of class discrimin
. See discrimin
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Perriere, G.,Lobry, J. R. and Thioulouse J. (1996) Correspondence discriminant analysis: a multivariate method for comparing
classes of protein and nucleic acid sequences. CABIOS, 12, 519–524.
Perriere, G. and Thioulouse, J. (2003) Use of Correspondence Discriminant Analysis to predict the subcellular location of bacterial proteins. Computer Methods and Programs in Biomedicine, 70, 2, 99–105.
data(perthi02) plot(discrimin.coa(perthi02$tab, perthi02$cla, scan = FALSE))
data(perthi02) plot(discrimin.coa(perthi02$tab, perthi02$cla, scan = FALSE))
computes for binary data some distance matrice.
dist.binary(df, method = NULL, diag = FALSE, upper = FALSE)
dist.binary(df, method = NULL, diag = FALSE, upper = FALSE)
df |
a matrix or a data frame with positive or null numeric values. Used with |
method |
an integer between 1 and 10 . If NULL the choice is made with a console message. See details |
diag |
a logical value indicating whether the diagonal of the distance matrix should be printed by ‘print.dist’ |
upper |
a logical value indicating whether the upper triangle of the distance matrix should be printed by ‘print.dist’ |
Let be the contingency table of binary data such as ,
,
and
. All these distances are of type
with s a similarity coefficient.
S3 coefficient of Gower & Legendre
S4 coefficient of Gower & Legendre
S5 coefficient of Gower & Legendre
S6 coefficient of Gower & Legendre
S7 coefficient of Gower & Legendre
S9 index of Gower & Legendre (1986)
S12 coefficient of Gower & Legendre
S13 coefficient of Gower & Legendre
S14 coefficient of Gower & Legendre
returns a distance matrix of class dist
between the rows of the data frame
Daniel Chessel
Stéphane Dray [email protected]
Gower, J.C. and Legendre, P. (1986) Metric and Euclidean properties of dissimilarity coefficients. Journal of Classification, 3, 5–48.
data(aviurba) for (i in 1:10) { d <- dist.binary(aviurba$fau, method = i) cat(attr(d, "method"), is.euclid(d), "\n")}
data(aviurba) for (i in 1:10) { d <- dist.binary(aviurba$fau, method = i) cat(attr(d, "method"), is.euclid(d), "\n")}
computes for a statistical triplet a distance matrix.
dist.dudi(dudi, amongrow = TRUE)
dist.dudi(dudi, amongrow = TRUE)
dudi |
a duality diagram, object of class |
amongrow |
a logical value computing the distance if TRUE, between rows, if FALSE between columns. |
an object of class dist
Daniel Chessel
Stéphane Dray [email protected]
data (meaudret) pca1 <- dudi.pca(meaudret$env, scan = FALSE) sum((dist(scalewt(meaudret$env)) - dist.dudi(pca1))^2) #[1] 4.045e-29 the same thing
data (meaudret) pca1 <- dudi.pca(meaudret$env, scan = FALSE) sum((dist(scalewt(meaudret$env)) - dist.dudi(pca1))^2) #[1] 4.045e-29 the same thing
The mixed-variables coefficient of distance generalizes Gower's general coefficient of distance to allow the treatment of various statistical types of variables when calculating distances. This is especially important when measuring functional diversity. Indeed, most of the indices that measure functional diversity depend on variables (traits) that have various statistical types (e.g. circular, fuzzy, ordinal) and that go through a matrix of distances among species.
dist.ktab(x, type, option = c("scaledBYrange", "scaledBYsd", "noscale"), scann = FALSE, tol = 1e-8) ldist.ktab(x, type, option = c("scaledBYrange", "scaledBYsd", "noscale"), scann = FALSE, tol = 1e-8) kdist.cor(x, type, option = c("scaledBYrange", "scaledBYsd", "noscale"), scann = FALSE, tol = 1e-8, squared = TRUE) prep.fuzzy(df, col.blocks, row.w = rep(1, nrow(df)), labels = paste("F", 1:length(col.blocks), sep = "")) prep.binary(df, col.blocks, labels = paste("B", 1:length(col.blocks), sep = "")) prep.circular(df, rangemin = apply(df, 2, min, na.rm = TRUE), rangemax = apply(df, 2, max, na.rm = TRUE))
dist.ktab(x, type, option = c("scaledBYrange", "scaledBYsd", "noscale"), scann = FALSE, tol = 1e-8) ldist.ktab(x, type, option = c("scaledBYrange", "scaledBYsd", "noscale"), scann = FALSE, tol = 1e-8) kdist.cor(x, type, option = c("scaledBYrange", "scaledBYsd", "noscale"), scann = FALSE, tol = 1e-8, squared = TRUE) prep.fuzzy(df, col.blocks, row.w = rep(1, nrow(df)), labels = paste("F", 1:length(col.blocks), sep = "")) prep.binary(df, col.blocks, labels = paste("B", 1:length(col.blocks), sep = "")) prep.circular(df, rangemin = apply(df, 2, min, na.rm = TRUE), rangemax = apply(df, 2, max, na.rm = TRUE))
x |
Object of class |
type |
Vector that provide the type of each table in x. The possible types are "Q" (quantitative), "O" (ordinal), "N" (nominal), "D" (dichotomous), "F" (fuzzy, or expressed as a proportion), "B" (multichoice nominal variables, coded by binary columns), "C" (circular). Values in type must be in the same order as in x. |
option |
A string that can have three values: either "scaledBYrange" if the quantitative variables must be scaled by their range, or "scaledBYsd" if they must be scaled by their standard deviation, or "noscale" if they should not be scaled. This last option can be useful if the the values have already been normalized by the known range of the whole population instead of the observed range measured on the sample. If x contains data from various types, then the option "scaledBYsd" is not suitable (a warning will appear if the option selected with that condition). |
scann |
A logical. If TRUE, then the user will have to choose among several possible functions of distances for the quantitative, ordinal, fuzzy and binary variables. |
tol |
A tolerance threshold: a value less than tol is considered as null. |
squared |
A logical, if TRUE, the squared distances are considered. |
df |
Objet of class data.frame |
col.blocks |
A vector that contains the number of levels per variable (in the same order
as in |
row.w |
A vector of row weigths |
labels |
the names of the traits |
rangemin |
A numeric corresponding to the smallest level where the loop starts |
rangemax |
A numeric corresponding to the highest level where the loop closes |
When preparing the object of class ktab
(object x), variables of type "Q", "O", "D", "F", "B" and "C" should be of class numeric
(the class ordered
is not yet considered by dist.ktab
); variables of type "N" should be of class character
or factor
The functions provide the following results:
dist.ktab |
returns an object of class |
ldist.ktab |
returns a list of objects of class |
kdist.cor |
returns a list of three objects: "paircov" provides the covariance between traits in terms of (squared) distances between species; "paircor" provides the correlations between traits in terms of (squared) distances between species; "glocor" provides the correlations between the (squared) distances obtained for each trait and the global (squared) distances obtained by mixing all the traits (= contributions of traits to the global distances); |
prep.binary and prep.fuzzy |
returns a data frame with the following attributes: col.blocks specifies the number of columns per fuzzy variable; col.num specifies which variable each column belongs to; |
prep.circular |
returns a data frame with the following attributes: max specifies the number of levels in each circular variable. |
Sandrine Pavoine [email protected]
Pavoine S., Vallet, J., Dufour, A.-B., Gachet, S. and Daniel, H. (2009) On the challenge of treating various types of variables: Application for improving the measurement of functional diversity. Oikos, 118, 391–402. doi:10.1111/j.1600-0706.2008.16668.x
Appendix available at: http://www.oikosjournal.org/sites/oikosjournal.org/files/appendix/o16668.pdf http://www.oikosjournal.org/sites/oikosjournal.org/files/appendix/o16668_files.zip
daisy
in the case of ratio-scale (quantitative) and nominal variables;
and woangers
for an application.
# With fuzzy variables data(bsetal97) w <- prep.fuzzy(bsetal97$biol, bsetal97$biol.blo) w[1:6, 1:10] ktab1 <- ktab.list.df(list(w)) dis <- dist.ktab(ktab1, type = "F") as.matrix(dis)[1:5, 1:5] ## Not run: # With ratio-scale and multichoice variables data(ecomor) wM <- log(ecomor$morpho + 1) # Quantitative variables wD <- ecomor$diet # wD is a data frame containing a multichoice nominal variable # (diet habit), with 8 modalities (Granivorous, etc) # We must prepare it by prep.binary head(wD) wD <- prep.binary(wD, col.blocks = 8, label = "diet") wF <- ecomor$forsub # wF is also a data frame containing a multichoice nominal variable # (foraging substrat), with 6 modalities (Foliage, etc) # We must prepare it by prep.binary head(wF) wF <- prep.binary(wF, col.blocks = 6, label = "foraging") # Another possibility is to combine the two last data frames wD and wF as # they contain the same type of variables wB <- cbind.data.frame(ecomor$diet, ecomor$forsub) head(wB) wB <- prep.binary(wB, col.blocks = c(8, 6), label = c("diet", "foraging")) # The results given by the two alternatives are identical ktab2 <- ktab.list.df(list(wM, wD, wF)) disecomor <- dist.ktab(ktab2, type= c("Q", "B", "B")) as.matrix(disecomor)[1:5, 1:5] contrib2 <- kdist.cor(ktab2, type= c("Q", "B", "B")) contrib2 ktab3 <- ktab.list.df(list(wM, wB)) disecomor2 <- dist.ktab(ktab3, type= c("Q", "B")) as.matrix(disecomor2)[1:5, 1:5] contrib3 <- kdist.cor(ktab3, type= c("Q", "B")) contrib3 # With a range of variables data(woangers) traits <- woangers$traits # Nominal variables 'li', 'pr', 'lp' and 'le' # (see table 1 in the main text for the codes of the variables) tabN <- traits[,c(1:2, 7, 8)] # Circular variable 'fo' tabC <- traits[3] tabCp <- prep.circular(tabC, 1, 12) # The levels of the variable lie between 1 (January) and 12 (December). # Ordinal variables 'he', 'ae' and 'un' tabO <- traits[, 4:6] # Fuzzy variables 'mp', 'pe' and 'di' tabF <- traits[, 9:19] tabFp <- prep.fuzzy(tabF, c(3, 3, 5), labels = c("mp", "pe", "di")) # 'mp' has 3 levels, 'pe' has 3 levels and 'di' has 5 levels. # Quantitative variables 'lo' and 'lf' tabQ <- traits[, 20:21] ktab1 <- ktab.list.df(list(tabN, tabCp, tabO, tabFp, tabQ)) distrait <- dist.ktab(ktab1, c("N", "C", "O", "F", "Q")) is.euclid(distrait) contrib <- kdist.cor(ktab1, type = c("N", "C", "O", "F", "Q")) contrib dotchart(sort(contrib$glocor), labels = rownames(contrib$glocor)[order(contrib$glocor[, 1])]) ## End(Not run)
# With fuzzy variables data(bsetal97) w <- prep.fuzzy(bsetal97$biol, bsetal97$biol.blo) w[1:6, 1:10] ktab1 <- ktab.list.df(list(w)) dis <- dist.ktab(ktab1, type = "F") as.matrix(dis)[1:5, 1:5] ## Not run: # With ratio-scale and multichoice variables data(ecomor) wM <- log(ecomor$morpho + 1) # Quantitative variables wD <- ecomor$diet # wD is a data frame containing a multichoice nominal variable # (diet habit), with 8 modalities (Granivorous, etc) # We must prepare it by prep.binary head(wD) wD <- prep.binary(wD, col.blocks = 8, label = "diet") wF <- ecomor$forsub # wF is also a data frame containing a multichoice nominal variable # (foraging substrat), with 6 modalities (Foliage, etc) # We must prepare it by prep.binary head(wF) wF <- prep.binary(wF, col.blocks = 6, label = "foraging") # Another possibility is to combine the two last data frames wD and wF as # they contain the same type of variables wB <- cbind.data.frame(ecomor$diet, ecomor$forsub) head(wB) wB <- prep.binary(wB, col.blocks = c(8, 6), label = c("diet", "foraging")) # The results given by the two alternatives are identical ktab2 <- ktab.list.df(list(wM, wD, wF)) disecomor <- dist.ktab(ktab2, type= c("Q", "B", "B")) as.matrix(disecomor)[1:5, 1:5] contrib2 <- kdist.cor(ktab2, type= c("Q", "B", "B")) contrib2 ktab3 <- ktab.list.df(list(wM, wB)) disecomor2 <- dist.ktab(ktab3, type= c("Q", "B")) as.matrix(disecomor2)[1:5, 1:5] contrib3 <- kdist.cor(ktab3, type= c("Q", "B")) contrib3 # With a range of variables data(woangers) traits <- woangers$traits # Nominal variables 'li', 'pr', 'lp' and 'le' # (see table 1 in the main text for the codes of the variables) tabN <- traits[,c(1:2, 7, 8)] # Circular variable 'fo' tabC <- traits[3] tabCp <- prep.circular(tabC, 1, 12) # The levels of the variable lie between 1 (January) and 12 (December). # Ordinal variables 'he', 'ae' and 'un' tabO <- traits[, 4:6] # Fuzzy variables 'mp', 'pe' and 'di' tabF <- traits[, 9:19] tabFp <- prep.fuzzy(tabF, c(3, 3, 5), labels = c("mp", "pe", "di")) # 'mp' has 3 levels, 'pe' has 3 levels and 'di' has 5 levels. # Quantitative variables 'lo' and 'lf' tabQ <- traits[, 20:21] ktab1 <- ktab.list.df(list(tabN, tabCp, tabO, tabFp, tabQ)) distrait <- dist.ktab(ktab1, c("N", "C", "O", "F", "Q")) is.euclid(distrait) contrib <- kdist.cor(ktab1, type = c("N", "C", "O", "F", "Q")) contrib dotchart(sort(contrib$glocor), labels = rownames(contrib$glocor)[order(contrib$glocor[, 1])]) ## End(Not run)
This distance matrix between two points is the length of the shortest path between these points.
dist.neig(neig)
dist.neig(neig)
neig |
a neighbouring graph, object of class |
returns a distance matrix, object of class dist
Daniel Chessel
Stéphane Dray [email protected]
data(elec88) d0 <- dist.neig(nb2neig(elec88$nb)) plot(dist(elec88$xy),d0)
data(elec88) d0 <- dist.neig(nb2neig(elec88$nb)) plot(dist(elec88$xy),d0)
computes for percentage data some distance matrices.
dist.prop(df, method = NULL, diag = FALSE, upper = FALSE)
dist.prop(df, method = NULL, diag = FALSE, upper = FALSE)
df |
a data frame containing only positive or null values, used as row percentages |
method |
an integer between 1 and 5. If NULL the choice is made with a console message. See details |
diag |
a logical value indicating whether the diagonal of the distance matrix should be printed by ‘print.dist’ |
upper |
a logical value indicating whether the upper triangle of the distance matrix should be printed by ‘print.dist’ |
returns a distance matrix, object of class dist
Daniel Chessel
Stéphane Dray [email protected]
Edwards, A. W. F. (1971) Distance between populations on the basis of gene frequencies. Biometrics, 27, 873–881.
Manly, B. F. (1994) Multivariate Statistical Methods. A primer., Second edition. Chapman & Hall, London.
Nei, M. (1972) Genetic distances between populations. The American Naturalist, 106, 283–292.
data(microsatt) w <- microsatt$tab[1:microsatt$loci.eff[1]] if(adegraphicsLoaded()) { g1 <- scatter(dudi.pco(lingoes(dist.prop(w, 1)), scann = FALSE), plot = FALSE) g2 <- scatter(dudi.pco(lingoes(dist.prop(w, 2)), scann = FALSE), plot = FALSE) g3 <- scatter(dudi.pco(dist.prop(w, 3), scann = FALSE), plot = FALSE) g4 <- scatter(dudi.pco(lingoes(dist.prop(w, 4)), scann = FALSE), plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2, 2)) scatter(dudi.pco(lingoes(dist.prop(w, 1)), scann = FALSE)) scatter(dudi.pco(lingoes(dist.prop(w, 2)), scann = FALSE)) scatter(dudi.pco(dist.prop(w, 3), scann = FALSE)) scatter(dudi.pco(lingoes(dist.prop(w, 4)), scann = FALSE)) par(mfrow = c(1, 1)) }
data(microsatt) w <- microsatt$tab[1:microsatt$loci.eff[1]] if(adegraphicsLoaded()) { g1 <- scatter(dudi.pco(lingoes(dist.prop(w, 1)), scann = FALSE), plot = FALSE) g2 <- scatter(dudi.pco(lingoes(dist.prop(w, 2)), scann = FALSE), plot = FALSE) g3 <- scatter(dudi.pco(dist.prop(w, 3), scann = FALSE), plot = FALSE) g4 <- scatter(dudi.pco(lingoes(dist.prop(w, 4)), scann = FALSE), plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2, 2)) scatter(dudi.pco(lingoes(dist.prop(w, 1)), scann = FALSE)) scatter(dudi.pco(lingoes(dist.prop(w, 2)), scann = FALSE)) scatter(dudi.pco(dist.prop(w, 3), scann = FALSE)) scatter(dudi.pco(lingoes(dist.prop(w, 4)), scann = FALSE)) par(mfrow = c(1, 1)) }
computes on quantitative variables, some distance matrices as canonical, Joreskog and Mahalanobis.
dist.quant(df, method = NULL, diag = FALSE, upper = FALSE, tol = 1e-07)
dist.quant(df, method = NULL, diag = FALSE, upper = FALSE, tol = 1e-07)
df |
a data frame containing only quantitative variables |
method |
an integer between 1 and 3. If NULL the choice is made with a console message. See details |
diag |
a logical value indicating whether the diagonal of the distance matrix should be printed by ‘print.dist’ |
upper |
a logical value indicating whether the upper triangle of the distance matrix should be printed by ‘print.dist’ |
tol |
used in case 3 of |
All the distances are of type
A = Identity
A = inv(cov)
an object of class dist
Daniel Chessel
Stéphane Dray [email protected]
data(ecomor) if(adegraphicsLoaded()) { g1 <- scatter(dudi.pco(dist.quant(ecomor$morpho, 3), scan = FALSE), plot = FALSE) g2 <- scatter(dudi.pco(dist.quant(ecomor$morpho, 2), scan = FALSE), plot = FALSE) g3 <- scatter(dudi.pco(dist(scalewt(ecomor$morpho)), scan = FALSE), plot = FALSE) g4 <- scatter(dudi.pco(dist.quant(ecomor$morpho, 1), scan = FALSE), plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2, 2)) scatter(dudi.pco(dist.quant(ecomor$morpho, 3), scan = FALSE)) scatter(dudi.pco(dist.quant(ecomor$morpho, 2), scan = FALSE)) scatter(dudi.pco(dist(scalewt(ecomor$morpho)), scan = FALSE)) scatter(dudi.pco(dist.quant(ecomor$morpho, 1), scan = FALSE)) par(mfrow = c(1, 1)) }
data(ecomor) if(adegraphicsLoaded()) { g1 <- scatter(dudi.pco(dist.quant(ecomor$morpho, 3), scan = FALSE), plot = FALSE) g2 <- scatter(dudi.pco(dist.quant(ecomor$morpho, 2), scan = FALSE), plot = FALSE) g3 <- scatter(dudi.pco(dist(scalewt(ecomor$morpho)), scan = FALSE), plot = FALSE) g4 <- scatter(dudi.pco(dist.quant(ecomor$morpho, 1), scan = FALSE), plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2, 2)) scatter(dudi.pco(dist.quant(ecomor$morpho, 3), scan = FALSE)) scatter(dudi.pco(dist.quant(ecomor$morpho, 2), scan = FALSE)) scatter(dudi.pco(dist(scalewt(ecomor$morpho)), scan = FALSE)) scatter(dudi.pco(dist.quant(ecomor$morpho, 1), scan = FALSE)) par(mfrow = c(1, 1)) }
Calculates Rao's diversity coefficient within samples.
divc(df, dis, scale)
divc(df, dis, scale)
df |
a data frame with elements as rows, samples as columns, and abundance, presence-absence or frequencies as entries |
dis |
an object of class |
scale |
a logical value indicating whether or not the diversity coefficient should be scaled by its maximal value over all frequency distributions. |
Returns a data frame with samples as rows and the diversity coefficient within samples as columns
Sandrine Pavoine [email protected]
Rao, C.R. (1982) Diversity and dissimilarity coefficients: a unified approach. Theoretical Population Biology, 21, 24–43.
Gini, C. (1912) Variabilità e mutabilità. Universite di Cagliari III, Parte II.
Simpson, E.H. (1949) Measurement of diversity. Nature, 163, 688.
Champely, S. and Chessel, D. (2002) Measuring biological diversity using Euclidean metrics. Environmental and Ecological Statistics, 9, 167–177.
data(ecomor) dtaxo <- dist.taxo(ecomor$taxo) divc(ecomor$habitat, dtaxo) data(humDNAm) divc(humDNAm$samples, sqrt(humDNAm$distances))
data(ecomor) dtaxo <- dist.taxo(ecomor$taxo) divc(ecomor$habitat, dtaxo) data(humDNAm) divc(humDNAm$samples, sqrt(humDNAm$distances))
For a given dissimilarity matrix, this function calculates the maximal value of Rao's diversity coefficient over all frequency distribution. It uses an optimization technique based on Rosen's projection gradient algorithm and is verified using the Kuhn-Tucker conditions.
divcmax(dis, epsilon, comment)
divcmax(dis, epsilon, comment)
dis |
an object of class |
epsilon |
a tolerance threshold : a frequency is non null if it is higher than epsilon. |
comment |
a logical value indicating whether or not comments on the optimization technique should be printed. |
Returns a list
value |
the maximal value of Rao's diversity coefficient. |
vectors |
a data frame containing four frequency
distributions : |
Stéphane Champely [email protected]
Sandrine Pavoine [email protected]
Rao, C.R. (1982) Diversity and dissimilarity coefficients: a unified approach. Theoretical Population Biology, 21, 24–43.
Gini, C. (1912) Variabilità e mutabilità. Universite di Cagliari III, Parte II.
Simpson, E.H. (1949) Measurement of diversity. Nature, 163, 688.
Champely, S. and Chessel, D. (2002) Measuring biological diversity using Euclidean metrics. Environmental and Ecological Statistics, 9, 167–177.
Pavoine, S., Ollier, S. and Pontier, D. (2005) Measuring diversity from dissimilarities with Rao's quadratic entropy: are any dissimilarities suitable? Theoretical Population Biology, 67, 231–239.
data(elec88) # Dissimilarity matrix. d0 <- dist(elec88$xy/100) # Frequency distribution maximizing spatial diversity in France # according to Rao's quadratic entropy. France.m <- divcmax(d0) w0 <- France.m$vectors$num v0 <- France.m$value idx <- (1:94) [w0 > 0] if(!adegraphicsLoaded()) { # Smallest circle including all the 94 departments. # The squared radius of that circle is the maximal value of the # spatial diversity. w1 <- elec88$xy[idx, ]/100 w.c <- apply(w1 * w0[idx], 2, sum) plot(elec88$xy[, 1]/100, elec88$xy[, 2]/100, asp=1) symbols(w.c[1], w.c[2], circles = sqrt(v0), inches = FALSE, add = TRUE) s.value(elec88$xy/100, w0, add.plot = TRUE) }
data(elec88) # Dissimilarity matrix. d0 <- dist(elec88$xy/100) # Frequency distribution maximizing spatial diversity in France # according to Rao's quadratic entropy. France.m <- divcmax(d0) w0 <- France.m$vectors$num v0 <- France.m$value idx <- (1:94) [w0 > 0] if(!adegraphicsLoaded()) { # Smallest circle including all the 94 departments. # The squared radius of that circle is the maximal value of the # spatial diversity. w1 <- elec88$xy[idx, ]/100 w.c <- apply(w1 * w0[idx], 2, sum) plot(elec88$xy[, 1]/100, elec88$xy[, 2]/100, asp=1) symbols(w.c[1], w.c[2], circles = sqrt(v0), inches = FALSE, add = TRUE) s.value(elec88$xy/100, w0, add.plot = TRUE) }
dotchart.phylog
represents the phylogenetic tree and draws Cleveland dot
plot of each variable.
dotchart.phylog(phylog, values, y = NULL, scaling = TRUE, ranging = TRUE, yranging = NULL, joining = TRUE, yjoining = NULL, ceti = 1, cdot = 1, csub = 1, f.phylog = 1/(1 + ncol(values)), ...)
dotchart.phylog(phylog, values, y = NULL, scaling = TRUE, ranging = TRUE, yranging = NULL, joining = TRUE, yjoining = NULL, ceti = 1, cdot = 1, csub = 1, f.phylog = 1/(1 + ncol(values)), ...)
phylog |
an object of class |
values |
a vector or a data frame giving the variables |
y |
a vector which values correspond to leaves positions |
scaling |
if TRUE, data are scaled |
ranging |
if TRUE, dotplots are drawn with the same horizontal limits |
yranging |
a vector with two values giving the horizontal limits. If NULL, horizontal limits are defined by lower and upper values of data |
joining |
if TRUE, segments join each point to a central value |
yjoining |
a vector with the central value. If NULL, the central value equals 0 |
ceti |
a character size for editing horizontal limits, |
cdot |
a character size for plotting the points of the dot plot,
used with |
csub |
a character size for editing the names of variables, |
f.phylog |
a size coefficient for tree size (a parameter to draw the tree in proportion to leaves labels) |
... |
further arguments passed to or from other methods |
Daniel Chessel
Sébastien Ollier [email protected]
symbols.phylog
and table.phylog
# one variable tre <- c("((A,B),(C,D));") phy <- newick2phylog(tre) x <- 1:4 par(mfrow = c(2,2)) dotchart.phylog(phy, x, scaling = FALSE) dotchart.phylog(phy, x) dotchart.phylog(phy, x, joining = FALSE) dotchart.phylog(phy, x, scaling = FALSE, yjoining = 0, yranging = c(-1, 5)) par(mfrow = c(1,1)) # many variables data(mjrochet) phy <- newick2phylog(mjrochet$tre) tab <- data.frame(log(mjrochet$tab)) dotchart.phylog(phy, tab, ceti = 0.5, csub = 0.6, cleaves = 0, cdot = 0.6) par(mfrow=c(1,1))
# one variable tre <- c("((A,B),(C,D));") phy <- newick2phylog(tre) x <- 1:4 par(mfrow = c(2,2)) dotchart.phylog(phy, x, scaling = FALSE) dotchart.phylog(phy, x) dotchart.phylog(phy, x, joining = FALSE) dotchart.phylog(phy, x, scaling = FALSE, yjoining = 0, yranging = c(-1, 5)) par(mfrow = c(1,1)) # many variables data(mjrochet) phy <- newick2phylog(mjrochet$tre) tab <- data.frame(log(mjrochet$tab)) dotchart.phylog(phy, tab, ceti = 0.5, csub = 0.6, cleaves = 0, cdot = 0.6) par(mfrow=c(1,1))
This function represents n values on a circle. The n points are shared out regularly over the circle and put on the radius according to the value attributed to that measure.
dotcircle(z, alpha0 = pi/2, xlim = range(pretty(z)), labels = names(z), clabel = 1, cleg = 1)
dotcircle(z, alpha0 = pi/2, xlim = range(pretty(z)), labels = names(z), clabel = 1, cleg = 1)
z |
: a numeric vector |
alpha0 |
: polar angle to put the first value |
xlim |
: the ranges to be encompassed by the circle radius |
labels |
: a vector of strings of characters for the angle labels |
clabel |
: a character size for the labels, used with |
cleg |
: a character size for the ranges, used with |
Daniel Chessel
w <- scores.neig(neig(n.cir = 24)) par(mfrow = c(4,4)) for (k in 1:16) dotcircle(w[,k],labels = 1:24) par(mfrow = c(1,1))
w <- scores.neig(neig(n.cir = 24)) par(mfrow = c(4,4)) for (k in 1:16) dotcircle(w[,k],labels = 1:24) par(mfrow = c(1,1))
This data set gives environmental variables, fish species and spatial coordinates for 30 sites.
data(doubs)
data(doubs)
doubs
is a list with 4 components.
is a data frame with 30 rows (sites) and 11 environmental variables.
is a data frame with 30 rows (sites) and 27 fish species.
is a data frame with 30 rows (sites) and 2 spatial coordinates.
is a data frame with 27 rows (species) and 4 columns (names).
The rows of doubs$env
, doubs$fish
and doubs$xy
are 30 sites along the Doubs, a French and Switzerland river.
doubs$env
contains the following variables:
dfs - distance from the source (km * 10),
alt - altitude (m),
slo ( where x is the slope (per mil * 100),
flo - minimum average stream flow (m3/s * 100),
pH (* 10),
har - total hardness of water (mg/l of Calcium),
pho - phosphates (mg/l * 100),
nit - nitrates (mg/l * 100),
amm - ammonia nitrogen (mg/l * 100),
oxy - dissolved oxygen (mg/l * 10),
bdo - biological demand for oxygen (mg/l * 10).
doubs$fish
contains the abundance of the following fish species: Cottus gobio (Cogo), Salmo trutta fario (Satr),
Phoxinus phoxinus (Phph), Nemacheilus barbatulus (Neba), Thymallus thymallus (Thth), Telestes soufia agassizi (Teso),
Chondrostoma nasus (Chna), Chondostroma toxostoma (Chto), Leuciscus leuciscus (Lele), Leuciscus cephalus cephalus (Lece),
Barbus barbus (Baba), Spirlinus bipunctatus (Spbi), Gobio gobio (Gogo), Esox lucius (Eslu),
Perca fluviatilis (Pefl), Rhodeus amarus (Rham), Lepomis gibbosus (Legi), Scardinius erythrophtalmus (Scer),
Cyprinus carpio (Cyca), Tinca tinca (Titi), Abramis brama (Abbr), Ictalurus melas (Icme),
Acerina cernua (Acce), Rutilus rutilus (Ruru), Blicca bjoerkna (Blbj), Alburnus alburnus (Alal),
Anguilla anguilla (Anan).
doubs$species
contains the names of the 27 fish species. The four columns correspond to: 1 = scientific name (Genus species), 2 = French common name, 3 = English common name, 4 = Four character code.
Verneaux, J. (1973) Cours d'eau de Franche-Comté (Massif du Jura). Recherches écologiques sur le réseau hydrographique du Doubs. Essai de biotypologie. Thèse d'état, Besançon. 1–257.
See a French description of fish species at http://pbil.univ-lyon1.fr/R/pdf/pps047.pdf.
Chessel, D., Lebreton, J.D. and Yoccoz, N.G. (1987) Propriétés de l'analyse canonique des correspondances. Une illustration
en hydrobiologie. Revue de Statistique Appliquée, 35, 4, 55–72.
data(doubs) pca1 <- dudi.pca(doubs$env, scan = FALSE) pca2 <- dudi.pca(doubs$fish, scale = FALSE, scan = FALSE) coiner1 <- coinertia(pca1, pca2, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.corcircle(coiner1$aX, plot = FALSE) g2 <- s.value(doubs$xy, coiner1$lX[, 1], plot = FALSE) g3 <- s.value(doubs$xy, coiner1$lX[, 2], plot = FALSE) g4 <- s.arrow(coiner1$c1, plot = FALSE) g5 <- s.match(coiner1$mX, coiner1$mY, plot = FALSE) g6 <- s.corcircle(coiner1$aY, plot = FALSE) g7 <- s.arrow(coiner1$l1, plot = FALSE) g8 <- s.value(doubs$xy, coiner1$lY[, 1], plot = FALSE) g9 <- s.value(doubs$xy, coiner1$lY[, 2], plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4, g5, g6, g7, g8, g9), layout = c(3, 3)) } else { par(mfrow = c(3, 3)) s.corcircle(coiner1$aX) s.value(doubs$xy, coiner1$lX[, 1]) s.value(doubs$xy, coiner1$lX[, 2]) s.arrow(coiner1$c1) s.match(coiner1$mX, coiner1$mY) s.corcircle(coiner1$aY) s.arrow(coiner1$l1) s.value(doubs$xy, coiner1$lY[, 1]) s.value(doubs$xy, coiner1$lY[, 2]) par(mfrow = c(1, 1)) }
data(doubs) pca1 <- dudi.pca(doubs$env, scan = FALSE) pca2 <- dudi.pca(doubs$fish, scale = FALSE, scan = FALSE) coiner1 <- coinertia(pca1, pca2, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.corcircle(coiner1$aX, plot = FALSE) g2 <- s.value(doubs$xy, coiner1$lX[, 1], plot = FALSE) g3 <- s.value(doubs$xy, coiner1$lX[, 2], plot = FALSE) g4 <- s.arrow(coiner1$c1, plot = FALSE) g5 <- s.match(coiner1$mX, coiner1$mY, plot = FALSE) g6 <- s.corcircle(coiner1$aY, plot = FALSE) g7 <- s.arrow(coiner1$l1, plot = FALSE) g8 <- s.value(doubs$xy, coiner1$lY[, 1], plot = FALSE) g9 <- s.value(doubs$xy, coiner1$lY[, 2], plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4, g5, g6, g7, g8, g9), layout = c(3, 3)) } else { par(mfrow = c(3, 3)) s.corcircle(coiner1$aX) s.value(doubs$xy, coiner1$lX[, 1]) s.value(doubs$xy, coiner1$lX[, 2]) s.arrow(coiner1$c1) s.match(coiner1$mX, coiner1$mY) s.corcircle(coiner1$aY) s.arrow(coiner1$l1) s.value(doubs$xy, coiner1$lY[, 1]) s.value(doubs$xy, coiner1$lY[, 2]) par(mfrow = c(1, 1)) }
Performs a double principal coordinate analysis
dpcoa(df, dis = NULL, scannf = TRUE, nf = 2, full = FALSE, tol = 1e-07, RaoDecomp = TRUE) ## S3 method for class 'dpcoa' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'dpcoa' print(x, ...) ## S3 method for class 'dpcoa' summary(object, ...)
dpcoa(df, dis = NULL, scannf = TRUE, nf = 2, full = FALSE, tol = 1e-07, RaoDecomp = TRUE) ## S3 method for class 'dpcoa' plot(x, xax = 1, yax = 2, ...) ## S3 method for class 'dpcoa' print(x, ...) ## S3 method for class 'dpcoa' summary(object, ...)
df |
a data frame with samples as rows and categories (i.e. species) as columns and abundance or presence-absence as entries. Previous releases of ade4 (<=1.6-2) considered the transposed matrix as argument. |
dis |
an object of class |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
RaoDecomp |
a logical value indicating whether Rao diversity decomposition should be performed |
nf |
if scannf is FALSE, an integer indicating the number of kept axes |
full |
a logical value indicating whether all non null eigenvalues should be kept |
tol |
a tolerance threshold for null eigenvalues (a value less than tol times the first one is considered as null) |
x , object
|
an object of class |
xax |
the column number for the x-axis |
yax |
the column number for the y-axis |
... |
|
Returns a list of class dpcoa
containing:
call |
call |
nf |
a numeric value indicating the number of kept axes |
dw |
a numeric vector containing the weights of the elements (was
|
lw |
a numeric vector containing the weights of the samples (was
|
eig |
a numeric vector with all the eigenvalues |
RaoDiv |
a numeric vector containing diversities within samples |
RaoDis |
an object of class |
RaoDecodiv |
a data frame with the decomposition of the diversity |
dls |
a data frame with the coordinates of the elements (was
|
li |
a data frame with the coordinates of the samples (was
|
c1 |
a data frame with the scores of the principal axes of the elements |
Daniel Chessel
Sandrine Pavoine [email protected]
Stéphane Dray [email protected]
Pavoine, S., Dufour, A.B. and Chessel, D. (2004) From dissimilarities among species to dissimilarities among communities: a double principal coordinate analysis. Journal of Theoretical Biology, 228, 523–537.
data(humDNAm) dpcoahum <- dpcoa(data.frame(t(humDNAm$samples)), sqrt(humDNAm$distances), scan = FALSE, nf = 2) dpcoahum if(adegraphicsLoaded()) { g1 <- plot(dpcoahum) } else { plot(dpcoahum) } ## Not run: data(ecomor) dtaxo <- dist.taxo(ecomor$taxo) dpcoaeco <- dpcoa(data.frame(t(ecomor$habitat)), dtaxo, scan = FALSE, nf = 2) dpcoaeco if(adegraphicsLoaded()) { g1 <- plot(dpcoaeco) } else { plot(dpcoaeco) } ## End(Not run)
data(humDNAm) dpcoahum <- dpcoa(data.frame(t(humDNAm$samples)), sqrt(humDNAm$distances), scan = FALSE, nf = 2) dpcoahum if(adegraphicsLoaded()) { g1 <- plot(dpcoahum) } else { plot(dpcoahum) } ## Not run: data(ecomor) dtaxo <- dist.taxo(ecomor$taxo) dpcoaeco <- dpcoa(data.frame(t(ecomor$habitat)), dtaxo, scan = FALSE, nf = 2) dpcoaeco if(adegraphicsLoaded()) { g1 <- plot(dpcoaeco) } else { plot(dpcoaeco) } ## End(Not run)
as.dudi
is called by many functions (dudi.pca
, dudi.coa
, dudi.acm
, ...)
and not directly by the user. It creates duality diagrams.
t.dudi
returns an object of class 'dudi
' where the rows are the columns and the columns are the rows
of the initial dudi
.
is.dudi
returns TRUE if the object is of class dudi
redo.dudi
computes again an analysis, eventually changing the number of kept axes. Used by other functions.
as.dudi(df, col.w, row.w, scannf, nf, call, type, tol = 1e-07, full = FALSE) ## S3 method for class 'dudi' print(x, ...) is.dudi(x) redo.dudi(dudi, newnf = 2) ## S3 method for class 'dudi' t(x) ## S3 method for class 'dudi' summary(object, ...) ## S3 method for class 'dudi' x[i,j]
as.dudi(df, col.w, row.w, scannf, nf, call, type, tol = 1e-07, full = FALSE) ## S3 method for class 'dudi' print(x, ...) is.dudi(x) redo.dudi(dudi, newnf = 2) ## S3 method for class 'dudi' t(x) ## S3 method for class 'dudi' summary(object, ...) ## S3 method for class 'dudi' x[i,j]
df |
a data frame with n rows and p columns |
col.w |
a numeric vector containing the row weights |
row.w |
a numeric vector containing the column weights |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
call |
generally |
type |
a string of characters : the returned list will be of class |
tol |
a tolerance threshold for null eigenvalues (a value less than tol times the first one is considered as null) |
full |
a logical value indicating whether all non null eigenvalues should be kept |
x , dudi , object
|
objects of class |
... |
further arguments passed to or from other methods |
newnf |
an integer indicating the number of kept axes |
i , j
|
elements to extract (integer or empty): index of rows (i) and columns (j) |
as.dudi and all the functions that use it return a list with the following components :
tab |
a data frame with n rows and p columns |
cw |
column weights, a vector with n components |
lw |
row (lines) weights, a vector with p components |
eig |
eigenvalues, a vector with min(n,p) components |
nf |
integer, number of kept axes |
c1 |
principal axes, data frame with p rows and nf columns |
l1 |
principal components, data frame with n rows and nf columns |
co |
column coordinates, data frame with p rows and nf columns |
li |
row coordinates, data frame with n rows and nf columns |
call |
original call |
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Stéphane Dray [email protected]
Escoufier, Y. (1987) The duality diagram : a means of better practical applications In Development in numerical ecology, Legendre, P. & Legendre, L. (Eds.) NATO advanced Institute, Serie G. Springer Verlag, Berlin, 139–156.
data(deug) dd1 <- dudi.pca(deug$tab, scannf = FALSE) dd1 t(dd1) is.dudi(dd1) redo.dudi(dd1,3) summary(dd1)
data(deug) dd1 <- dudi.pca(deug$tab, scannf = FALSE) dd1 t(dd1) is.dudi(dd1) redo.dudi(dd1,3) summary(dd1)
dudi.acm
performs the multiple correspondence analysis of a factor table.acm.burt
an utility giving the crossed Burt table of two factors table.acm.disjonctif
an utility giving the complete disjunctive table of a factor table.boxplot.acm
a graphic utility to interpret axes.
dudi.acm (df, row.w = rep(1, nrow(df)), scannf = TRUE, nf = 2) acm.burt (df1, df2, counts = rep(1, nrow(df1))) acm.disjonctif (df) ## S3 method for class 'acm' boxplot(x, xax = 1, ...)
dudi.acm (df, row.w = rep(1, nrow(df)), scannf = TRUE, nf = 2) acm.burt (df1, df2, counts = rep(1, nrow(df1))) acm.disjonctif (df) ## S3 method for class 'acm' boxplot(x, xax = 1, ...)
df , df1 , df2
|
data frames containing only factors |
row.w , counts
|
vector of row weights, by default, uniform weighting |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
x |
an object of class |
xax |
the number of factor to display |
... |
further arguments passed to or from other methods |
dudi.acm
returns a list of class acm
and dudi
(see dudi) containing
cr |
a data frame which rows are the variables, columns are the kept scores and the values are the correlation ratios |
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Tenenhaus, M. & Young, F.W. (1985) An analysis and synthesis of multiple correspondence analysis, optimal scaling, dual scaling, homogeneity analysis ans other methods for quantifying categorical multivariate data. Psychometrika, 50, 1, 91-119.
Lebart, L., A. Morineau, and M. Piron. 1995. Statistique exploratoire multidimensionnelle. Dunod, Paris.
data(ours) summary(ours) if(adegraphicsLoaded()) { g1 <- s1d.boxplot(dudi.acm(ours, scan = FALSE)$li[, 1], ours) } else { boxplot(dudi.acm(ours, scan = FALSE)) } ## Not run: data(banque) banque.acm <- dudi.acm(banque, scann = FALSE, nf = 3) if(adegraphicsLoaded()) { g2 <- adegraphics:::scatter.dudi(banque.acm) } else { scatter(banque.acm) } apply(banque.acm$cr, 2, mean) banque.acm$eig[1:banque.acm$nf] # the same thing if(adegraphicsLoaded()) { g3 <- s1d.boxplot(banque.acm$li[, 1], banque) g4 <- scatter(banque.acm) } else { boxplot(banque.acm) scatter(banque.acm) } s.value(banque.acm$li, banque.acm$li[,3]) bb <- acm.burt(banque, banque) bbcoa <- dudi.coa(bb, scann = FALSE) plot(banque.acm$c1[,1], bbcoa$c1[,1]) # mca and coa of Burt table. Lebart & coll. section 1.4 bd <- acm.disjonctif(banque) bdcoa <- dudi.coa(bd, scann = FALSE) plot(banque.acm$li[,1], bdcoa$li[,1]) # mca and coa of disjonctive table. Lebart & coll. section 1.4 plot(banque.acm$co[,1], dudi.coa(bd, scann = FALSE)$co[,1]) ## End(Not run)
data(ours) summary(ours) if(adegraphicsLoaded()) { g1 <- s1d.boxplot(dudi.acm(ours, scan = FALSE)$li[, 1], ours) } else { boxplot(dudi.acm(ours, scan = FALSE)) } ## Not run: data(banque) banque.acm <- dudi.acm(banque, scann = FALSE, nf = 3) if(adegraphicsLoaded()) { g2 <- adegraphics:::scatter.dudi(banque.acm) } else { scatter(banque.acm) } apply(banque.acm$cr, 2, mean) banque.acm$eig[1:banque.acm$nf] # the same thing if(adegraphicsLoaded()) { g3 <- s1d.boxplot(banque.acm$li[, 1], banque) g4 <- scatter(banque.acm) } else { boxplot(banque.acm) scatter(banque.acm) } s.value(banque.acm$li, banque.acm$li[,3]) bb <- acm.burt(banque, banque) bbcoa <- dudi.coa(bb, scann = FALSE) plot(banque.acm$c1[,1], bbcoa$c1[,1]) # mca and coa of Burt table. Lebart & coll. section 1.4 bd <- acm.disjonctif(banque) bdcoa <- dudi.coa(bd, scann = FALSE) plot(banque.acm$li[,1], bdcoa$li[,1]) # mca and coa of disjonctive table. Lebart & coll. section 1.4 plot(banque.acm$co[,1], dudi.coa(bd, scann = FALSE)$co[,1]) ## End(Not run)
performs a correspondence analysis.
dudi.coa(df, scannf = TRUE, nf = 2)
dudi.coa(df, scannf = TRUE, nf = 2)
df |
a data frame containing positive or null values |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
returns a list of class coa
and dudi
(see dudi) containing
N |
the sum of all the values of the initial table |
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Benzécri, J.P. and Coll. (1973) L'analyse des données. II L'analyse des correspondances, Bordas, Paris. 1–620.
Greenacre, M. J. (1984) Theory and applications of correspondence analysis, Academic Press, London.
data(rpjdl) chisq.test(rpjdl$fau)$statistic rpjdl.coa <- dudi.coa(rpjdl$fau, scannf = FALSE, nf = 4) sum(rpjdl.coa$eig)*rpjdl.coa$N # the same if(adegraphicsLoaded()) { g1 <- s.label(rpjdl.coa$co, plab.cex = 0.6, lab = rpjdl$frlab, plot = FALSE) g2 <- s.label(rpjdl.coa$li, plab.cex = 0.6, plot = FALSE) cbindADEg(g1, g2, plot = TRUE) } else { par(mfrow = c(1,2)) s.label(rpjdl.coa$co, clab = 0.6, lab = rpjdl$frlab) s.label(rpjdl.coa$li, clab = 0.6) par(mfrow = c(1,1)) } data(bordeaux) db <- dudi.coa(bordeaux, scan = FALSE) db score(db)
data(rpjdl) chisq.test(rpjdl$fau)$statistic rpjdl.coa <- dudi.coa(rpjdl$fau, scannf = FALSE, nf = 4) sum(rpjdl.coa$eig)*rpjdl.coa$N # the same if(adegraphicsLoaded()) { g1 <- s.label(rpjdl.coa$co, plab.cex = 0.6, lab = rpjdl$frlab, plot = FALSE) g2 <- s.label(rpjdl.coa$li, plab.cex = 0.6, plot = FALSE) cbindADEg(g1, g2, plot = TRUE) } else { par(mfrow = c(1,2)) s.label(rpjdl.coa$co, clab = 0.6, lab = rpjdl$frlab) s.label(rpjdl.coa$li, clab = 0.6) par(mfrow = c(1,1)) } data(bordeaux) db <- dudi.coa(bordeaux, scan = FALSE) db score(db)
performs a decentred correspondence analysis.
dudi.dec(df, eff, scannf = TRUE, nf = 2)
dudi.dec(df, eff, scannf = TRUE, nf = 2)
df |
a data frame containing positive or null values |
eff |
a vector containing the reference distribution. Its length is equal to the number of rows of df |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
Returns a list of class dec
and dudi
(see dudi
) containing also
R |
sum of all the values of the initial table |
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Dolédec, S., Chessel, D. and Olivier J. M. (1995) L'analyse des correspondances décentrée: application aux peuplements ichtyologiques du haut-Rhône. Bulletin Français de la Pêche et de la Pisciculture, 336, 29–40.
data(ichtyo) dudi1 <- dudi.dec(ichtyo$tab, ichtyo$eff, scan = FALSE) sum(apply(ichtyo$tab, 2, function(x) chisq.test(x, p = ichtyo$eff/sum(ichtyo$eff))$statistic)) sum(dudi1$eig) * sum(ichtyo$eff) # the same s.class(dudi1$li, ichtyo$dat, wt = ichtyo$eff/sum(ichtyo$eff))
data(ichtyo) dudi1 <- dudi.dec(ichtyo$tab, ichtyo$eff, scan = FALSE) sum(apply(ichtyo$tab, 2, function(x) chisq.test(x, p = ichtyo$eff/sum(ichtyo$eff))$statistic)) sum(dudi1$eig) * sum(ichtyo$eff) # the same s.class(dudi1$li, ichtyo$dat, wt = ichtyo$eff/sum(ichtyo$eff))
Theses functions analyse a table of fuzzy variables.
A fuzzy variable takes values of type
giving the importance of k categories.
A missing data is denoted (0,...,0).
Only the profile a/sum(a) is used, and missing data are replaced by
the mean profile of the others in the function prep.fuzzy.var
. See ref. for details.
prep.fuzzy.var (df, col.blocks, row.w = rep(1, nrow(df))) dudi.fca(df, scannf = TRUE, nf = 2) dudi.fpca(df, scannf = TRUE, nf = 2)
prep.fuzzy.var (df, col.blocks, row.w = rep(1, nrow(df))) dudi.fca(df, scannf = TRUE, nf = 2) dudi.fpca(df, scannf = TRUE, nf = 2)
df |
a data frame containing positive or null values |
col.blocks |
a vector containing the number of categories for each fuzzy variable |
row.w |
a vector of row weights |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
The function prep.fuzzy.var
returns a data frame with the attribute col.blocks
.
The function dudi.fca
returns a list of class fca
and dudi
(see dudi) containing also
cr |
a data frame which rows are the blocs, columns are the kept axes, and values are the correlation ratios. |
The function dudi.fpca
returns a list of class pca
and dudi
(see dudi) containing also
cent
norm
blo
indica
FST
inertia
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Chevenet, F., Dolédec, S. and Chessel, D. (1994) A fuzzy coding approach for the analysis of long-term ecological data. Freshwater Biology, 31, 295–309.
w1 <- matrix(c(1,0,0,2,1,1,0,2,2,0,1,0,1,1,1,0,1,3,1,0), 4, 5) w1 <- data.frame(w1) w2 <- prep.fuzzy.var(w1, c(2, 3)) w1 w2 attributes(w2) data(bsetal97) w <- prep.fuzzy.var(bsetal97$biol, bsetal97$biol.blo) if(adegraphicsLoaded()) { g1 <- plot(dudi.fca(w, scann = FALSE, nf = 3), plabels.cex = 1.5) } else { scatter(dudi.fca(w, scann = FALSE, nf = 3), csub = 3, clab.moda = 1.5) scatter(dudi.fpca(w, scann = FALSE, nf = 3), csub = 3, clab.moda = 1.5) } ## Not run: w1 <- prep.fuzzy.var(bsetal97$biol, bsetal97$biol.blo) w2 <- prep.fuzzy.var(bsetal97$ecol, bsetal97$ecol.blo) d1 <- dudi.fca(w1, scannf = FALSE, nf = 3) d2 <- dudi.fca(w2, scannf = FALSE, nf = 3) plot(coinertia(d1, d2, scannf = FALSE)) ## End(Not run)
w1 <- matrix(c(1,0,0,2,1,1,0,2,2,0,1,0,1,1,1,0,1,3,1,0), 4, 5) w1 <- data.frame(w1) w2 <- prep.fuzzy.var(w1, c(2, 3)) w1 w2 attributes(w2) data(bsetal97) w <- prep.fuzzy.var(bsetal97$biol, bsetal97$biol.blo) if(adegraphicsLoaded()) { g1 <- plot(dudi.fca(w, scann = FALSE, nf = 3), plabels.cex = 1.5) } else { scatter(dudi.fca(w, scann = FALSE, nf = 3), csub = 3, clab.moda = 1.5) scatter(dudi.fpca(w, scann = FALSE, nf = 3), csub = 3, clab.moda = 1.5) } ## Not run: w1 <- prep.fuzzy.var(bsetal97$biol, bsetal97$biol.blo) w2 <- prep.fuzzy.var(bsetal97$ecol, bsetal97$ecol.blo) d1 <- dudi.fca(w1, scannf = FALSE, nf = 3) d2 <- dudi.fca(w2, scannf = FALSE, nf = 3) plot(coinertia(d1, d2, scannf = FALSE)) ## End(Not run)
performs a multivariate analysis with mixed quantitative variables and factors.
dudi.hillsmith(df, row.w = rep(1, nrow(df))/nrow(df), scannf = TRUE, nf = 2)
dudi.hillsmith(df, row.w = rep(1, nrow(df))/nrow(df), scannf = TRUE, nf = 2)
df |
a data frame with mixed type variables (quantitative and factor) |
row.w |
a vector of row weights, by default uniform row weights are used |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
If df
contains only quantitative variables, this is equivalent to a normed PCA.
If df
contains only factors, this is equivalent to a MCA.
This analysis is the Hill and Smith method and is very similar to dudi.mix
function.
The differences are that dudi.hillsmith
allow to use various row weights, while
dudi.mix
deals with ordered variables.
The principal components of this analysis are centered and normed vectors maximizing the sum of :
squared correlation coefficients with quantitative variables
correlation ratios with factors
Returns a list of class mix
and dudi
(see dudi) containing also
index |
a factor giving the type of each variable : f = factor, q = quantitative |
assign |
a factor indicating the initial variable for each column of the transformed table |
cr |
a data frame giving for each variable and each score: |
Stéphane Dray [email protected]
Anne-Béatrice Dufour [email protected]
Hill, M. O., and A. J. E. Smith. 1976. Principal component analysis of taxonomic data with multi-state discrete characters. Taxon, 25, 249-255.
dudi.mix
data(dunedata) attributes(dunedata$envir$use)$class <- "factor" # use dudi.mix for ordered data dd1 <- dudi.hillsmith(dunedata$envir, scann = FALSE) if(adegraphicsLoaded()) { g <- scatter(dd1, row.plab.cex = 1, col.plab.cex = 1.5) } else { scatter(dd1, clab.r = 1, clab.c = 1.5) }
data(dunedata) attributes(dunedata$envir$use)$class <- "factor" # use dudi.mix for ordered data dd1 <- dudi.hillsmith(dunedata$envir, scann = FALSE) if(adegraphicsLoaded()) { g <- scatter(dd1, row.plab.cex = 1, col.plab.cex = 1.5) } else { scatter(dd1, clab.r = 1, clab.c = 1.5) }
performs a multivariate analysis with mixed quantitative variables and factors.
dudi.mix(df, add.square = FALSE, scannf = TRUE, nf = 2)
dudi.mix(df, add.square = FALSE, scannf = TRUE, nf = 2)
df |
a data frame with mixed type variables (quantitative, factor and ordered) |
add.square |
a logical value indicating whether the squares of quantitative variables should be added |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
If df contains only quantitative variables, this is equivalent to a normed PCA.
If df contains only factors, this is equivalent to a MCA.
Ordered factors are replaced by poly(x,deg=2)
.
This analysis generalizes the Hill and Smith method.
The principal components of this analysis are centered and normed vectors maximizing the sum of the:
squared correlation coefficients with quantitative variables
squared multiple correlation coefficients with polynoms
correlation ratios with factors.
Returns a list of class mix
and dudi
(see dudi) containing also
index |
a factor giving the type of each variable : f = factor, o = ordered, q = quantitative |
assign |
a factor indicating the initial variable for each column of the transformed table |
cr |
a data frame giving for each variable and each score: |
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Hill, M. O., and A. J. E. Smith. 1976. Principal component analysis of taxonomic data with multi-state discrete characters. Taxon, 25, 249-255.
De Leeuw, J., J. van Rijckevorsel, and . 1980. HOMALS and PRINCALS - Some generalizations of principal components analysis. Pages 231-242 in E. Diday and Coll., editors. Data Analysis and Informatics II. Elsevier Science Publisher, North Holland, Amsterdam.
Kiers, H. A. L. 1994. Simple structure in component analysis techniques for mixtures of qualitative ans quantitative variables. Psychometrika, 56, 197-212.
data(dunedata) dd1 <- dudi.mix(dunedata$envir, scann = FALSE) if(adegraphicsLoaded()) { g1 <- scatter(dd1, row.plab.cex = 1, col.plab.cex = 1.5) } else { scatter(dd1, clab.r = 1, clab.c = 1.5) } dd2 <- dudi.mix(dunedata$envir, scann = FALSE, add.square = TRUE) if(adegraphicsLoaded()) { g2 <- scatter(dd2, row.plab.cex = 1, col.plab.cex = 1.5) } else { scatter(dd2, clab.r = 1, clab.c = 1.5) }
data(dunedata) dd1 <- dudi.mix(dunedata$envir, scann = FALSE) if(adegraphicsLoaded()) { g1 <- scatter(dd1, row.plab.cex = 1, col.plab.cex = 1.5) } else { scatter(dd1, clab.r = 1, clab.c = 1.5) } dd2 <- dudi.mix(dunedata$envir, scann = FALSE, add.square = TRUE) if(adegraphicsLoaded()) { g2 <- scatter(dd2, row.plab.cex = 1, col.plab.cex = 1.5) } else { scatter(dd2, clab.r = 1, clab.c = 1.5) }
performs a non symmetric correspondence analysis.
dudi.nsc(df, scannf = TRUE, nf = 2)
dudi.nsc(df, scannf = TRUE, nf = 2)
df |
a data frame containing positive or null values |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
Returns a list of class nsc
and dudi
(see dudi
) containing also
N |
sum of the values of the initial table |
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Kroonenberg, P. M., and Lombardo R. (1999) Nonsymmetric correspondence analysis: a tool for analysing contingency tables with a dependence structure. Multivariate Behavioral Research, 34, 367–396.
data(housetasks) nsc1 <- dudi.nsc(housetasks, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.label(nsc1$c1, plab.cex = 1.25) g2 <- s.arrow(nsc1$li, add = TRUE, plab.cex = 0.75) } else { s.label(nsc1$c1, clab = 1.25) s.arrow(nsc1$li, add.pl = TRUE, clab = 0.75) # see ref p.383 }
data(housetasks) nsc1 <- dudi.nsc(housetasks, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.label(nsc1$c1, plab.cex = 1.25) g2 <- s.arrow(nsc1$li, add = TRUE, plab.cex = 0.75) } else { s.label(nsc1$c1, clab = 1.25) s.arrow(nsc1$li, add.pl = TRUE, clab = 0.75) # see ref p.383 }
dudi.pca
performs a principal component analysis of a data frame and
returns the results as objects of class pca
and dudi
.
dudi.pca(df, row.w = rep(1, nrow(df))/nrow(df), col.w = rep(1, ncol(df)), center = TRUE, scale = TRUE, scannf = TRUE, nf = 2)
dudi.pca(df, row.w = rep(1, nrow(df))/nrow(df), col.w = rep(1, ncol(df)), center = TRUE, scale = TRUE, scannf = TRUE, nf = 2)
df |
a data frame with n rows (individuals) and p columns (numeric variables) |
row.w |
an optional row weights (by default, uniform row weights) |
col.w |
an optional column weights (by default, unit column weights) |
center |
a logical or numeric value, centring option |
scale |
a logical value indicating whether the column vectors should be normed for the row.w weighting |
scannf |
a logical value indicating whether the screeplot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
Returns a list of classes pca
and dudi
(see dudi) containing the used information
for computing the principal component analysis :
tab |
the data frame to be analyzed depending of the transformation arguments (center and scale) |
cw |
the column weights |
lw |
the row weights |
eig |
the eigenvalues |
rank |
the rank of the analyzed matrice |
nf |
the number of kept factors |
c1 |
the column normed scores i.e. the principal axes |
l1 |
the row normed scores |
co |
the column coordinates |
li |
the row coordinates i.e. the principal components |
call |
the call function |
cent |
the p vector containing the means for variables (Note that if |
norm |
the p vector containing the standard deviations for variables i.e. the root
of the sum of squares deviations of the values from their means divided by n (Note that if |
Daniel Chessel
Anne-Béatrice Dufour [email protected]
prcomp
, princomp
in the mva
library
data(deug) deug.dudi <- dudi.pca(deug$tab, center = deug$cent, scale = FALSE, scan = FALSE) deug.dudi1 <- dudi.pca(deug$tab, center = TRUE, scale = TRUE, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.class(deug.dudi$li, deug$result, plot = FALSE) g2 <- s.arrow(deug.dudi$c1, lab = names(deug$tab), plot = FALSE) g3 <- s.class(deug.dudi1$li, deug$result, plot = FALSE) g4 <- s.corcircle(deug.dudi1$co, lab = names(deug$tab), full = FALSE, plot = FALSE) G1 <- rbindADEg(cbindADEg(g1, g2, plot = FALSE), cbindADEg(g3, g4, plot = FALSE), plot = TRUE) G2 <- s1d.hist(deug.dudi$tab, breaks = seq(-45, 35, by = 5), type = "density", xlim = c(-40, 40), right = FALSE, ylim = c(0, 0.1), porigin.lwd = 2) } else { par(mfrow = c(2, 2)) s.class(deug.dudi$li, deug$result, cpoint = 1) s.arrow(deug.dudi$c1, lab = names(deug$tab)) s.class(deug.dudi1$li, deug$result, cpoint = 1) s.corcircle(deug.dudi1$co, lab = names(deug$tab), full = FALSE, box = TRUE) par(mfrow = c(1, 1)) # for interpretations par(mfrow = c(3, 3)) par(mar = c(2.1, 2.1, 2.1, 1.1)) for(i in 1:9) { hist(deug.dudi$tab[,i], xlim = c(-40, 40), breaks = seq(-45, 35, by = 5), prob = TRUE, right = FALSE, main = names(deug$tab)[i], xlab = "", ylim = c(0, 0.10)) abline(v = 0, lwd = 3) } par(mfrow = c(1, 1)) }
data(deug) deug.dudi <- dudi.pca(deug$tab, center = deug$cent, scale = FALSE, scan = FALSE) deug.dudi1 <- dudi.pca(deug$tab, center = TRUE, scale = TRUE, scan = FALSE) if(adegraphicsLoaded()) { g1 <- s.class(deug.dudi$li, deug$result, plot = FALSE) g2 <- s.arrow(deug.dudi$c1, lab = names(deug$tab), plot = FALSE) g3 <- s.class(deug.dudi1$li, deug$result, plot = FALSE) g4 <- s.corcircle(deug.dudi1$co, lab = names(deug$tab), full = FALSE, plot = FALSE) G1 <- rbindADEg(cbindADEg(g1, g2, plot = FALSE), cbindADEg(g3, g4, plot = FALSE), plot = TRUE) G2 <- s1d.hist(deug.dudi$tab, breaks = seq(-45, 35, by = 5), type = "density", xlim = c(-40, 40), right = FALSE, ylim = c(0, 0.1), porigin.lwd = 2) } else { par(mfrow = c(2, 2)) s.class(deug.dudi$li, deug$result, cpoint = 1) s.arrow(deug.dudi$c1, lab = names(deug$tab)) s.class(deug.dudi1$li, deug$result, cpoint = 1) s.corcircle(deug.dudi1$co, lab = names(deug$tab), full = FALSE, box = TRUE) par(mfrow = c(1, 1)) # for interpretations par(mfrow = c(3, 3)) par(mar = c(2.1, 2.1, 2.1, 1.1)) for(i in 1:9) { hist(deug.dudi$tab[,i], xlim = c(-40, 40), breaks = seq(-45, 35, by = 5), prob = TRUE, right = FALSE, main = names(deug$tab)[i], xlab = "", ylim = c(0, 0.10)) abline(v = 0, lwd = 3) } par(mfrow = c(1, 1)) }
dudi.pco
performs a principal coordinates analysis of a Euclidean distance matrix
and returns the results as objects of class pco
and dudi
.
dudi.pco(d, row.w = "uniform", scannf = TRUE, nf = 2, full = FALSE, tol = 1e-07) ## S3 method for class 'pco' scatter(x, xax = 1, yax = 2, clab.row = 1, posieig = "top", sub = NULL, csub = 2, ...)
dudi.pco(d, row.w = "uniform", scannf = TRUE, nf = 2, full = FALSE, tol = 1e-07) ## S3 method for class 'pco' scatter(x, xax = 1, yax = 2, clab.row = 1, posieig = "top", sub = NULL, csub = 2, ...)
d |
an object of class |
row.w |
an optional distance matrix row weights. If not NULL, must be a vector of positive numbers with length equal to the size of the distance matrix |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
full |
a logical value indicating whether all the axes should be kept |
tol |
a tolerance threshold to test whether the distance matrix is Euclidean :
an eigenvalue is considered positive if it is larger than
|
x |
an object of class |
xax |
the column number for the x-axis |
yax |
the column number for the y-axis |
clab.row |
a character size for the row labels |
posieig |
if "top" the eigenvalues bar plot is upside, if "bottom" it is downside, if "none" no plot |
sub |
a string of characters to be inserted as legend |
csub |
a character size for the legend, used with |
... |
further arguments passed to or from other methods |
dudi.pco
returns a list of class pco
and dudi
. See dudi
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Gower, J. C. (1966) Some distance properties of latent root and vector methods used in multivariate analysis. Biometrika, 53, 325–338.
data(yanomama) gen <- quasieuclid(as.dist(yanomama$gen)) geo <- quasieuclid(as.dist(yanomama$geo)) ant <- quasieuclid(as.dist(yanomama$ant)) geo1 <- dudi.pco(geo, scann = FALSE, nf = 3) gen1 <- dudi.pco(gen, scann = FALSE, nf = 3) ant1 <- dudi.pco(ant, scann = FALSE, nf = 3) plot(coinertia(ant1, gen1, scann = FALSE))
data(yanomama) gen <- quasieuclid(as.dist(yanomama$gen)) geo <- quasieuclid(as.dist(yanomama$geo)) ant <- quasieuclid(as.dist(yanomama$ant)) geo1 <- dudi.pco(geo, scann = FALSE, nf = 3) gen1 <- dudi.pco(gen, scann = FALSE, nf = 3) ant1 <- dudi.pco(ant, scann = FALSE, nf = 3) plot(coinertia(ant1, gen1, scann = FALSE))
dunedata
is a data set containing for 20 sites, environmental variables and plant species.
data(dunedata)
data(dunedata)
dunedata
is a list with 2 components.
is a data frame with 20 rows (sites) 5 columns (environnemental variables).
is a data frame with 20 rows (sites) 30 columns (plant species).
Jongman, R. H., ter Braak, C. J. F. and van Tongeren, O. F. R. (1987) Data analysis in community and landscape ecology, Pudoc, Wageningen.
data(dunedata) summary(dunedata$envir) is.ordered(dunedata$envir$use) score(dudi.mix(dunedata$envir, scan = FALSE))
data(dunedata) summary(dunedata$envir) is.ordered(dunedata$envir$use) score(dudi.mix(dunedata$envir, scan = FALSE))
These data were measured during the normal sinus rhythm of a patient who occasionally experiences arrhythmia. There are 2048 observations measured in units of millivolts and collected at a rate of 180 samples per second. This time series is a good candidate for a multiresolution analysis because its components are on different scales. For example, the large scale (low frequency) fluctuations, known as baseline drift, are due to the patient respiration, while the prominent short scale (high frequency) intermittent fluctuations between 3 and 4 seconds are evidently due to patient movement. Heart rhythm determines most of the remaining features in the series. The large spikes occurring about 0.7 seconds apart the R waves of normal heart rhythm; the smaller, but sharp peak coming just prior to an R wave is known as a P wave; and the broader peak that comes after a R wave is a T wave.
data(ecg)
data(ecg)
A vector of class ts
containing 2048 observations.
Gust Bardy and Per Reinhall, University of Washington
Percival, D. B., and Walden, A.T. (2000) Wavelet Methods for Time Series Analysis, Cambridge University Press.
## Not run: # figure 130 in Percival and Walden (2000) if (requireNamespace("waveslim") == TRUE) { data(ecg) ecg.level <- haar2level(ecg) ecg.haar <- orthobasis.haar(length(ecg)) ecg.mld <- mld(ecg, ecg.haar, ecg.level, plot = FALSE) res <- cbind.data.frame(apply(ecg.mld[,1:5],1,sum), ecg.mld[,6:11]) par(mfrow = c(8,1)) par(mar = c(2, 5, 1.5, 0.6)) plot(as.ts(ecg), ylab = "ECG") apply(res, 2, function(x) plot(as.ts(x), ylim = range(res), ylab = "")) par(mfrow = c(1,1)) } ## End(Not run)
## Not run: # figure 130 in Percival and Walden (2000) if (requireNamespace("waveslim") == TRUE) { data(ecg) ecg.level <- haar2level(ecg) ecg.haar <- orthobasis.haar(length(ecg)) ecg.mld <- mld(ecg, ecg.haar, ecg.level, plot = FALSE) res <- cbind.data.frame(apply(ecg.mld[,1:5],1,sum), ecg.mld[,6:11]) par(mfrow = c(8,1)) par(mar = c(2, 5, 1.5, 0.6)) plot(as.ts(ecg), ylab = "ECG") apply(res, 2, function(x) plot(as.ts(x), ylim = range(res), ylab = "")) par(mfrow = c(1,1)) } ## End(Not run)
This data set gives ecomorphological informations about 129 bird species.
data(ecomor)
data(ecomor)
ecomor
is a list of 7 components.
is a data frame with 129 species, 6 variables (the feeding place classes): foliage, ground , twig , bush, trunk and aerial feeders. These dummy variables indicate the use (1) or no use (0) of a given feeding place by a species.
is a data frame with 129 species and 8 variables (diet types): Gr (granivorous: seeds), Fr (frugivorous: berries, acorns, drupes), Ne (frugivorous: nectar), Fo (folivorous: leaves), In (invertebrate feeder: insects, spiders, myriapods, isopods, snails, worms), Ca (carnivorous: flesh of small vertebrates), Li (limnivorous: invertebrates in fresh water), and Ch (carrion feeder). These dummy variables indicate the use (1) or no use (0) of a given diet type by a species.
is a data frame with 129 species, 16 dummy variables (the habitats). These variables indicate the species presence (1) or the species absence (0) in a given habitat.
is a data frame with 129 species abd 8 morphological variables: wingl (Wing length, mm), taill (Tail length, mm), culml (Culmen length, mm), bilh (Bill height, mm), bilw (Bill width, mm), tarsl (Tarsus length, mm), midtl (Middle toe length, mm) and weig (Weight, g).
is a data frame with 129 species and 3 factors: Genus, Family and Order.
It is a data frame of class 'taxo'
: the variables are factors giving nested classifications.
is a data frame with vectors of the names of species (complete and in abbreviated form.
is a data frame with 129 species, 2 factors : 'forsub' summarizing the feeding place and 'diet' the diet type.
Blondel, J., Vuilleumier, F., Marcus, L.F., and Terouanne, E. (1984). Is there ecomorphological convergence among mediterranean bird communities of Chile, California, and France. In Evolutionary Biology (eds M.K. Hecht, B. Wallace and R.J. MacIntyre), 141–213, 18. Plenum Press, New York.
See a data description at http://pbil.univ-lyon1.fr/R/pdf/pps023.pdf (in French).
data(ecomor) ric <- apply(ecomor$habitat, 2, sum) s.corcircle(dudi.pca(log(ecomor$morpho), scan = FALSE)$co) forsub <- data.frame(t(apply(ecomor$forsub, 1, function (x) x / sum(x)))) pca1 <- dudi.pca(forsub, scan = FALSE, scale = FALSE) w1 <- as.matrix(forsub) %*% as.matrix(pca1$c1) if(adegraphicsLoaded()) { g1 <- s.arrow(pca1$c1, plot = FALSE) g2 <- s.label(w1, plab.cex = 0, ppoi.cex = 2, plot = FALSE) G1 <- superpose(g1, g2, plot = TRUE) } else { s.arrow(pca1$c1) s.label(w1, clab = 0, add.p = TRUE, cpoi = 2) } diet <- data.frame(t(apply(ecomor$diet, 1, function (x) x / sum(x)))) pca2 <- dudi.pca(diet, scan = FALSE, scale = FALSE) w2 <- as.matrix(diet) %*% as.matrix(pca2$c1) if(adegraphicsLoaded()) { g3 <- s.arrow(pca2$c1, plot = FALSE) g4 <- s.label(w2, plab.cex = 0, ppoi.cex = 2, plot = FALSE) G2 <- superpose(g3, g4, plot = TRUE) } else { s.arrow(pca2$c1) s.label(w2, clab = 0, add.p = TRUE, cpoi = 2) } ## Not run: dmorpho <- dist.quant(log(ecomor$morpho), 3) dhabitat <- dist.binary(ecomor$habitat, 1) dtaxo <- dist.taxo(ecomor$taxo) mantel.randtest(dmorpho, dhabitat) RV.rtest(pcoscaled(dmorpho), pcoscaled(dhabitat), 999) procuste.randtest(pcoscaled(dmorpho), pcoscaled(dhabitat)) ecophy <- taxo2phylog(ecomor$taxo, add.tools=TRUE) table.phylog(ecomor$habitat, ecophy, clabel.n = 0.5, f = 0.6, clabel.c = 0.75, clabel.r = 0.5, csi = 0.75, cleg = 0) plot(ecophy, clabel.n = 0.75, clabel.l = 0.75, labels.l = ecomor$labels[,"latin"]) mantel.randtest(dmorpho, dtaxo) mantel.randtest(dhabitat, dtaxo) ## End(Not run)
data(ecomor) ric <- apply(ecomor$habitat, 2, sum) s.corcircle(dudi.pca(log(ecomor$morpho), scan = FALSE)$co) forsub <- data.frame(t(apply(ecomor$forsub, 1, function (x) x / sum(x)))) pca1 <- dudi.pca(forsub, scan = FALSE, scale = FALSE) w1 <- as.matrix(forsub) %*% as.matrix(pca1$c1) if(adegraphicsLoaded()) { g1 <- s.arrow(pca1$c1, plot = FALSE) g2 <- s.label(w1, plab.cex = 0, ppoi.cex = 2, plot = FALSE) G1 <- superpose(g1, g2, plot = TRUE) } else { s.arrow(pca1$c1) s.label(w1, clab = 0, add.p = TRUE, cpoi = 2) } diet <- data.frame(t(apply(ecomor$diet, 1, function (x) x / sum(x)))) pca2 <- dudi.pca(diet, scan = FALSE, scale = FALSE) w2 <- as.matrix(diet) %*% as.matrix(pca2$c1) if(adegraphicsLoaded()) { g3 <- s.arrow(pca2$c1, plot = FALSE) g4 <- s.label(w2, plab.cex = 0, ppoi.cex = 2, plot = FALSE) G2 <- superpose(g3, g4, plot = TRUE) } else { s.arrow(pca2$c1) s.label(w2, clab = 0, add.p = TRUE, cpoi = 2) } ## Not run: dmorpho <- dist.quant(log(ecomor$morpho), 3) dhabitat <- dist.binary(ecomor$habitat, 1) dtaxo <- dist.taxo(ecomor$taxo) mantel.randtest(dmorpho, dhabitat) RV.rtest(pcoscaled(dmorpho), pcoscaled(dhabitat), 999) procuste.randtest(pcoscaled(dmorpho), pcoscaled(dhabitat)) ecophy <- taxo2phylog(ecomor$taxo, add.tools=TRUE) table.phylog(ecomor$habitat, ecophy, clabel.n = 0.5, f = 0.6, clabel.c = 0.75, clabel.r = 0.5, csi = 0.75, cleg = 0) plot(ecophy, clabel.n = 0.75, clabel.l = 0.75, labels.l = ecomor$labels[,"latin"]) mantel.randtest(dmorpho, dtaxo) mantel.randtest(dhabitat, dtaxo) ## End(Not run)
This data set gives the results of the presidential election in France in 1988 for each department and all the candidates.
data(elec88)
data(elec88)
elec88
is a list with the following components:
a data frame with 94 rows (departments) and 9 variables (candidates)
the global result of the election all-over the country
a data frame with two variables: elec88$lab$dep
is a
vector containing the names of the 94 french departments,
elec88$lab$reg
is a vector containing the names of the
21 French administrative regions.
the data frame of 3 variables returning the boundary lines of each department.
The first variable is a factor. The levels of this one are the row.names of tab
.
The second and third variables return the coordinates (x, y) of the points of the boundary line.
a data frame with 4 variables (x1, y1, x2, y2) for the contour display of France
a data frame with two variables (x, y) giving the position of the center for each department
the neighbouring graph between departments, object of the class nb
the map of the french departments in Lambert II coordinates
(an object of the class SpatialPolygons
of sp
)
the contour of the map of France in Lambert II
coordinates (an object of the class SpatialPolygons
of sp
)
Public data
This dataset is compatible with presid2002
and cnc2003
data(elec88) apply(elec88$tab, 2, mean) summary(elec88$res) pca1 <- dudi.pca(elec88$tab, scale = FALSE, scannf = FALSE) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { data1 <- as.data.frame(as.numeric(rownames(elec88$tab) == "D25")) rownames(data1) <- row.names(elec88$Spatial) obj1 <- sp::SpatialPolygonsDataFrame(Sr = elec88$Spatial, data = data1) g1 <- s.Spatial(obj1, psub.text = "", plot = FALSE) g2 <- s.Spatial(obj1, psub.text = "", nb = elec88$nb, pnb.node.cex = 0, plot = FALSE) data3 <- as.data.frame(elec88$xy[, 1] + elec88$xy[, 2]) rownames(data3) <- row.names(elec88$Spatial) obj3 <- sp::SpatialPolygonsDataFrame(Sr = elec88$Spatial, data = data3) g3 <- s.Spatial(obj3, psub.text = "", plot = FALSE) data4 <- as.data.frame(pca1$li[, 1]) rownames(data4) <- row.names(elec88$Spatial) obj4 <- sp::SpatialPolygonsDataFrame(Sr = elec88$Spatial, data = data4) g4 <- s.Spatial(obj4, psub.text = "F1 PCA", plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } } else { par(mfrow = c(2, 2)) plot(elec88$area[, 2:3], type = "n", asp = 1) lpoly <- split(elec88$area[, 2:3], elec88$area[, 1]) lapply(lpoly, function(x) {points(x, type = "l"); invisible()}) polygon(elec88$area[elec88$area$V1 == "D25", 2:3], col = 1) area.plot(elec88$area, val = elec88$xy[, 1] + elec88$xy[, 2]) area.plot(elec88$area, val = pca1$li[, 1], sub = "F1 PCA", csub = 2, cleg = 1.5) par(mfrow = c(1, 1)) }
data(elec88) apply(elec88$tab, 2, mean) summary(elec88$res) pca1 <- dudi.pca(elec88$tab, scale = FALSE, scannf = FALSE) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { data1 <- as.data.frame(as.numeric(rownames(elec88$tab) == "D25")) rownames(data1) <- row.names(elec88$Spatial) obj1 <- sp::SpatialPolygonsDataFrame(Sr = elec88$Spatial, data = data1) g1 <- s.Spatial(obj1, psub.text = "", plot = FALSE) g2 <- s.Spatial(obj1, psub.text = "", nb = elec88$nb, pnb.node.cex = 0, plot = FALSE) data3 <- as.data.frame(elec88$xy[, 1] + elec88$xy[, 2]) rownames(data3) <- row.names(elec88$Spatial) obj3 <- sp::SpatialPolygonsDataFrame(Sr = elec88$Spatial, data = data3) g3 <- s.Spatial(obj3, psub.text = "", plot = FALSE) data4 <- as.data.frame(pca1$li[, 1]) rownames(data4) <- row.names(elec88$Spatial) obj4 <- sp::SpatialPolygonsDataFrame(Sr = elec88$Spatial, data = data4) g4 <- s.Spatial(obj4, psub.text = "F1 PCA", plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } } else { par(mfrow = c(2, 2)) plot(elec88$area[, 2:3], type = "n", asp = 1) lpoly <- split(elec88$area[, 2:3], elec88$area[, 1]) lapply(lpoly, function(x) {points(x, type = "l"); invisible()}) polygon(elec88$area[elec88$area$V1 == "D25", 2:3], col = 1) area.plot(elec88$area, val = elec88$xy[, 1] + elec88$xy[, 2]) area.plot(elec88$area, val = pca1$li[, 1], sub = "F1 PCA", csub = 2, cleg = 1.5) par(mfrow = c(1, 1)) }
This data set describes 27 characteristics of 21 wines distributed in four fields : rest, visual, olfactory and global.
data(escopage)
data(escopage)
escopage
is a list of 3 components.
is a data frame with 21 observations (wines) and 27 variables.
is the vector of the names of sub-tables : "rest" "visual" "olfactory" "global".
is a vector of the numbers of variables for each sub-table.
Escofier, B. and Pagès, J. (1990) Analyses factorielles simples et multiples : objectifs, méthodes et interprétation Dunod, Paris. 1–267.
Escofier, B. and Pagès, J. (1994) Multiple factor analysis (AFMULT package). Computational Statistics and Data Analysis, 18, 121–140.
data(escopage) w <- data.frame(scale(escopage$tab)) w <- ktab.data.frame(w, escopage$blo) names(w)[1:4] <- escopage$tab.names plot(mfa(w, scan = FALSE))
data(escopage) w <- data.frame(scale(escopage$tab)) w <- ktab.data.frame(w, escopage$blo) names(w)[1:4] <- escopage$tab.names plot(mfa(w, scan = FALSE))
This data set gives the proportions of employement in the primary, secondary and tertiary sectors for 12 European countries in 1978, 1986 and 1997.
data(euro123)
data(euro123)
euro123
is a list of 4 components.
is a data frame with 12 rows and 3 variables.
: idem in 1986
: idem in 1997
is a data frame with two factors to both organize the 3 tables.
Encyclopaedia Universalis, Symposium, Les chiffres du Monde. Encyclopaedia Universalis, Paris. 519.
data(euro123) if(adegraphicsLoaded()) { g1 <- triangle.label(euro123$in78, addaxes = TRUE, plabels.cex = 0, plot = FALSE) g2 <- triangle.label(euro123$in86, addaxes = TRUE, plabels.cex = 0, plot = FALSE) g3 <- triangle.label(euro123$in97, addaxes = TRUE, plabels.cex = 0, plot = FALSE) g4 <- triangle.match(euro123$in78, euro123$in97, plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2,2)) triangle.plot(euro123$in78, addaxes = TRUE) triangle.plot(euro123$in86, addaxes = TRUE) triangle.plot(euro123$in97, addaxes = TRUE) triangle.biplot(euro123$in78, euro123$in97) par(mfrow = c(1,1)) }
data(euro123) if(adegraphicsLoaded()) { g1 <- triangle.label(euro123$in78, addaxes = TRUE, plabels.cex = 0, plot = FALSE) g2 <- triangle.label(euro123$in86, addaxes = TRUE, plabels.cex = 0, plot = FALSE) g3 <- triangle.label(euro123$in97, addaxes = TRUE, plabels.cex = 0, plot = FALSE) g4 <- triangle.match(euro123$in78, euro123$in97, plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } else { par(mfrow = c(2,2)) triangle.plot(euro123$in78, addaxes = TRUE) triangle.plot(euro123$in86, addaxes = TRUE) triangle.plot(euro123$in97, addaxes = TRUE) triangle.biplot(euro123$in78, euro123$in97) par(mfrow = c(1,1)) }
This data set contains the mean values of five highly heritable linear combinations of cranial metric (GM1-GM3) and non metric (GN1-GN2) for 8 social groups of Rhesus Macaques on Cayo Santiago. It also describes the fission tree depicting the historical phyletic relationships.
data(fission)
data(fission)
fission
is a list containing the 2 following objects :
is a character string giving the fission tree in Newick format.
is a data frame with 8 social groups and five traits : cranial metrics (GM1, GM2, GM3) and cranial non metrics (GN1, GN2)
Cheverud, J. and Dow, M.M. (1985) An autocorrelation analysis of genetic variation due to lineal fission in social groups of rhesus macaques. American Journal of Physical Anthropology, 67, 113–122.
data(fission) fis.phy <- newick2phylog(fission$tre) table.phylog(fission$tab[names(fis.phy$leaves),], fis.phy, csi = 2) gearymoran(fis.phy$Amat, fission$tab)
data(fission) fis.phy <- newick2phylog(fission$tre) table.phylog(fission$tab[names(fis.phy$leaves),], fis.phy, csi = 2) gearymoran(fis.phy$Amat, fission$tab)
K tables have the same rows and the same columns.
Each table is transformed by P = X/sum(X). The average of P is computing.
A correspondence analysis is realized on this average.
The initial rows and the initial columns are projected in supplementary elements.
foucart(X, scannf = TRUE, nf = 2) ## S3 method for class 'foucart' plot(x, xax = 1, yax = 2, clab = 1, csub = 2, possub = "bottomright", ...) ## S3 method for class 'foucart' print(x, ...)
foucart(X, scannf = TRUE, nf = 2) ## S3 method for class 'foucart' plot(x, xax = 1, yax = 2, clab = 1, csub = 2, possub = "bottomright", ...) ## S3 method for class 'foucart' print(x, ...)
X |
a list of data frame where the row names and the column names are the same for each table |
scannf |
a logical value indicating whether the eigenvalues bar plot should be displayed |
nf |
if scannf FALSE, an integer indicating the number of kept axes |
x |
an object of class 'foucart' |
xax |
the column number of the x-axis |
yax |
the column number of the y-axis |
clab |
if not NULL, a character size for the labels, used with |
csub |
a character size for the legend, used with |
possub |
a string of characters indicating the sub-title position ("topleft", "topright", "bottomleft", "bottomright") |
... |
further arguments passed to or from other methods |
foucart
returns a list of the classes 'dudi', 'coa' and 'foucart'
call |
origine |
nf |
axes-components saved |
rank |
rank |
blo |
useful vector |
cw |
vector: column weights |
lw |
vector: row weights |
eig |
vector: eigen values |
tab |
data.frame: modified array |
li |
data.frame: row coordinates |
l1 |
data.frame: row normed scores |
co |
data.frame: column coordinates |
c1 |
data.frame: column normed scores |
Tli |
data.frame: row coordinates (each table) |
Tco |
data.frame: col coordinates (each table) |
TL |
data.frame: factors for Tli |
TC |
data.frame: factors for Tco |
Pierre Bady [email protected]
Anne-Béatrice Dufour [email protected]
Foucart, T. (1984) Analyse factorielle de tableaux multiples, Masson, Paris.
data(bf88) fou1 <- foucart(bf88, scann = FALSE, nf = 3) fou1 plot(fou1) data(meaudret) l1 <- split(meaudret$spe, meaudret$design$season) l1 <- lapply(l1, function(x) {row.names(x) <- paste("Sit",1:5,sep="");x}) fou2 <- foucart(l1, scan = FALSE) if(adegraphicsLoaded()) { kplot(fou2, row.plabels.cex = 2) } else { kplot(fou2, clab.r = 2) }
data(bf88) fou1 <- foucart(bf88, scann = FALSE, nf = 3) fou1 plot(fou1) data(meaudret) l1 <- split(meaudret$spe, meaudret$design$season) l1 <- lapply(l1, function(x) {row.names(x) <- paste("Sit",1:5,sep="");x}) fou2 <- foucart(l1, scan = FALSE) if(adegraphicsLoaded()) { kplot(fou2, row.plabels.cex = 2) } else { kplot(fou2, clab.r = 2) }
These functions allow to compute the fourth-corner statistic for abundance or presence-absence data. The fourth-corner statistic has been developed by Legendre et al (1997) and extended in Dray and Legendre (2008). The statistic measures the link between three tables: a table L (n x p) containing the abundances of p species at n sites, a second table R (n x m) containing the measurements of m environmental variables for the n sites, and a third table Q (p x s) describing s species traits for the p species.
fourthcorner(tabR, tabL, tabQ, modeltype = 6, nrepet = 999, tr01 = FALSE, p.adjust.method.G = p.adjust.methods, p.adjust.method.D = p.adjust.methods, p.adjust.D = c("global", "levels"), ...) fourthcorner2(tabR, tabL, tabQ, modeltype = 6, nrepet = 999, tr01 = FALSE, p.adjust.method.G = p.adjust.methods, ...) ## S3 method for class '4thcorner' print(x, varQ = 1:length(x$varnames.Q), varR = 1:length(x$varnames.R), stat = c("D", "D2"), ...) ## S3 method for class '4thcorner' summary(object,...) ## S3 method for class '4thcorner' plot(x, stat = c("D", "D2", "G"), type = c("table", "biplot"), xax = 1, yax = 2, x.rlq = NULL, alpha = 0.05, col = c("lightgrey", "red", "deepskyblue", "purple"), ...) fourthcorner.rlq(xtest, nrepet = 999, modeltype = 6, typetest = c("axes", "Q.axes", "R.axes"), p.adjust.method.G = p.adjust.methods, p.adjust.method.D = p.adjust.methods, p.adjust.D = c("global", "levels"), ...)
fourthcorner(tabR, tabL, tabQ, modeltype = 6, nrepet = 999, tr01 = FALSE, p.adjust.method.G = p.adjust.methods, p.adjust.method.D = p.adjust.methods, p.adjust.D = c("global", "levels"), ...) fourthcorner2(tabR, tabL, tabQ, modeltype = 6, nrepet = 999, tr01 = FALSE, p.adjust.method.G = p.adjust.methods, ...) ## S3 method for class '4thcorner' print(x, varQ = 1:length(x$varnames.Q), varR = 1:length(x$varnames.R), stat = c("D", "D2"), ...) ## S3 method for class '4thcorner' summary(object,...) ## S3 method for class '4thcorner' plot(x, stat = c("D", "D2", "G"), type = c("table", "biplot"), xax = 1, yax = 2, x.rlq = NULL, alpha = 0.05, col = c("lightgrey", "red", "deepskyblue", "purple"), ...) fourthcorner.rlq(xtest, nrepet = 999, modeltype = 6, typetest = c("axes", "Q.axes", "R.axes"), p.adjust.method.G = p.adjust.methods, p.adjust.method.D = p.adjust.methods, p.adjust.D = c("global", "levels"), ...)
tabR |
a dataframe containing the measurements (numeric values or factors) of m environmental variables (columns) for the n sites (rows). |
tabL |
a dataframe containing the abundances of p species (columns) at n sites (rows). |
tabQ |
a dataframe containing numeric values or factors describing s species traits (columns) for the p species (rows). |
modeltype |
an integer (1-6) indicating the permutation model used in the testing procedure (see details). |
nrepet |
the number of permutations |
tr01 |
a logical indicating if data in |
object |
an object of the class 4thcorner |
x |
an object of the class 4thcorner |
varR |
a vector containing indices for variables in |
varQ |
a vector containing indices for variables in |
type |
results are represented by a table or on a biplot (see x.rlq) |
alpha |
a value of significance level |
p.adjust.method.G |
a string indicating a method for multiple
adjustment used for output tabG, see |
p.adjust.method.D |
a string indicating a method for multiple
adjustment used for output tabD/tabD2, see |
p.adjust.D |
a string indicating if multiple adjustment for tabD/tabD2 should be done globally or only between levels of a factor ("levels", as in the original paper of Legendre et al. 1997) |
stat |
a character to specify if results should be plotted for cells (D and D2) or variables (G) |
xax |
an integer indicating which rlq axis should be plotted on the x-axis |
yax |
an integer indicating which rlq axis should be plotted on the y-axis |
x.rlq |
an object created by the |
col |
a vector of length 4 containing four colors used for the
graphical representations. The first is used to represent non-significant
associations, the second positive significant, the third negative
significant. For the 'biplot' method and objects created by the
|
xtest |
an object created by the |
typetest |
a string indicating which tests should be performed |
... |
further arguments passed to or from other methods |
For the fourthcorner
function, the link is measured by a Pearson correlation coefficient for two quantitative variables (trait and environmental variable), by a Pearson Chi2 and G statistic for two qualitative variables and by a Pseudo-F and Pearson r for one quantitative variable and one qualitative variable. The fourthcorner2 function offers a multivariate statistic (equal to the sum of eigenvalues of RLQ analysis) and measures the link between two variables by a square correlation coefficient (quant/quant), a Chi2/sum(L) (qual/qual) and a correlation ratio (quant/qual). The significance is tested by a permutation procedure. Different models are available:
model 1 (modeltype
=1): Permute values for each species independently (i.e., permute within each column of table L)
model 2 (modeltype
=2): Permute values of sites (i.e., permute entire rows of table L)
model 3 (modeltype
=3): Permute values for each site independently (i.e., permute within each row of table L)
model 4 (modeltype
=4): Permute values of species (i.e., permute entire columns of table L)
model 5 (modeltype
=5): Permute values of species and after
(or before) permute values of sites (i.e., permute entire columns and
after (or before) entire rows of table L)
model 6 (modeltype
=6): combination of the outputs of models
2 and 4. Dray and Legendre (2008) and ter Braak et al. (20012) showed
that all models (except model 6) have inflated type I error.
Note that the model 5 is strictly equivalent to permuting simultaneously the rows of tables R and Q, as proposed by Doledec et al. (1996).
The function summary
returns results for variables (G). The
function print
returns results for cells (D and D2). In the case
of qualitative variables, Holm's corrected pvalues are also provided.
The function plot
produces a graphical representation of the
results (white for non significant, light grey for negative significant
and dark grey for positive significant relationships). Results can be
plotted for variables (G) or for cells (D and D2). In the case of
qualitative / quantitative association, homogeneity (D) or correlation
(D2) are plotted.
The fourthcorner
function returns a a list where:
tabD
is a krandtest
object giving the results of tests for cells of the fourth-corner (homogeneity for quant./qual.).
tabD2
is a krandtest
object giving the results of tests for cells of the fourth-corner (Pearson r for quant./qual.).
tabG
is a krandtest
object giving the results of tests for variables (Pearson's Chi2 for qual./qual.).
The fourthcorner2
function returns a list where:
tabG
is a krandtest
object giving the results of tests for variables.
trRLQ
is a krandtest
object giving the results of tests for the multivariate statistic (i.e. equivalent to randtest.rlq
function).
Stéphane Dray [email protected]
Doledec, S., Chessel, D., ter Braak, C.J.F. and Champely, S. (1996) Matching species traits to environmental variables: a new three-table ordination method. Environmental and Ecological Statistics, 3, 143–166.
Legendre, P., R. Galzin, and M. L. Harmelin-Vivien. (1997) Relating behavior to habitat: solutions to the fourth-corner problem. Ecology, 78, 547–562.
Dray, S. and Legendre, P. (2008) Testing the species traits-environment relationships: the fourth-corner problem revisited. Ecology, 89, 3400–3412.
ter Braak, C., Cormont, A., and Dray, S. (2012) Improved testing of species traits-environment relationships in the fourth corner problem. Ecology, 93, 1525–1526.
Dray, S., Choler, P., Doledec, S., Peres-Neto, P.R., Thuiller, W., Pavoine, S. and ter Braak, C.J.F (2014) Combining the fourth-corner and the RLQ methods for assessing trait responses to environmental variation. Ecology, 95, 14–21. doi:10.1890/13-0196.1
rlq
, combine.4thcorner
, p.adjust.methods
data(aviurba) ## Version using the sequential test (ter Braak et al 2012) ## as recommended in Dray et al (2013), ## using Holm correction of P-values (only 99 permutations here) four.comb.default <- fourthcorner(aviurba$mil,aviurba$fau,aviurba$traits,nrepet=99) summary(four.comb.default) plot(four.comb.default, stat = "G") ## using fdr correction of P-values four.comb.fdr <- fourthcorner(aviurba$mil, aviurba$fau, aviurba$traits, nrepet = 99, p.adjust.method.G = 'fdr', p.adjust.method.D = 'fdr') summary(four.comb.fdr) plot(four.comb.fdr, stat = "G") ## Explicit procedure to combine the results of two models ## proposed in Dray and Legendre (2008);the above does this implicitly four2 <- fourthcorner(aviurba$mil,aviurba$fau,aviurba$traits,nrepet=99,modeltype=2) four4 <- fourthcorner(aviurba$mil,aviurba$fau,aviurba$traits,nrepet=99,modeltype=4) four.comb <- combine.4thcorner(four2, four4) summary(four.comb) plot(four.comb, stat = "G")
data(aviurba) ## Version using the sequential test (ter Braak et al 2012) ## as recommended in Dray et al (2013), ## using Holm correction of P-values (only 99 permutations here) four.comb.default <- fourthcorner(aviurba$mil,aviurba$fau,aviurba$traits,nrepet=99) summary(four.comb.default) plot(four.comb.default, stat = "G") ## using fdr correction of P-values four.comb.fdr <- fourthcorner(aviurba$mil, aviurba$fau, aviurba$traits, nrepet = 99, p.adjust.method.G = 'fdr', p.adjust.method.D = 'fdr') summary(four.comb.fdr) plot(four.comb.fdr, stat = "G") ## Explicit procedure to combine the results of two models ## proposed in Dray and Legendre (2008);the above does this implicitly four2 <- fourthcorner(aviurba$mil,aviurba$fau,aviurba$traits,nrepet=99,modeltype=2) four4 <- fourthcorner(aviurba$mil,aviurba$fau,aviurba$traits,nrepet=99,modeltype=4) four.comb <- combine.4thcorner(four2, four4) summary(four.comb) plot(four.comb, stat = "G")
This data set gives informations about sites, species and environmental variables.
data(friday87)
data(friday87)
friday87
is a list of 4 components.
is a data frame containing a faunistic table with 16 sites and 91 species.
is a data frame with 16 sites and 11 environmental variables.
is a vector of the number of species per group.
is the name of each group of species.
Friday, L.E. (1987) The diversity of macroinvertebrate and macrophyte communities in ponds, Freshwater Biology, 18, 87–104.
data(friday87) wfri <- data.frame(scale(friday87$fau, scal = FALSE)) wfri <- ktab.data.frame(wfri, friday87$fau.blo, tabnames = friday87$tab.names) if(adegraphicsLoaded()) { g1 <- kplot(sepan(wfri), row.plabels.cex = 2) } else { kplot(sepan(wfri), clab.r = 2, clab.c = 1) }
data(friday87) wfri <- data.frame(scale(friday87$fau, scal = FALSE)) wfri <- ktab.data.frame(wfri, friday87$fau.blo, tabnames = friday87$tab.names) if(adegraphicsLoaded()) { g1 <- kplot(sepan(wfri), row.plabels.cex = 2) } else { kplot(sepan(wfri), clab.r = 2, clab.c = 1) }
28 batches of fruits -two types- are judged by two different ways.
They are classified in order of preference, without ex aequo, by 16 individuals.
15 quantitative variables described the batches of fruits.
data(fruits)
data(fruits)
fruits
is a list of 3 components:
is a vector returning the type of the 28 batches of fruits (peaches or nectarines).
is a data frame of 28 rows and 16 columns (judges).
is a data frame of 28 rows and 16 measures (average of 2 judgements).
fruits$var
is a data frame of 15 variables:
taches: quantity of cork blemishes (0=absent - maximum 5)
stries: quantity of stria (1/none - maximum 4)
abmucr: abundance of mucron (1/absent - 4)
irform: shape irregularity (0/none - 3)
allong: length of the fruit (1/round fruit - 4)
suroug: percentage of the red surface (minimum 40% - maximum 90%)
homlot: homogeneity of the intra-batch coloring (1/strong - 4)
homfru: homogeneity of the intra-fruit coloring (1/strong - 4)
pubesc: pubescence (0/none - 4)
verrou: intensity of green in red area (1/none - 4)
foncee: intensity of dark area (0/pink - 4)
comucr: intensity of the mucron color (1=no contrast - 4/dark)
impres: kind of impression (1/watched - 4/pointillé)
coldom: intensity of the predominating color (0/clear - 4)
calibr: grade (1/<90g - 5/>200g)
Kervella, J. (1991) Analyse de l'attrait d'un produit : exemple d'une comparaison de lots de pêches. Agro-Industrie et méthodes statistiques. Compte-rendu des secondes journées européennes. Nantes 13-14 juin 1991. Association pour la Statistique et ses Utilisations, Paris, 313–325.
data(fruits) pcajug <- dudi.pca(fruits$jug, scann = FALSE) pcavar <- dudi.pca(fruits$var, scann = FALSE) if(adegraphicsLoaded()) { g1 <- s.corcircle(pcajug$co, plot = FALSE) g2 <- s.class(pcajug$li, fac = fruits$type, plot = FALSE) g3 <- s.corcircle(pcavar$co, plot = FALSE) g4 <- s.class(pcavar$li, fac = fruits$type, plot = FALSE) G1 <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) G2 <- plot(coinertia(pcajug, pcavar, scan = FALSE)) } else { par(mfrow = c(2,2)) s.corcircle(pcajug$co) s.class(pcajug$li, fac = fruits$type) s.corcircle(pcavar$co) s.class(pcavar$li, fac = fruits$type) par(mfrow = c(1,1)) plot(coinertia(pcajug, pcavar, scan = FALSE)) }
data(fruits) pcajug <- dudi.pca(fruits$jug, scann = FALSE) pcavar <- dudi.pca(fruits$var, scann = FALSE) if(adegraphicsLoaded()) { g1 <- s.corcircle(pcajug$co, plot = FALSE) g2 <- s.class(pcajug$li, fac = fruits$type, plot = FALSE) g3 <- s.corcircle(pcavar$co, plot = FALSE) g4 <- s.class(pcavar$li, fac = fruits$type, plot = FALSE) G1 <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) G2 <- plot(coinertia(pcajug, pcavar, scan = FALSE)) } else { par(mfrow = c(2,2)) s.corcircle(pcajug$co) s.class(pcajug$li, fac = fruits$type) s.corcircle(pcavar$co) s.class(pcavar$li, fac = fruits$type) par(mfrow = c(1,1)) plot(coinertia(pcajug, pcavar, scan = FALSE)) }
This function performs Moran's I test using phylogenetic and spatial link matrix (binary or general). It uses neighbouring weights so Moran's I and Geary's c randomization tests are equivalent.
gearymoran(bilis, X, nrepet = 999, alter=c("greater", "less", "two-sided"))
gearymoran(bilis, X, nrepet = 999, alter=c("greater", "less", "two-sided"))
bilis |
: a n by n link matrix where n is the row number of X |
X |
: a data frame with continuous variables |
nrepet |
: number of random vectors for the randomization test |
alter |
a character string specifying the alternative hypothesis, must be one of "greater" (default), "less" or "two-sided" |
bilis
is a squared symmetric matrix which terms are all positive or null.
bilis
is firstly transformed in frequency matrix A by dividing it by the total sum of data matrix :
The neighbouring weights is defined by the matrix where
.
For each vector x of the data frame X, the test is based on the Moran statistic
where x is D-centred.
Returns an object of class krandtest
(randomization tests).
Sébastien Ollier [email protected]
Daniel Chessel
Cliff, A. D. and Ord, J. K. (1973) Spatial autocorrelation, Pion, London.
Thioulouse, J., Chessel, D. and Champely, S. (1995) Multivariate analysis of spatial patterns: a unified approach to local and global structures. Environmental and Ecological Statistics, 2, 1–14.
moran.test
and geary.test
for classical versions of Moran's test and Geary's one
# a spatial example data(mafragh) tab0 <- (as.data.frame(scalewt(mafragh$env))) bilis0 <- neig2mat(nb2neig(mafragh$nb)) gm0 <- gearymoran(bilis0, tab0, 999) gm0 plot(gm0, nclass = 20) ## Not run: # a phylogenetic example data(mjrochet) mjr.phy <- newick2phylog(mjrochet$tre) mjr.tab <- log(mjrochet$tab) gearymoran(mjr.phy$Amat, mjr.tab) gearymoran(mjr.phy$Wmat, mjr.tab) if(adegraphicsLoaded()) { g1 <- table.value(mjr.phy$Wmat, ppoints.cex = 0.35, nclass = 5, axis.text = list(cex = 0), plot = FALSE) g2 <- table.value(mjr.phy$Amat, ppoints.cex = 0.35, nclass = 5, axis.text = list(cex = 0), plot = FALSE) G <- cbindADEg(g1, g2, plot = TRUE) } else { par(mfrow = c(1, 2)) table.value(mjr.phy$Wmat, csi = 0.25, clabel.r = 0) table.value(mjr.phy$Amat, csi = 0.35, clabel.r = 0) par(mfrow = c(1, 1)) } ## End(Not run)
# a spatial example data(mafragh) tab0 <- (as.data.frame(scalewt(mafragh$env))) bilis0 <- neig2mat(nb2neig(mafragh$nb)) gm0 <- gearymoran(bilis0, tab0, 999) gm0 plot(gm0, nclass = 20) ## Not run: # a phylogenetic example data(mjrochet) mjr.phy <- newick2phylog(mjrochet$tre) mjr.tab <- log(mjrochet$tab) gearymoran(mjr.phy$Amat, mjr.tab) gearymoran(mjr.phy$Wmat, mjr.tab) if(adegraphicsLoaded()) { g1 <- table.value(mjr.phy$Wmat, ppoints.cex = 0.35, nclass = 5, axis.text = list(cex = 0), plot = FALSE) g2 <- table.value(mjr.phy$Amat, ppoints.cex = 0.35, nclass = 5, axis.text = list(cex = 0), plot = FALSE) G <- cbindADEg(g1, g2, plot = TRUE) } else { par(mfrow = c(1, 2)) table.value(mjr.phy$Wmat, csi = 0.25, clabel.r = 0) table.value(mjr.phy$Amat, csi = 0.35, clabel.r = 0) par(mfrow = c(1, 1)) } ## End(Not run)
This data set gives genetic relationships between Galapagos tortoises populations with 10 microsatellites.
data(ggtortoises)
data(ggtortoises)
ggtortoises
is a list with the following components:
a data frame designed to be used in the area.plot
function
a list of three pixmap icons representing the tortoises morphotypes
a data frame containing meta informations about populations
a data frame containing the coordinates of the island labels
a numeric vector giving the number of alleles by marker
a data frame containing the number of alleles by populations for 10 microsatellites
an object of the class SpatialPolygons
of sp
,
containing the map
M.C. Ciofi, C. Milinkovitch, J.P. Gibbs, A. Caccone, and J.R. Powell (2002) Microsatellite analysis of genetic divergence among populations of giant galapagos tortoises. Molecular Ecology 11: 2265-2283.
M.C. Ciofi, C. Milinkovitch, J.P. Gibbs, A. Caccone, and J.R. Powell (2002). Microsatellite analysis of genetic divergence among populations of giant galapagos tortoises. Molecular Ecology 11: 2265-2283.
See a data description at http://pbil.univ-lyon1.fr/R/pdf/pps069.pdf (in French).
if(requireNamespace("pixmap", quietly=TRUE)) { data(ggtortoises) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g1 <- s.logo(ggtortoises$pop, ggtortoises$ico[as.character(ggtortoises$pop$carap)], Sp = ggtortoises$Spatial, pbackground.col = "lightblue", pSp.col = "white", pgrid.draw = FALSE, ppoints.cex = 0.5) g1 <- s.label(ggtortoises$misc, pgrid.draw = FALSE, porigin.include = FALSE, paxes.draw = FALSE, add = TRUE) } } else { a1 <- ggtortoises$area area.plot(a1) rect(min(a1$x), min(a1$y), max(a1$x), max(a1$y), col = "lightblue") invisible(lapply(split(a1, a1$id), function(x) polygon(x[, -1], col = "white"))) s.label(ggtortoises$misc, grid = FALSE, include.ori = FALSE, addaxes = FALSE, add.p = TRUE) listico <- ggtortoises$ico[as.character(ggtortoises$pop$carap)] s.logo(ggtortoises$pop, listico, add.p = TRUE) } }
if(requireNamespace("pixmap", quietly=TRUE)) { data(ggtortoises) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g1 <- s.logo(ggtortoises$pop, ggtortoises$ico[as.character(ggtortoises$pop$carap)], Sp = ggtortoises$Spatial, pbackground.col = "lightblue", pSp.col = "white", pgrid.draw = FALSE, ppoints.cex = 0.5) g1 <- s.label(ggtortoises$misc, pgrid.draw = FALSE, porigin.include = FALSE, paxes.draw = FALSE, add = TRUE) } } else { a1 <- ggtortoises$area area.plot(a1) rect(min(a1$x), min(a1$y), max(a1$x), max(a1$y), col = "lightblue") invisible(lapply(split(a1, a1$id), function(x) polygon(x[, -1], col = "white"))) s.label(ggtortoises$misc, grid = FALSE, include.ori = FALSE, addaxes = FALSE, add.p = TRUE) listico <- ggtortoises$ico[as.character(ggtortoises$pop$carap)] s.logo(ggtortoises$pop, listico, add.p = TRUE) } }
This data set gives the repartition in diameter classes of deposit samples.
data(granulo)
data(granulo)
granulo
is a list of 2 components.
contains the 49 deposit samples, 9 diameter classes, weight of grains by size class
contains the boundaries of the diameter classes
Gaschignard-Fossati, O. (1986) Répartition spatiale des macroinvertébrés benthiques d'un bras vif du Rhône. Rôle des crues et dynamique saisonnière. Thèse de doctorat, Université Lyon 1.
data(granulo) w <- t(apply(granulo$tab, 1, function (x) x / sum(x))) w <- data.frame(w) wtr <- data.frame(t(w)) wmoy <- data.frame(matrix(apply(wtr, 1, mean), 1)) d1 <- dudi.pca(w, scal = FALSE, scan = FALSE) wmoy <- suprow(d1, wmoy)$lisup if(adegraphicsLoaded()) { s.arrow(d1$c1, plab.cex = 1.5) s.distri(d1$c1, wtr, starSize = 0.33, ellipseSize = 0, add = TRUE, plab.cex = 0.75) s.label(wmoy, ppoints.cex = 5, plab.cex = 0, add = TRUE) } else { s.arrow(d1$c1, clab = 1.5) s.distri(d1$c1, wtr, cstar = 0.33, cell = 0, axesell = FALSE, add.p = TRUE, clab = 0.75) s.label(wmoy, cpoi = 5, clab = 0, add.p = TRUE) }
data(granulo) w <- t(apply(granulo$tab, 1, function (x) x / sum(x))) w <- data.frame(w) wtr <- data.frame(t(w)) wmoy <- data.frame(matrix(apply(wtr, 1, mean), 1)) d1 <- dudi.pca(w, scal = FALSE, scan = FALSE) wmoy <- suprow(d1, wmoy)$lisup if(adegraphicsLoaded()) { s.arrow(d1$c1, plab.cex = 1.5) s.distri(d1$c1, wtr, starSize = 0.33, ellipseSize = 0, add = TRUE, plab.cex = 0.75) s.label(wmoy, ppoints.cex = 5, plab.cex = 0, add = TRUE) } else { s.arrow(d1$c1, clab = 1.5) s.distri(d1$c1, wtr, cstar = 0.33, cell = 0, axesell = FALSE, add.p = TRUE, clab = 0.75) s.label(wmoy, cpoi = 5, clab = 0, add.p = TRUE) }
This function defines objects to analyse data sets associated with complete regular grid.
gridrowcol(nrow, ncol, cell.names = NULL)
gridrowcol(nrow, ncol, cell.names = NULL)
nrow |
size of the grid (number of rows) |
ncol |
size of the grid (number of columns) |
cell.names |
grid cell labels |
Returns a list containing the following items :
xy |
: a data frame with grid cell coordinates |
area |
: a data frame with three variables to display grid cells as areas |
neig |
: an object of class |
orthobasis |
: an object of class |
Sébastien Ollier [email protected]
Daniel Chessel
Méot, A., Chessel, D. and Sabatier, D. (1993) Opérateurs de voisinage et analyse des données spatio-temporelles. in J.D. Lebreton and B. Asselain, editors. Biométrie et environnement. Masson, 45-72.
Cornillon, P.A. (1998) Prise en compte de proximités en analyse factorielle et comparative. Thèse, Ecole Nationale Supérieure Agronomique, Montpellier.
w <- gridrowcol(8, 5) par(mfrow = c(1, 2)) area.plot(w$area, center = w$xy, graph = w$neig, clab = 0.75) area.plot(w$area, center = w$xy, graph = w$neig, clab = 0.75, label = as.character(1:40)) par(mfrow = c(1, 1)) if(adegraphicsLoaded()) { fac1 <- w$orthobasis names(fac1) <- as.character(signif(attr(w$orthobasis, "values"), 3)) s.value(w$xy, fac1, porigin.include = FALSE, plegend.drawKey = FALSE, pgrid.text.cex = 0, ylim = c(0, 10)) } else { par(mfrow = c(5,8)) for(k in 1:39) s.value(w$xy, w$orthobasis[, k], csi = 3, cleg = 0, csub = 2, sub = as.character(signif(attr(w$orthobasis, "values")[k], 3)), incl = FALSE, addax = FALSE, cgr = 0, ylim = c(0,10)) par(mfrow = c(1,1)) }
w <- gridrowcol(8, 5) par(mfrow = c(1, 2)) area.plot(w$area, center = w$xy, graph = w$neig, clab = 0.75) area.plot(w$area, center = w$xy, graph = w$neig, clab = 0.75, label = as.character(1:40)) par(mfrow = c(1, 1)) if(adegraphicsLoaded()) { fac1 <- w$orthobasis names(fac1) <- as.character(signif(attr(w$orthobasis, "values"), 3)) s.value(w$xy, fac1, porigin.include = FALSE, plegend.drawKey = FALSE, pgrid.text.cex = 0, ylim = c(0, 10)) } else { par(mfrow = c(5,8)) for(k in 1:39) s.value(w$xy, w$orthobasis[, k], csi = 3, cleg = 0, csub = 2, sub = as.character(signif(attr(w$orthobasis, "values")[k], 3)), incl = FALSE, addax = FALSE, cgr = 0, ylim = c(0,10)) par(mfrow = c(1,1)) }
This data set gives genotypes variation of 1066 individuals belonging to 52 predefined populations, for 404 microsatellite markers.
data(hdpg)
data(hdpg)
hdpg
is a list of 3 components.
is a data frame with the genotypes of 1066 individuals encoded with 6 characters (individuals in row, locus in column), for example ‘123098’ for a heterozygote carrying alleles ‘123’ and ‘098’, ‘123123’ for a homozygote carrying two alleles ‘123’ and, ‘000000’ for a not classified locus (missing data).
is a a data frame with 4 columns containing information about the 1066 individuals:
hdpg$ind$id
containing the Diversity Panel identification number of each individual,
and three factors hdpg$ind$sex
, hdpg$ind$population
and hdpg$ind$region
containing the names of the 52 populations belonging to 7 major geographic regions (see details).
is a dataframe containing four columns: hdpg$locus$marknames
a vector of names of the microsatellite markers, hdpg$locus$allbyloc
a vector containing the number of alleles by loci, hdpg$locus$chromosome
a factor defining a number for one chromosome and,
hdpg$locus$maposition
indicating the position of the locus in the chromosome.
The rows of hdpg$pop
are the names of the 52 populations belonging to the geographic regions
contained in the rows of hdpg$region
. The chosen regions are: America, Asia, Europe,
Middle East North Africa, Oceania, Subsaharan AFRICA.
The 52 populations are: Adygei, Balochi, Bantu, Basque, Bedouin, Bergamo, Biaka Pygmies,
Brahui, Burusho, Cambodian, Columbian, Dai, Daur, Druze, French,
Han, Hazara, Hezhen, Japanese, Kalash, Karitiana, Lahu, Makrani, Mandenka, Maya,
Mbuti Pygmies, Melanesian, Miaozu, Mongola, Mozabite, Naxi, NewGuinea, Nilote, Orcadian,
Oroqen, Palestinian, Pathan, Pima, Russian, San, Sardinian, She, Sindhi, Surui, Tu, Tujia, Tuscan,
Uygur, Xibo, Yakut, Yizu, Yoruba.
hdpg$freq
is a data frame with 52 rows,
corresponding to the 52 populations described above, and 4992 microsatellite markers.
Extract of data prepared by the Human Diversity Panel Genotypes (invalid http://research.marshfieldclinic.org/genetics/Freq/FreqInfo.htm)
prepared by Hinda Haned, from data used in: Noah A. Rosenberg, Jonatahan K. Pritchard, James L. Weber, Howard M. Cabb, Kenneth K. Kidds, Lev A. Zhivotovsky, Marcus W. Feldman (2002) Genetic Structure of human Populations Science, 298, 2381–2385.
Lev A. Zhivotovsky, Noah Rosenberg, and Marcus W. Feldman (2003). Features of Evolution and Expansion of Modern Humans, Inferred from Genomewide Microsatellite Markers Am. J. Hum. Genet, 72, 1171–1186.
data(hdpg) names(hdpg) str(hdpg)
data(hdpg) names(hdpg) str(hdpg)
Morphometric data set describing the shape of the first upper molar in populations of the Western European house mouse (Mus musculus domesticus)
data(houmousr)
data(houmousr)
houmousr
is a list with 2 components.
is a data frame with 214 rows (mice) and 128 morphometric variables.
is a factor giving the sampling location of the 214 mice.
The rows of houmousr$dfcc
correspond to 214 mice sampled in five locations in France and Italy. The 128 columns are 128 aligned coordinates describing the shape of the occlusal surface of the first upper molar (UM1).
houmousr$faccc
is a factor giving the location where mice were sampled: Montpellier, Frontignan, Gardouch (South of France), Lombardy (Northern Italy), and Corsica.
Thioulouse, J., Renaud, S., Dufour, AB. et al. Overcoming the Spurious Groups Problem in Between-Group PCA. Evol Biol (2021). https://doi.org/10.1007/s11692-021-09550-0
Renaud S, Pantalacci S, Auffray J (2011) Differential evolvability along lines of least resistance of upper and lower molars in island house mice. PLoS ONE 6, https://doi.org/10.1371/journal.pone.0018951
Renaud S, Dufour A, Hardouin E, Ledevin R, Auffray J (2015) Once upon multivariate analyses: when they tell several stories about biological evolution. PLoS ONE 10, https://doi.org/10.1371/journal.pone.0132801
Renaud S, Ledevin R, Souquet L, Gomes Rodrigues H, Ginot S, Agret S, Claude J, Herrel A, Hautier L (2018) Evolving teeth within a stable masticatory apparatus in Orkney mice. Evolutionary Biology 45:405–424
data(houmousr) fac1 <- houmousr$faccc df1 <- houmousr$dfcc nf1 <- nlevels(fac1) - 1 # Compute PCA pca1 <- dudi.pca(df1, scale = FALSE, scannf = FALSE, nf = nf1) # Compute BGA bca1 <- bca(pca1, fac1, scannf = FALSE, nf = nf1) if(adegraphicsLoaded()) { s.class(bca1$ls, fac1, starSize = 0, chullSize = 1, ellipseSize = 0, ppoint.cex = 0, plabel.cex = 0, plegend.drawKey = FALSE, col = TRUE) s.class(bca1$ls, fac1, starSize = 1, ellipseSize = 0, col = TRUE, add = T) } else { col1 <- c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00") s.class(bca1$ls, fac1, cstar = 1, cellipse = 0, col = col1) s.chull(bca1$ls, fac1, optchull = 1, add.plot = TRUE, col = col1) } ## Not run: # Compute cross-validated coordinates xbca1 <- loocv(bca1) plot(xbca1) ## End(Not run)
data(houmousr) fac1 <- houmousr$faccc df1 <- houmousr$dfcc nf1 <- nlevels(fac1) - 1 # Compute PCA pca1 <- dudi.pca(df1, scale = FALSE, scannf = FALSE, nf = nf1) # Compute BGA bca1 <- bca(pca1, fac1, scannf = FALSE, nf = nf1) if(adegraphicsLoaded()) { s.class(bca1$ls, fac1, starSize = 0, chullSize = 1, ellipseSize = 0, ppoint.cex = 0, plabel.cex = 0, plegend.drawKey = FALSE, col = TRUE) s.class(bca1$ls, fac1, starSize = 1, ellipseSize = 0, col = TRUE, add = T) } else { col1 <- c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00") s.class(bca1$ls, fac1, cstar = 1, cellipse = 0, col = col1) s.chull(bca1$ls, fac1, optchull = 1, add.plot = TRUE, col = col1) } ## Not run: # Compute cross-validated coordinates xbca1 <- loocv(bca1) plot(xbca1) ## End(Not run)
The housetasks
data frame gives 13 housetasks and their repartition in the couple.
data(housetasks)
data(housetasks)
This data frame contains four columns : wife, alternating, husband and jointly. Each column is a numeric vector.
Kroonenberg, P. M. and Lombardo, R. (1999) Nonsymmetric correspondence analysis: a tool for analysing contingency tables with a dependence structure. Multivariate Behavioral Research, 34, 367–396
data(housetasks) nsc1 <- dudi.nsc(housetasks, scan = FALSE) if(adegraphicsLoaded()) { s.label(nsc1$c1, plab.cex = 1.25) s.arrow(nsc1$li, add = TRUE, plab.cex = 0.75) } else { s.label(nsc1$c1, clab = 1.25) s.arrow(nsc1$li, add.pl = TRUE, clab = 0.75) }
data(housetasks) nsc1 <- dudi.nsc(housetasks, scan = FALSE) if(adegraphicsLoaded()) { s.label(nsc1$c1, plab.cex = 1.25) s.arrow(nsc1$li, add = TRUE, plab.cex = 0.75) } else { s.label(nsc1$c1, clab = 1.25) s.arrow(nsc1$li, add.pl = TRUE, clab = 0.75) }
This data set gives the frequencies of haplotypes of mitochondrial DNA restriction data in ten populations all over the world.
It gives also distances among the haplotypes.
data(humDNAm)
data(humDNAm)
humDNAm
is a list of 3 components.
is an object of class dist
with 56 haplotypes.
These distances are computed by counting the number of differences in restriction sites between two haplotypes.
is a data frame with 56 haplotypes, 10 abundance variables (populations). These variables give the haplotype abundance in a given population.
is a data frame with 10 populations, 1 variable (classification). This variable gives the name of the continent in which a given population is located.
Excoffier, L., Smouse, P.E. and Quattro, J.M. (1992) Analysis of molecular variance inferred from metric distances among DNA haplotypes: application to human mitochondrial DNA restriction data. Genetics, 131, 479–491.
data(humDNAm) dpcoahum <- dpcoa(data.frame(t(humDNAm$samples)), sqrt(humDNAm$distances), scan = FALSE, nf = 2) plot(dpcoahum)
data(humDNAm) dpcoahum <- dpcoa(data.frame(t(humDNAm$samples)), sqrt(humDNAm$distances), scan = FALSE, nf = 2) plot(dpcoahum)
This data set gives informations between a faunistic array, the total number of sampling points made at each sampling occasion and the year of the sampling occasion.
data(ichtyo)
data(ichtyo)
ichtyo
is a list of 3 components.
is a faunistic array with 9 columns and 32 rows.
is a vector of the 32 sampling effort.
is a factor where the levels are the 10 years of the sampling occasion.
The value n(i,j) at the ith row and the jth column in tab
corresponds
to the number of sampling points of the ith sampling occasion (in eff
) that contains the jth species.
Dolédec, S., Chessel, D. and Olivier, J. M. (1995) L'analyse des correspondances décentrée: application aux peuplements ichtyologiques du haut-Rhône. Bulletin Français de la Pêche et de la Pisciculture, 336, 29–40.
data(ichtyo) dudi1 <- dudi.dec(ichtyo$tab, ichtyo$eff, scannf = FALSE) s.class(dudi1$li, ichtyo$dat, wt = ichtyo$eff / sum(ichtyo$eff))
data(ichtyo) dudi1 <- dudi.dec(ichtyo$tab, ichtyo$eff, scannf = FALSE) s.class(dudi1$li, ichtyo$dat, wt = ichtyo$eff / sum(ichtyo$eff))
Computes the decomposition of inertia to measure the contributions of row and/or columns in multivariate methods
## S3 method for class 'dudi' inertia(x, row.inertia = FALSE, col.inertia = FALSE, ...) ## S3 method for class 'inertia' print(x, ...) ## S3 method for class 'inertia' summary(object, sort.axis = 1, subset = 5, ...)
## S3 method for class 'dudi' inertia(x, row.inertia = FALSE, col.inertia = FALSE, ...) ## S3 method for class 'inertia' print(x, ...) ## S3 method for class 'inertia' summary(object, sort.axis = 1, subset = 5, ...)
x , object
|
a duality diagram, object of class |
row.inertia |
if TRUE, returns the decomposition of inertia for the rows |
col.inertia |
if TRUE, returns the decomposition of inertia for the columns |
sort.axis |
the kept axis used to sort the contributions in decreasing order |
subset |
the number of rows and/or columns to display in the summary |
... |
further arguments passed to or from other methods |
Contributions are printed in percentage and the sign is the sign of the coordinates
An object of class inertia
, i.e. a list containing :
tot.inertia |
repartition of the total inertia between axes |
row.contrib |
contributions of the rows to the total inertia |
row.abs |
absolute contributions of the rows (i.e. decomposition per axis) |
row.rel |
relative contributions of the rows |
row.cum |
cumulative relative contributions of the rows (i.e. decomposition per row) |
col.contrib |
contributions of the columns to the total inertia |
col.abs |
absolute contributions of the columns (i.e. decomposition per axis) |
col.rel |
relative contributions of the columns |
col.cum |
cumulative relative contributions of the columns (i.e. decomposition per column) |
nf |
the number of kept axes |
Daniel Chessel
Stéphane Dray [email protected]
Anne-Béatrice Dufour [email protected]
Lebart, L., Morineau, A. and Tabart, N. (1977) Techniques de la description statistique, méthodes et logiciels pour la description des grands tableaux, Dunod, Paris, 61–62.
Volle, M. (1981) Analyse des données, Economica, Paris, 89–90 and 118
Lebart, L., Morineau, L. and Warwick, K.M. (1984) Multivariate descriptive analysis: correspondence and related techniques for large matrices, John Wiley and Sons, New York.
Greenacre, M. (1984) Theory and applications of correspondence analysis, Academic Press, London, 66.
Rouanet, H. and Le Roux, B. (1993) Analyse des données multidimensionnelles, Dunod, Paris, 143–144.
Tenenhaus, M. (1994) Méthodes statistiques en gestion, Dunod, Paris, p. 160, 161, 166, 204.
Lebart, L., Morineau, A. and Piron, M. (1995) Statistique exploratoire multidimensionnelle, Dunod, Paris, p. 56,95-96.
data(housetasks) coa1 <- dudi.coa(housetasks, scann = FALSE) res <- inertia(coa1, col = TRUE, row = FALSE) res summary(res)
data(housetasks) coa1 <- dudi.coa(housetasks, scann = FALSE) res <- inertia(coa1, col = TRUE, row = FALSE) res summary(res)
This data set contains geographical informations about 25 counties of Ireland.
data(irishdata)
data(irishdata)
irishdata
is a list of 13 components:
a data frame with polygons for each of the 25 contiguous counties
a vector with the names of the 25 counties
a data frame with the coordinates centers of the 25 counties
a data frame with 25 rows (counties) and 12 variables
a data frame with the global polygon of all the 25 counties
a matrix containing the common length between two counties
from area
a data frame with polygons for each of the 25 contiguous counties expressed in Universal Transverse Mercator (UTM) coordinates
a data frame with the UTM coordinates centers of the 25 counties
a matrix containing the common length between two counties
from area.utm
a data frame with the 25 counties (explicitly named) and 12 variables
a data frame with the global polygon of all the 25 counties expressed in UTM coordinates
the map of the 25 counties of Ireland (an object of the
class SpatialPolygons
of sp
)
the contour of the map of the 25 counties of
Ireland (an object of the class SpatialPolygons
of sp
)
Geary, R.C. (1954) The contiguity ratio and statistical mapping. The incorporated Statistician, 5, 3, 115–145.
Cliff, A.D. and Ord, J.K. (1973) Spatial autocorrelation, Pion, London. 1–178.
data(irishdata) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)){ g1 <- s.label(irishdata$xy.utm, Sp = irishdata$Spatial, pSp.col = "white", plot = FALSE) g21 <- s.label(irishdata$xy.utm, Sp = irishdata$Spatial, pSp.col = "white", plab.cex = 0, ppoints.cex = 0, plot = FALSE) g22 <- s.label(irishdata$xy.utm, Sp = irishdata$Spatial.contour, pSp.col = "transparent", plab.cex = 0, ppoints.cex = 0, pSp.lwd = 3, plot = FALSE) g2 <- superpose(g21, g22) g3 <- s.corcircle(dudi.pca(irishdata$tab, scan = FALSE)$co, plot = FALSE) score <- dudi.pca(irishdata$tab, scannf = FALSE, nf = 1)$li$Axis1 names(score) <- row.names(irishdata$Spatial) obj <- sp::SpatialPolygonsDataFrame(Sr = irishdata$Spatial, data = as.data.frame(score)) g4 <- s.Spatial(obj, plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } } else { par(mfrow = c(2, 2)) area.plot(irishdata$area, lab = irishdata$county.names, clab = 0.75) area.plot(irishdata$area) apply(irishdata$contour, 1, function(x) segments(x[1], x[2], x[3], x[4], lwd = 3)) s.corcircle(dudi.pca(irishdata$tab, scannf = FALSE)$co) score <- dudi.pca(irishdata$tab, scannf = FALSE, nf = 1)$li$Axis1 names(score) <- row.names(irishdata$tab) area.plot(irishdata$area, score) par(mfrow = c(1, 1)) }
data(irishdata) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)){ g1 <- s.label(irishdata$xy.utm, Sp = irishdata$Spatial, pSp.col = "white", plot = FALSE) g21 <- s.label(irishdata$xy.utm, Sp = irishdata$Spatial, pSp.col = "white", plab.cex = 0, ppoints.cex = 0, plot = FALSE) g22 <- s.label(irishdata$xy.utm, Sp = irishdata$Spatial.contour, pSp.col = "transparent", plab.cex = 0, ppoints.cex = 0, pSp.lwd = 3, plot = FALSE) g2 <- superpose(g21, g22) g3 <- s.corcircle(dudi.pca(irishdata$tab, scan = FALSE)$co, plot = FALSE) score <- dudi.pca(irishdata$tab, scannf = FALSE, nf = 1)$li$Axis1 names(score) <- row.names(irishdata$Spatial) obj <- sp::SpatialPolygonsDataFrame(Sr = irishdata$Spatial, data = as.data.frame(score)) g4 <- s.Spatial(obj, plot = FALSE) G <- ADEgS(list(g1, g2, g3, g4), layout = c(2, 2)) } } else { par(mfrow = c(2, 2)) area.plot(irishdata$area, lab = irishdata$county.names, clab = 0.75) area.plot(irishdata$area) apply(irishdata$contour, 1, function(x) segments(x[1], x[2], x[3], x[4], lwd = 3)) s.corcircle(dudi.pca(irishdata$tab, scannf = FALSE)$co) score <- dudi.pca(irishdata$tab, scannf = FALSE, nf = 1)$li$Axis1 names(score) <- row.names(irishdata$tab) area.plot(irishdata$area, score) par(mfrow = c(1, 1)) }
Confirmation of the Euclidean nature of a distance matrix by the Gower's theorem.is.euclid
is used in summary.dist
.
is.euclid(distmat, plot = FALSE, print = FALSE, tol = 1e-07) ## S3 method for class 'dist' summary(object, ...)
is.euclid(distmat, plot = FALSE, print = FALSE, tol = 1e-07) ## S3 method for class 'dist' summary(object, ...)
distmat |
an object of class 'dist' |
plot |
a logical value indicating whether the eigenvalues bar plot of the matrix of the term |
print |
a logical value indicating whether the eigenvalues of the matrix of the term |
tol |
a tolerance threshold : an eigenvalue is considered positive if it is larger than |
object |
an object of class 'dist' |
... |
further arguments passed to or from other methods |
returns a logical value indicating if all the eigenvalues are positive or equal to zero
Daniel Chessel
Stéphane Dray [email protected]
Gower, J.C. and Legendre, P. (1986) Metric and Euclidean properties of dissimilarity coefficients. Journal of Classification, 3, 5–48.
w <- matrix(runif(10000), 100, 100) w <- dist(w) summary(w) is.euclid (w) # TRUE w <- quasieuclid(w) # no correction need in: quasieuclid(w) w <- lingoes(w) # no correction need in: lingoes(w) w <- cailliez(w) # no correction need in: cailliez(w) rm(w)
w <- matrix(runif(10000), 100, 100) w <- dist(w) summary(w) is.euclid (w) # TRUE w <- quasieuclid(w) # no correction need in: quasieuclid(w) w <- lingoes(w) # no correction need in: lingoes(w) w <- cailliez(w) # no correction need in: cailliez(w) rm(w)
This data set gives the spatial distribution of seeds (quadrats counts) of seven species in the understorey of tropical rainforest.
data(julliot)
data(julliot)
julliot
is a list with the following components:
a data frame with 160 rows (quadrats) and 7 variables (species)
a data frame with the coordinates of the 160 quadrats (positioned by their centers)
a data frame with 3 variables returning the boundary lines of
each quadrat. The first variable is a factor. The levels of this one are
the row.names of tab
. The second and third variables return the
coordinates (x,y) of the points of the boundary line.
an object of the class SpatialPolygons
of sp
,
containing the map
Species names of julliot$tab
are:
Pouteria torta,
Minquartia guianensis,
Quiina obovata,
Chrysophyllum lucentifolium,
Parahancornia fasciculata,
Virola michelii,
and Pourouma spp.
Julliot, C. (1992). Utilisation des ressources alimentaires par le singe hurleur roux, Alouatta seniculus (Atelidae, Primates), en Guyane : impact de la dissémination des graines sur la régénération forestière. Thèse de troisième cycle, Université de Tours.
Julliot, C. (1997). Impact of seed dispersal by red howler monkeys Alouatta seniculus on the seedling population in the understorey of tropical rain forest. Journal of Ecology, 85, 431–440.
data(julliot) ## Not run: if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { obj1 <- sp::SpatialPolygonsDataFrame(Sr = julliot$Spatial, data = log(julliot$tab + 1)) g1 <- s.Spatial(obj1) g2 <- s.value(julliot$xy, scalewt(log(julliot$tab + 1)), Sp = julliot$Spatial, pSp.col = "white", pgrid.draw = FALSE) } } else { if(requireNamespace("splancs", quietly = TRUE)) { par(mfrow = c(3, 3)) for(k in 1:7) area.plot(julliot$area, val = log(julliot$tab[, k] + 1), sub = names(julliot$tab)[k], csub = 2.5) par(mfrow = c(1, 1)) par(mfrow = c(3, 3)) for(k in 1:7) { area.plot(julliot$area) s.value(julliot$xy, scalewt(log(julliot$tab[, k] + 1)), sub = names(julliot$tab)[k], csub = 2.5, add.p = TRUE) } par(mfrow = c(1, 1)) } } ## End(Not run) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g3 <- s.image(julliot$xy, log(julliot$tab + 1), span = 0.25) } g4 <- s.value(julliot$xy, log(julliot$tab + 1)) } else { if(requireNamespace("splancs", quietly = TRUE)) { par(mfrow = c(3, 3)) for(k in 1:7) s.image(julliot$xy, log(julliot$tab[, k] + 1), kgrid = 3, span = 0.25, sub = names(julliot$tab)[k], csub = 2.5) par(mfrow = c(1, 1)) par(mfrow = c(3, 3)) for(k in 1:7) s.value(julliot$xy, log(julliot$tab[, k] + 1), sub = names(julliot$tab)[k], csub = 2.5) par(mfrow = c(1, 1)) } } ## Not run: if (requireNamespace("spdep", quietly = TRUE)) { neig0 <- nb2neig(spdep::dnearneigh(as.matrix(julliot$xy), 1, 1.8)) if(adegraphicsLoaded()) { g5 <- s.label(julliot$xy, nb = spdep::dnearneigh(as.matrix(julliot$xy), 1, 1.8)) } else { par(mfrow = c(1, 1)) s.label(julliot$xy, neig = neig0, clab = 0.75, incl = FALSE, addax = FALSE, grid = FALSE) } gearymoran(ade4:::neig.util.LtoG(neig0), log(julliot$tab + 1)) if (requireNamespace("adephylo", quietly = TRUE)) { adephylo::orthogram(log(julliot$tab[, 3] + 1), ortho = scores.neig(neig0)) } } ## End(Not run)
data(julliot) ## Not run: if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { obj1 <- sp::SpatialPolygonsDataFrame(Sr = julliot$Spatial, data = log(julliot$tab + 1)) g1 <- s.Spatial(obj1) g2 <- s.value(julliot$xy, scalewt(log(julliot$tab + 1)), Sp = julliot$Spatial, pSp.col = "white", pgrid.draw = FALSE) } } else { if(requireNamespace("splancs", quietly = TRUE)) { par(mfrow = c(3, 3)) for(k in 1:7) area.plot(julliot$area, val = log(julliot$tab[, k] + 1), sub = names(julliot$tab)[k], csub = 2.5) par(mfrow = c(1, 1)) par(mfrow = c(3, 3)) for(k in 1:7) { area.plot(julliot$area) s.value(julliot$xy, scalewt(log(julliot$tab[, k] + 1)), sub = names(julliot$tab)[k], csub = 2.5, add.p = TRUE) } par(mfrow = c(1, 1)) } } ## End(Not run) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g3 <- s.image(julliot$xy, log(julliot$tab + 1), span = 0.25) } g4 <- s.value(julliot$xy, log(julliot$tab + 1)) } else { if(requireNamespace("splancs", quietly = TRUE)) { par(mfrow = c(3, 3)) for(k in 1:7) s.image(julliot$xy, log(julliot$tab[, k] + 1), kgrid = 3, span = 0.25, sub = names(julliot$tab)[k], csub = 2.5) par(mfrow = c(1, 1)) par(mfrow = c(3, 3)) for(k in 1:7) s.value(julliot$xy, log(julliot$tab[, k] + 1), sub = names(julliot$tab)[k], csub = 2.5) par(mfrow = c(1, 1)) } } ## Not run: if (requireNamespace("spdep", quietly = TRUE)) { neig0 <- nb2neig(spdep::dnearneigh(as.matrix(julliot$xy), 1, 1.8)) if(adegraphicsLoaded()) { g5 <- s.label(julliot$xy, nb = spdep::dnearneigh(as.matrix(julliot$xy), 1, 1.8)) } else { par(mfrow = c(1, 1)) s.label(julliot$xy, neig = neig0, clab = 0.75, incl = FALSE, addax = FALSE, grid = FALSE) } gearymoran(ade4:::neig.util.LtoG(neig0), log(julliot$tab + 1)) if (requireNamespace("adephylo", quietly = TRUE)) { adephylo::orthogram(log(julliot$tab[, 3] + 1), ortho = scores.neig(neig0)) } } ## End(Not run)
This data set gives physical and physico-chemical variables, fish species, spatial coordinates about 92 sites.
data(jv73)
data(jv73)
jv73
is a list with the following components:
a data frame with 92 sites and 6 physical variables
a data frame with 92 sites and 12 physico-chemical variables
a data frame with 92 sites and 19 fish species
a data frame with 92 sites and 2 spatial coordinates
a data frame for mapping
a factor distributing the 92 sites on 12 rivers
an object of the class SpatialLines
of sp
,
containing the map
Verneaux, J. (1973) Cours d'eau de Franche-Comté (Massif du Jura). Recherches écologiques sur le réseau hydrographique du Doubs. Essai de biotypologie. Thèse d'Etat, Besançon.
See a data description at http://pbil.univ-lyon1.fr/R/pdf/pps047.pdf (in French).
data(jv73) w <- split(jv73$morpho, jv73$fac.riv) w <- lapply(w, function(x) t(dudi.pca(x, scann = FALSE))) w <- ktab.list.dudi(w) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g11 <- s.label(jv73$xy, Sp = jv73$Spatial, pori.incl = FALSE, plab.cex = 0.75, plot = FALSE) g12 <- s.class(jv73$xy, jv73$fac.riv, ellipseSize = 0, pellipses.axes.draw = FALSE, starSize = 0, ppoints.cex = 0, plab.cex = 1.25, plot = FALSE) g1 <- superpose(g11, g12, plot = TRUE) g2 <- kplot(sepan(w), perm = TRUE, row.plab.cex = 0, posieig = "none") } } else { s.label(jv73$xy, contour = jv73$contour, incl = FALSE, clab = 0.75) s.class(jv73$xy, jv73$fac.riv, add.p = TRUE, cell = 0, axese = FALSE, csta = 0, cpoi = 0, clab = 1.25) kplot(sepan(w), perm = TRUE, clab.r = 0, clab.c = 2, show = FALSE) }
data(jv73) w <- split(jv73$morpho, jv73$fac.riv) w <- lapply(w, function(x) t(dudi.pca(x, scann = FALSE))) w <- ktab.list.dudi(w) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g11 <- s.label(jv73$xy, Sp = jv73$Spatial, pori.incl = FALSE, plab.cex = 0.75, plot = FALSE) g12 <- s.class(jv73$xy, jv73$fac.riv, ellipseSize = 0, pellipses.axes.draw = FALSE, starSize = 0, ppoints.cex = 0, plab.cex = 1.25, plot = FALSE) g1 <- superpose(g11, g12, plot = TRUE) g2 <- kplot(sepan(w), perm = TRUE, row.plab.cex = 0, posieig = "none") } } else { s.label(jv73$xy, contour = jv73$contour, incl = FALSE, clab = 0.75) s.class(jv73$xy, jv73$fac.riv, add.p = TRUE, cell = 0, axese = FALSE, csta = 0, cpoi = 0, clab = 1.25) kplot(sepan(w), perm = TRUE, clab.r = 0, clab.c = 2, show = FALSE) }
This data set contains informations about 33 ponds in De Maten reserve (Genk, Belgium).
data(kcponds)
data(kcponds)
kponds
is a list with the following components:
a data frame with 15 environmental variables (columns) on 33 ponds (rows)
an object of class area
a data frame with the coordinates of ponds
the neighbourhood graph of the 33 sites (an object of class nb
)
an object of the class SpatialPolygons
of sp
, containing the map
Variables of kcponds$tab
are the following ones : depth, area, O2 (oxygen concentration),
cond (conductivity), pH, Fe (Fe concentration), secchi (Secchi disk depth), N (NNO concentration),
TP (total phosphorus concentration), chla (chlorophyll-a concentration), EM (emergent macrophyte cover),
FM (floating macrophyte cover), SM (submerged macrophyte cover), denMI (total density of macroinvertebrates),
divMI (diversity macroinvertebrates)
Cottenie, K. (2002) Local and regional processes in a zooplankton metacommunity. PhD, Katholieke Universiteit Leuven, Leuven, Belgium.
data(kcponds) w <- as.numeric(scalewt(kcponds$tab$N)) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g1 <- s.label(kcponds$xy, Sp = kcponds$Spatial, pSp.col = "white", nb = kcponds$nb, plab.cex = 0, paxes.asp = "fill", plot = FALSE) g2 <- s.label(kcponds$xy, Sp = kcponds$Spatial, pSp.col = "white", plabels.cex = 0.8, paxes.asp = "fill", plot = FALSE) g3 <- s.value(kcponds$xy, w, psub.text = "Nitrogen concentration", paxe.asp = "fill", plot = FALSE) G <- rbindADEg(g1, g2, g3, plot = TRUE) } } else { par(mfrow = c(3, 1)) area.plot(kcponds$area) s.label(kcponds$xy, add.p = TRUE, cpoi = 2, clab = 0) s.label(kcponds$xy, add.p = TRUE, cpoi = 3, clab = 0) area.plot(kcponds$area) s.label(kcponds$xy, add.p = TRUE, clab = 1.5) s.value(kcponds$xy, w, cleg = 2, sub = "Nitrogen concentration", csub = 4, possub = "topright", include = FALSE) par(mfrow = c(1, 1)) } ## Not run: par(mfrow = c(3, 1)) pca1 <- dudi.pca(kcponds$tab, scan = FALSE, nf = 4) if(requireNamespace("spdep", quietly = TRUE) & requireNamespace("adespatial", quietly = TRUE)) { multi1 <- adespatial::multispati(pca1, spdep::nb2listw(kcponds$nb), scannf = FALSE, nfposi = 2, nfnega = 1) summary(multi1) } par(mfrow = c(1, 1)) ## End(Not run)
data(kcponds) w <- as.numeric(scalewt(kcponds$tab$N)) if(adegraphicsLoaded()) { if(requireNamespace("sp", quietly = TRUE)) { g1 <- s.label(kcponds$xy, Sp = kcponds$Spatial, pSp.col = "white", nb = kcponds$nb, plab.cex = 0, paxes.asp = "fill", plot = FALSE) g2 <- s.label(kcponds$xy, Sp = kcponds$Spatial, pSp.col = "white", plabels.cex = 0.8, paxes.asp = "fill", plot = FALSE) g3 <- s.value(kcponds$xy, w, psub.text = "Nitrogen concentration", paxe.asp = "fill", plot = FALSE) G <- rbindADEg(g1, g2, g3, plot = TRUE) } } else { par(mfrow = c(3, 1)) area.plot(kcponds$area) s.label(kcponds$xy, add.p = TRUE, cpoi = 2, clab = 0) s.label(kcponds$xy, add.p = TRUE, cpoi = 3, clab = 0) area.plot(kcponds$area) s.label(kcponds$xy, add.p = TRUE, clab = 1.5) s.value(kcponds$xy, w, cleg = 2, sub = "Nitrogen concentration", csub = 4, possub = "topright", include = FALSE) par(mfrow = c(1, 1)) } ## Not run: par(mfrow = c(3, 1)) pca1 <- dudi.pca(kcponds$tab, scan = FALSE, nf = 4) if(requireNamespace("spdep", quietly = TRUE) & requireNamespace("adespatial", quietly = TRUE)) { multi1 <- adespatial::multispati(pca1, spdep::nb2listw(kcponds$nb), scannf = FALSE, nfposi = 2, nfnega = 1) summary(multi1) } par(mfrow = c(1, 1)) ## End(Not run)
An object of class kdist
is a list of distance matrices observed on the same individuals
kdist(..., epsi = 1e-07, upper = FALSE)
kdist(..., epsi = 1e-07, upper = FALSE)
... |
a sequence of objects of the class |
epsi |
a tolerance threshold to test if distances are Euclidean (Gower's theorem) using |
upper |
a logical value indicating whether the upper of a distance matrix is used (TRUE) or not (FALSE). |
The attributs of a 'kdist' object are:names
: the names of the distancessize
: the number of points between distances are knownlabels
: the labels of pointseuclid
: a logical vector indicating whether each distance of the list is Euclidean or not.call
: a call orderclass
: object 'kdist'
returns an object of class 'kdist' containing a list of semidefinite matrices.
Daniel Chessel
Anne-Béatrice Dufour [email protected]
Gower, J. C. (1966) Some distance properties of latent root and vector methods used in multivariate analysis. Biometrika, 53, 325–338.
# starting from a list of matrices data(yanomama) lapply(yanomama,class) kd1 = kdist(yanomama) print(kd1) # giving the correlations of Mantel's test cor(as.data.frame(kd1)) pairs(as.data.frame(kd1)) # starting from a list of objects 'dist' data(friday87) fri.w <- ktab.data.frame(friday87$fau, friday87$fau.blo, tabnames = friday87$tab.names) fri.kd = lapply(1:10, function(x) dist.binary(fri.w[[x]],2)) names(fri.kd) = friday87$tab.names unlist(lapply(fri.kd,class)) # a list of distances fri.kd = kdist(fri.kd) fri.kd s.corcircle(dudi.pca(as.data.frame(fri.kd), scan = FALSE)$co) # starting from several distances data(ecomor) d1 <- dist.binary(ecomor$habitat, 1) d2 <- dist.prop(ecomor$forsub, 5) d3 <- dist.prop(ecomor$diet, 5) d4 <- dist.quant(ecomor$morpho, 3) d5 <- dist.taxo(ecomor$taxo) ecomor.kd <- kdist(d1, d2, d3, d4, d5) names(ecomor.kd) = c("habitat", "forsub", "diet", "morpho", "taxo") class(ecomor.kd) s.corcircle(dudi.pca(as.data.frame(ecomor.kd), scan = FALSE)$co) data(bsetal97) X <- prep.fuzzy.var(bsetal97$biol, bsetal97$biol.blo) w1 <- attr(X, "col.num") w2 <- levels(w1) w3 <- lapply(w2, function(x) dist.quant(X[,w1==x], method = 1)) names(w3) <- names(attr(X, "col.blocks")) w3 <- kdist(list = w3) s.corcircle(dudi.pca(as.data.frame(w3), scan = FALSE)$co) data(rpjdl) w1 = lapply(1:10, function(x) dist.binary(rpjdl$fau, method = x)) w2 = c("JACCARD", "SOKAL_MICHENER", "SOKAL_SNEATH_S4", "ROGERS_TANIMOTO") w2 = c(w2, "CZEKANOWSKI", "S9_GOWER_LEGENDRE", "OCHIAI", "SOKAL_SNEATH_S13") w2 <- c(w2, "Phi_PEARSON", "S2_GOWER_LEGENDRE") names(w1) <- w2 w3 = kdist(list = w1) w4 <- dudi.pca(as.data.frame(w3), scan = FALSE)$co w4
# starting from a list of matrices data(yanomama) lapply(yanomama,class) kd1 = kdist(yanomama) print(kd1) # giving the correlations of Mantel's test cor(as.data.frame(kd1)) pairs(as.data.frame(kd1)) # starting from a list of objects 'dist' data(friday87) fri.w <- ktab.data.frame(friday87$fau, friday87$fau.blo, tabnames = friday87$tab.names) fri.kd = lapply(1:10, function(x) dist.binary(fri.w[[x]],2)) names(fri.kd) = friday87$tab.names unlist(lapply(fri.kd,class