[Vegan-commits] r933 - in branches/1.15: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 20 19:57:51 CEST 2009


Author: jarioksa
Date: 2009-08-20 19:57:50 +0200 (Thu, 20 Aug 2009)
New Revision: 933

Added:
   branches/1.15/R/fitted.capscale.R
   branches/1.15/R/rrarefy.R
Modified:
   branches/1.15/DESCRIPTION
   branches/1.15/R/biplot.rda.R
   branches/1.15/R/capscale.R
   branches/1.15/R/dispindmorisita.R
   branches/1.15/R/ordiGetData.R
   branches/1.15/R/ordilabel.R
   branches/1.15/R/ordilattice.getEnvfit.R
   branches/1.15/R/ordiplot3d.R
   branches/1.15/R/orditorp.R
   branches/1.15/R/ordixyplot.R
   branches/1.15/R/plot.spantree.R
   branches/1.15/R/points.cca.R
   branches/1.15/R/postMDS.R
   branches/1.15/R/predict.rda.R
   branches/1.15/R/summary.cca.R
   branches/1.15/R/text.cca.R
   branches/1.15/R/wcmdscale.R
   branches/1.15/inst/ChangeLog
   branches/1.15/man/biplot.rda.Rd
   branches/1.15/man/dispindmorisita.Rd
   branches/1.15/man/diversity.Rd
   branches/1.15/man/plot.cca.Rd
   branches/1.15/man/predict.cca.Rd
   branches/1.15/man/wcmdscale.Rd
Log:
merge r874 to r891 to branches/1.15

Modified: branches/1.15/DESCRIPTION
===================================================================
--- branches/1.15/DESCRIPTION	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/DESCRIPTION	2009-08-20 17:57:50 UTC (rev 933)
@@ -1,7 +1,7 @@
 Package: vegan
 Title: Community Ecology Package
-Version: 1.15-3
-Date: June 17, 2009
+Version: 1.15-4
+Date: August 20, 2009
 Author: Jari Oksanen, Roeland Kindt, Pierre Legendre, Bob O'Hara, Gavin L. Simpson, 
    Peter Solymos, M. Henry H. Stevens, Helene Wagner  
 Maintainer: Jari Oksanen <jari.oksanen at oulu.fi>

Modified: branches/1.15/R/biplot.rda.R
===================================================================
--- branches/1.15/R/biplot.rda.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/biplot.rda.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -5,7 +5,7 @@
 
 biplot.rda <- function(x, choices = c(1, 2), scaling = 2,
                        display = c("sites", "species"),
-                       type, xlim, ylim, col = c(1,2), ...) {
+                       type, xlim, ylim, col = c(1,2), const, ...) {
   if(!inherits(x, "rda"))
       stop("'biplot.rda' is only for objects of class 'rda'")
   if(!is.null(x$CCA))
@@ -15,7 +15,7 @@
   if (length(col) == 1)
       col <- c(col,col)
   g <- scores(x, choices = choices, display = display,
-              scaling = scaling)
+              scaling = scaling, const)
   if (!is.list(g)) {
       g <- list(default = g)
       names(g) <- display

Modified: branches/1.15/R/capscale.R
===================================================================
--- branches/1.15/R/capscale.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/capscale.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -85,6 +85,7 @@
             sol$CA$imaginary.chi <- sum(negax)
             sol$tot.chi <- sol$tot.chi + sol$CA$imaginary.chi
             sol$CA$imaginary.rank <- length(negax)
+            sol$CA$imaginary.u.eig <- X$negaxes
         }
     }
     if (!is.null(comm)) {

Modified: branches/1.15/R/dispindmorisita.R
===================================================================
--- branches/1.15/R/dispindmorisita.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/dispindmorisita.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -7,9 +7,9 @@
     Imor <- numeric(p)
     Imor <- apply(x, 2, function(y) n * ((sum(y^2) - sum(y)) / (sum(y)^2 - sum(y))))
     Smor <- Imor
-    chicr <- qchisq(c(0+crit/2, 1-crit/2), n-1)
-    Muni <- apply(x, 2, function(y) (chicr[1] - n + sum(y)) / (sum(y) - 1))
-    Mclu <- apply(x, 2, function(y) (chicr[2] - n + sum(y)) / (sum(y) - 1))
+    chicr <- qchisq(c(0+crit/2, 1-crit/2), n-1, lower.tail=FALSE)
+    Muni <- apply(x, 2, function(y) (chicr[2] - n + sum(y)) / (sum(y) - 1))
+    Mclu <- apply(x, 2, function(y) (chicr[1] - n + sum(y)) / (sum(y) - 1))
     for (i in 1:p) {
         if (apply(x, 2, sum)[i] > 1) {
             if (Imor[i] >= Mclu[i] && Mclu[i] > 1)

Copied: branches/1.15/R/fitted.capscale.R (from rev 888, pkg/vegan/R/fitted.capscale.R)
===================================================================
--- branches/1.15/R/fitted.capscale.R	                        (rev 0)
+++ branches/1.15/R/fitted.capscale.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -0,0 +1,17 @@
+fitted.capscale <-
+    function(object, model = c("CCA", "CA", "Imaginary"),
+             type = c("response", "working"), ...)
+{
+    model <- match.arg(model)
+    type <- match.arg(type)
+    ## Return scaled eigenvalues
+    U <- switch(model,
+                CCA = object$CCA$u.eig,
+                CA = object$CA$u.eig,
+                Imaginary = object$CA$imaginary.u.eig)
+    ## Distances or working scores U
+    if (type == "response")
+        dist(U)
+    else
+        U
+}

Modified: branches/1.15/R/ordiGetData.R
===================================================================
--- branches/1.15/R/ordiGetData.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/ordiGetData.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -2,7 +2,7 @@
 function (call, env) 
 {
     call$scale <- call$distance <- call$comm <- call$add <-
-        call$sqrt.dist <- NULL
+        call$dfun <- call$sqrt.dist <- call$metaMDSdist <- NULL
     call$na.action <- na.pass
     call[[2]] <- NULL
     call[[1]] <- as.name("model.frame")

Modified: branches/1.15/R/ordilabel.R
===================================================================
--- branches/1.15/R/ordilabel.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/ordilabel.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -2,7 +2,9 @@
     function(x, display, labels, choices = c(1,2), priority,
              cex = 0.8, fill = "white", border = NULL,  ...)
 {
-    x <- scores(x, display = display, choices = choices, ...)
+    if (missing(display))
+        display <- "sites"
+    x <- scores(x, choices = choices, display = display, ...)
     if (missing(labels))
         labels <- rownames(x)
     if (!missing(priority)) {

Modified: branches/1.15/R/ordilattice.getEnvfit.R
===================================================================
--- branches/1.15/R/ordilattice.getEnvfit.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/ordilattice.getEnvfit.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -3,8 +3,8 @@
 {
     if (!missing(envfit) && !is.null(envfit))
         object <- envfit
-    bp <- scores(object, display = "bp", choices = choices)
-    cn <- scores(object, display = "cn",  choices = choices)
+    bp <- scores(object, display = "bp", choices = choices, ...)
+    cn <- scores(object, display = "cn",  choices = choices, ...)
     bp <- bp[!(rownames(bp) %in% rownames(cn)),, drop=FALSE]
     left <- as.character(formula[[2]])
     right <- formula[[3]]

Modified: branches/1.15/R/ordiplot3d.R
===================================================================
--- branches/1.15/R/ordiplot3d.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/ordiplot3d.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -3,12 +3,14 @@
               arr.len = 0.1, arr.col = 4, envfit, xlab, ylab, zlab, ...) 
 {
     require(scatterplot3d) || stop("Requires package 'scatterplot3d'")
-    x <- scores(object, display = display, choices = choices)
+    local
+    x <- scores(object, display = display, choices = choices, ...)
     if (missing(xlab)) xlab <- colnames(x)[1]
     if (missing(ylab)) ylab <- colnames(x)[2]
     if (missing(zlab)) zlab <- colnames(x)[3]
-    pl <- scatterplot3d(x[, 1], x[, 2], x[, 3],  
-                        xlab = xlab, ylab = ylab, zlab = zlab, ...)
+    pl <- ordiArgAbsorber(x[, 1], x[, 2], x[, 3],  
+                        xlab = xlab, ylab = ylab, zlab = zlab,
+                          FUN = "scatterplot3d", ...)
     pl$points3d(range(x[, 1]), c(0, 0), c(0, 0), type = "l", 
                 col = ax.col)
     pl$points3d(c(0, 0), range(x[, 2]), c(0, 0), type = "l", 
@@ -18,8 +20,8 @@
     if (!missing(envfit) || !is.null(object$CCA)) {
         if (!missing(envfit)) 
             object <- envfit
-        bp <- scores(object, dis = "bp", choices = choices)
-        cn <- scores(object, dis = "cn", choices = choices)
+        bp <- scores(object, dis = "bp", choices = choices, ...)
+        cn <- scores(object, dis = "cn", choices = choices, ...)
         if (!is.null(cn) && !any(is.na(cn))) {
             bp <- bp[!(rownames(bp) %in% rownames(cn)), , drop = FALSE]
             cn.xyz <- pl$xyz.convert(cn)

Modified: branches/1.15/R/orditorp.R
===================================================================
--- branches/1.15/R/orditorp.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/orditorp.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -12,8 +12,8 @@
         labels <- rownames(x)
     if (missing(priority))
         priority <- rowSums((scale(x)^2))
-    w <- strwidth(labels, cex = cex)/2 * air
-    h <- strheight(labels, cex = cex)/2 * air
+    w <- abs(strwidth(labels, cex = cex))/2 * air
+    h <- abs(strheight(labels, cex = cex))/2 * air
     xx <- cbind(x[, 1] - w, x[, 1] + w, x[, 2] - h, x[, 2] +
                 h)
     is.na(priority) <- w == 0

Modified: branches/1.15/R/ordixyplot.R
===================================================================
--- branches/1.15/R/ordixyplot.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/ordixyplot.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -4,8 +4,6 @@
              type = c("p", "biplot"),  ...)
 {
   localXyplot <- function(..., shrink, origin, scaling) xyplot(...)
-  localOrdilattice.getEnvfit <-
-    function(..., shrink, origin, scaling) ordilattice.getEnvfit(...)
   require(lattice) || stop("requires package 'lattice'")
   p <- as.data.frame(scores(x, display = display, choices = choices, ...))
   if (!is.null(data))
@@ -17,7 +15,7 @@
   if ("biplot" %in% type && (!is.null(x$CCA) || !missing(envfit))) {
     if (missing(envfit))
       envfit <- NULL
-    env <- localOrdilattice.getEnvfit(formula, x, envfit, choices, ...)
+    env <- ordilattice.getEnvfit(formula, x, envfit, choices, ...)
     if (!is.null(env$arrows)) {
       mul <- apply(p[,colnames(env$arrows)], 2, range)/apply(env$arrows, 2, range)
       mul <- min(mul[is.finite(mul) & mul > 0])

Modified: branches/1.15/R/plot.spantree.R
===================================================================
--- branches/1.15/R/plot.spantree.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/plot.spantree.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -19,15 +19,16 @@
             y[dup, ] <- y[dup,] + runif(2*sum(dup), -0.01, 0.01) 
         ord <- FUN(d, y)
     }
-    ord <- scores(ord, display = "sites")
-    plot(ord, asp = 1, type = "n", ...)
+    ord <- scores(ord, display = "sites", ...)
+    ordiArgAbsorber(ord, asp = 1, type = "n", FUN = "plot", ...)
     lines(x, ord)
     if (type == "p" || type == "b") 
-        points(ord, cex = cex, ...)
+        ordiArgAbsorber(ord, cex = cex, FUN = "points", ...)
     else if (type == "t") {
         if (missing(labels)) 
             labels <- x$labels
-        ordilabel(ord, display = "sites", labels = labels, cex = cex, ...)
+        x <- scores(ord, display = "sites", ...)
+        ordiArgAbsorber(x, labels = labels, cex = cex, FUN = "ordilabel", ...)
     }
     ord <- list(sites = ord)
     class(ord) <- "ordiplot"

Modified: branches/1.15/R/points.cca.R
===================================================================
--- branches/1.15/R/points.cca.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/points.cca.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -1,17 +1,19 @@
 `points.cca` <-
     function (x, display = "sites", choices = c(1, 2), scaling = 2, 
-              arrow.mul, head.arrow = 0.05, select, ...) 
+              arrow.mul, head.arrow = 0.05, select, const, ...) 
 {
     formals(arrows) <- c(formals(arrows), alist(... = ))
     if (length(display) > 1) 
         stop("Only one `display' item can be added in one command.")
-    pts <- scores(x, choices = choices, display = display, scaling = scaling)
+    pts <- scores(x, choices = choices, display = display, scaling = scaling,
+                  const)
     if (!missing(select)) 
         pts <- pts[select, , drop = FALSE]
     if (display == "cn") {
         cnam <- rownames(pts)
         points(pts, ...)
-        pts <- scores(x, choices = choices, display = "bp", scaling = scaling)
+        pts <- scores(x, choices = choices, display = "bp", scaling = scaling,
+                      const)
         bnam <- rownames(pts)
         pts <- pts[!(bnam %in% cnam), , drop = FALSE]
         if (nrow(pts) == 0) 

Modified: branches/1.15/R/postMDS.R
===================================================================
--- branches/1.15/R/postMDS.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/postMDS.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -51,21 +51,22 @@
         drange <- range(c(dist, 0, 1))
         plot(orange, drange, type = "n", xlab = "Ordination distance", 
              ylab = "Community dissimilarity")
-        points(ordi[take], dist[take], pch = pch, col = "blue")
-        points(ordi[!take], dist[!take], pch = pch, col = "gray")
+        ## Colours in default palette: 2 = red, 4 = blue, 8 = gray.
+        points(ordi[take], dist[take], pch = pch, col = 4)
+        points(ordi[!take], dist[!take], pch = pch, col = 8)
         abline(h = threshold)
         abline(h = k[1])
         hclevel <- (1 - k[1])/2 + k[1]
-        segments(0, hclevel, hc, hclevel, col = "red", lwd = 2)
-        arrows(hc, hclevel, hc, 0, col = "red", lwd = 2)
-        arrows(0, k[1], 0, hclevel, col = "red", code = 3)
-        arrows(0, hclevel, 0, 1, col = "red", code = 3)
+        segments(0, hclevel, hc, hclevel, col = 2, lwd = 2)
+        arrows(hc, hclevel, hc, 0, col = 2, lwd = 2)
+        arrows(0, k[1], 0, hclevel, col = 2, code = 3)
+        arrows(0, hclevel, 0, 1, col = 2, code = 3)
         j <- 0.02
         text(0 + j, threshold + j, "Threshold", adj = c(0, 0))
         text(0 + j, k[1] + j, "Replicate dissimilarity", adj = c(0, 
                                                          0))
         text(0 + j, hclevel + j, "Half-change", adj = c(0, 0))
-        abline(k, col = "blue", lwd = 2)
+        abline(k, col = 4, lwd = 2)
     }
     attr(x, "centre") <- center
     attr(x, "pc") <- pc

Modified: branches/1.15/R/predict.rda.R
===================================================================
--- branches/1.15/R/predict.rda.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/predict.rda.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -23,15 +23,18 @@
         w <- u
     slam <- diag(sqrt(object[[model]]$eig[1:take] * nr), nrow = take)
     if (type == "response") {
-        if (inherits(object, "capscale")) 
-            stop("Prediction of 'response' not available in capscale")
         if (!is.null(object$pCCA)) 
             warning("Conditional ('partial') component ignored")
-        if (take > 0) 
-            out <- u %*% slam %*% t(v)
-        if (!is.null(scal)) 
-            out <- sweep(out, 2, scal, "*")
-        out <- sweep(out, 2, cent, "+")
+        if (inherits(object, "capscale")) {
+            if (take > 0)
+                out <- dist(u %*% slam/sqrt(nr))
+        } else {
+            if (take > 0) 
+                out <- u %*% slam %*% t(v)
+            if (!is.null(scal)) 
+                out <- sweep(out, 2, scal, "*")
+            out <- sweep(out, 2, cent, "+")
+        }
     }
     else if (type == "lc") {
         if (model == "CA") 

Copied: branches/1.15/R/rrarefy.R (from rev 874, pkg/vegan/R/rrarefy.R)
===================================================================
--- branches/1.15/R/rrarefy.R	                        (rev 0)
+++ branches/1.15/R/rrarefy.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -0,0 +1,17 @@
+rrarefy <-
+function(x, sample)
+{
+    if (length(sample) > 1 && length(sample) != nrow(x))
+        stop("length of 'sample' and number of rows of 'x' do not match")
+    sample <- rep(sample, length=nrow(x))
+    colnames(x) <- colnames(x, do.NULL = FALSE)
+    nm <- colnames(x)
+    for (i in 1:nrow(x)) {
+        row <- sample(rep(nm, times=x[i,]), sample[i])
+        row <- table(row)
+        ind <- names(row)
+        x[i,] <- 0
+        x[i,ind] <- row
+    }
+    x
+}

Modified: branches/1.15/R/summary.cca.R
===================================================================
--- branches/1.15/R/summary.cca.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/summary.cca.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -18,13 +18,20 @@
         summ <- list(summ)
         names(summ) <- nms[display]
     }
+    if (length(display) > 0) {
+        for (i in 1:length(summ)) {
+            rownames(summ[[i]]) <- rownames(summ[[i]], do.NULL = FALSE,
+                                            prefix = substr(names(summ)[i], 1, 3))
+        }
+    }
     summ$call <- object$call
     summ$tot.chi <- object$tot.chi
     summ$partial.chi <- object$pCCA$tot.chi
     summ$constr.chi <- object$CCA$tot.chi
     summ$unconst.chi <- object$CA$tot.chi
     summ$cont <- summary(eigenvals(object))
-    summ$concont <- summary(eigenvals(object, constrained = TRUE))
+    if (!is.null(object$CCA))
+        summ$concont <- summary(eigenvals(object, constrained = TRUE))
     summ$ev.head <- c(summ$ev.con, summ$ev.uncon)[1:axes]
     summ$scaling <- scaling
     summ$digits <- digits

Modified: branches/1.15/R/text.cca.R
===================================================================
--- branches/1.15/R/text.cca.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/text.cca.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -1,11 +1,12 @@
 `text.cca` <-
     function (x, display = "sites", labels, choices = c(1, 2), scaling = 2, 
-              arrow.mul, head.arrow = 0.05, select, ...) 
+              arrow.mul, head.arrow = 0.05, select, const, ...) 
 {
     formals(arrows) <- c(formals(arrows), alist(... = ))
     if (length(display) > 1) 
         stop("Only one `display' item can be added in one command.")
-    pts <- scores(x, choices = choices, display = display, scaling = scaling)
+    pts <- scores(x, choices = choices, display = display, scaling = scaling,
+                  const)
     if (!missing(labels))
         rownames(pts) <- labels
     if (!missing(select)) 
@@ -13,7 +14,8 @@
     if (display == "cn") {
         cnam <- rownames(pts)
         text(pts, labels = cnam, ...)
-        pts <- scores(x, choices = choices, display = "bp", scaling = scaling)
+        pts <- scores(x, choices = choices, display = "bp", scaling = scaling,
+                      const)
         bnam <- rownames(pts)
         pts <- pts[!(bnam %in% cnam), , drop = FALSE]
         if (nrow(pts) == 0) 

Modified: branches/1.15/R/wcmdscale.R
===================================================================
--- branches/1.15/R/wcmdscale.R	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/R/wcmdscale.R	2009-08-20 17:57:50 UTC (rev 933)
@@ -26,17 +26,24 @@
     ## Remove zero eigenvalues, keep negative
     keep <- abs(e$values) > ZERO
     e$values <- e$values[keep]
-    e$vectors <- e$vectors[, keep]
-    ## Get number of positive eigenvalues
-    if (missing(k))
+    e$vectors <- e$vectors[, keep, drop = FALSE]
+    ## Deweight and scale axes -- also negative
+    points <- sweep(e$vectors, 1, sqrt(w), "/")
+    points <- sweep(points, 2, sqrt(abs(e$values)), "*")
+    rownames(points) <- rownames(m)
+    ## If 'k' not given, find it as the number of positive
+    ## eigenvalues, and also save negative eigenvalues
+    negaxes <- NULL
+    if (missing(k) || k > sum(e$value > ZERO)) {
         k <- sum(e$values > ZERO)
-    ev <- e$values[1:k]
-    points <- sweep(e$vectors[, 1:k, drop=FALSE], 1, sqrt(w), "/")
-    points <- sweep(points, 2, sqrt(ev), "*")
-    rownames(points) <- rownames(m)
+        if (any(e$values < 0))
+            negaxes <- points[, e$values < 0, drop = FALSE]
+    }
+    points <- points[, 1:k, drop=FALSE]
     if (eig || x.ret || add) {
         out <- list(points = points, eig = if (eig) e$values,
-                    x = if (x.ret) m, ac = NA, GOF = NA, weights = w)
+                    x = if (x.ret) m, ac = NA, GOF = NA, weights = w,
+                    negaxes = negaxes)
         class(out) <- "wcmdscale"
     }
     else out <- points

Modified: branches/1.15/inst/ChangeLog
===================================================================
--- branches/1.15/inst/ChangeLog	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/inst/ChangeLog	2009-08-20 17:57:50 UTC (rev 933)
@@ -3,6 +3,26 @@
 
 VEGAN STABLE VERSIONS
 
+Version 1.15-4 (working from August 20, 2009)
+
+	* merged r874: rrarefy.
+
+	* merged r875,888: betadisper fix of removing zero eigenvalues.
+
+	* merged r880: fix diversity.Rd warnings.
+
+	* merged r881, r882: pass args of 'scores' to other functions, clean
+	summary.cca. 
+
+	* merged r883: orditorp works with reverse axes.
+
+	* merged r884 to r886: returns axes scaled by negative
+	eigenvalues.
+
+	* merged r888: capscale got fitted method.
+
+	* merged r889: postMDS uses numeric palette.
+
 Version 1.15-3 (released June 17, 2009)
 
 	* merged revs 866 to 868: changed the way capscale displays

Modified: branches/1.15/man/biplot.rda.Rd
===================================================================
--- branches/1.15/man/biplot.rda.Rd	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/man/biplot.rda.Rd	2009-08-20 17:57:50 UTC (rev 933)
@@ -7,7 +7,8 @@
 }
 \usage{
 \method{biplot}{rda}(x, choices = c(1, 2), scaling = 2,
-       display = c("sites", "species"), type, xlim, ylim, col = c(1,2), ...)
+       display = c("sites", "species"), type, xlim, ylim, col = c(1,2), 
+       const, ...)
 }
 
 \arguments{
@@ -34,6 +35,7 @@
   \item{xlim, ylim}{the x and y limits (min, max) of the plot.}
   \item{col}{Colours used for sites and species (in this order). If only
     one colour is given, it is used for both.}
+  \item{const}{General scaling constant for \code{\link{scores.rda}}.}
   \item{\dots}{Other parameters for plotting functions.}
 }
 \details{

Modified: branches/1.15/man/dispindmorisita.Rd
===================================================================
--- branches/1.15/man/dispindmorisita.Rd	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/man/dispindmorisita.Rd	2009-08-20 17:57:50 UTC (rev 933)
@@ -34,9 +34,9 @@
 values of the Chi-squared distribution with \eqn{n-1} degrees of
 freedom, respectively, for \code{alpha = 0.05}):
 
-\code{Mclu = (Chi2Upper - n + sum(xi)) / (sum(xi) - 1)}
+\code{Mclu = (Chi2Lower - n + sum(xi)) / (sum(xi) - 1)}
 
-\code{Muni = (Chi2Lower - n + sum(xi)) / (sum(xi) - 1)}
+\code{Muni = (Chi2Upper - n + sum(xi)) / (sum(xi) - 1)}
 
 Smith-Gill (1975) proposed scaling of Morisita index from [0, n]
 interval into [-1, 1], and setting up -0.5 and 0.5 values as

Modified: branches/1.15/man/diversity.Rd
===================================================================
--- branches/1.15/man/diversity.Rd	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/man/diversity.Rd	2009-08-20 17:57:50 UTC (rev 933)
@@ -2,6 +2,7 @@
 \name{diversity}
 \alias{diversity}
 \alias{rarefy}
+\alias{rrarefy}
 \alias{fisher.alpha}
 \alias{specnumber}
 
@@ -15,6 +16,8 @@
 
 rarefy(x, sample, se = FALSE, MARGIN = 1)
 
+rrarefy(x, sample)
+
 fisher.alpha(x, MARGIN = 1, se = FALSE, ...)
 
 specnumber(x, MARGIN = 1)
@@ -52,8 +55,15 @@
   size separately.
   Rarefaction can be performed only with genuine counts of individuals.
   The function \code{rarefy} is based on Hurlbert's (1971) formulation,
-  and the standard errors on Heck et al. (1975).  
+  and the standard errors on Heck et al. (1975).
 
+  Function \code{rrarefy} generates one randomly rarefied community data
+  frame or vector of given \code{sample} size. The \code{sample} can be
+  a vector, and its values must be less or equal to observed number of
+  individuals. The random rarefaction is made without replacement so
+  that the variance of rarefied communities is rather related to
+  rarefaction proportion than to to the size of the \code{sample}.  
+
   \code{fisher.alpha} estimates the \eqn{\alpha} parameter of
   Fisher's logarithmic series (see \code{\link{fisherfit}}). 
   The estimation is possible only for genuine

Modified: branches/1.15/man/plot.cca.Rd
===================================================================
--- branches/1.15/man/plot.cca.Rd	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/man/plot.cca.Rd	2009-08-20 17:57:50 UTC (rev 933)
@@ -21,9 +21,9 @@
 \method{plot}{cca}(x, choices = c(1, 2), display = c("sp", "wa", "cn"),
          scaling = 2, type, xlim, ylim, const, ...)
 \method{text}{cca}(x, display = "sites", labels, choices = c(1, 2), scaling = 2,
-    arrow.mul, head.arrow = 0.05, select, ...)
+    arrow.mul, head.arrow = 0.05, select, const, ...)
 \method{points}{cca}(x, display = "sites", choices = c(1, 2), scaling = 2,
-    arrow.mul, head.arrow = 0.05, select, ...)
+    arrow.mul, head.arrow = 0.05, select, const, ...)
 \method{scores}{cca}(x, choices=c(1,2), display=c("sp","wa","cn"), scaling=2, ...)
 \method{scores}{rda}(x, choices=c(1,2), display=c("sp","wa","cn"), scaling=2, 
     const, ...)

Modified: branches/1.15/man/predict.cca.Rd
===================================================================
--- branches/1.15/man/predict.cca.Rd	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/man/predict.cca.Rd	2009-08-20 17:57:50 UTC (rev 933)
@@ -1,6 +1,7 @@
 \name{predict.cca}
 \alias{fitted.cca}
 \alias{fitted.rda}
+\alias{fitted.capscale}
 \alias{residuals.cca}
 \alias{residuals.rda}
 \alias{predict.cca}
@@ -19,6 +20,9 @@
 \usage{
 \method{fitted}{cca}(object, model = c("CCA", "CA"),
     type =  c("response", "working"), ...)
+\method{fitted}{capscale}(object, model = c("CCA", "CA", "Imaginary"),
+    type = c("response", "working"), ...)
+\method{residuals}{cca}(object, ...)
 \method{predict}{cca}(object, newdata, type = c("response", "wa", "sp", "lc"),
     rank = "full", model = c("CCA", "CA"), scaling = FALSE, ...)
 calibrate.cca(object, newdata, rank = "full", ...)
@@ -31,7 +35,8 @@
   \item{object}{A result object from \code{\link{cca}},
     \code{\link{rda}}, \code{\link{capscale}} or \code{\link{decorana}}. }
   \item{model}{Show constrained (\code{"CCA"}) or unconstrained
-    (\code{"CA"}) results. }
+    (\code{"CA"}) results. For \code{\link{capscale}} this can also be 
+    \code{"Imaginary"} for imaginary components with negative eigenvalues. }
   \item{newdata}{New data frame to be used in
     prediction of species and site scores or for calibration.  Usually
     this a new community data frame, but for \code{predict.cca}
@@ -41,12 +46,15 @@
     \code{fitted} and \code{residuals}, \code{"response"} scales results so
     that the same ordination gives the same results, and \code{"working"}
     gives the values used internally, that is after Chi-square
-    standardization in \code{cca} and scaling and centring in \code{rda}.
+    standardization in \code{\link{cca}} and scaling and centring in 
+    \code{\link{rda}}. In \code{\link{capscale}} the \code{"response"} gives
+    the dissimilarities, and \code{"working"} the scaled scores that produce
+    the dissimlarities as Euclidean distances.
     In \code{predict} \code{"response"} 
-    gives an approximation of the original data matrix, \code{"wa"} the
-    site scores as weighted averages of the community data, \code{"lc"}
-    the site scores as linear combinations of environmental data, and
-    \code{"sp"} the species scores.  In \code{predict.decorana} the
+    gives an approximation of the original data matrix or dissimilarities, 
+    \code{"wa"} the site scores as weighted averages of the community data, 
+    \code{"lc"} the site scores as linear combinations of environmental data, 
+    and \code{"sp"} the species scores. In \code{predict.decorana} the
     alternatives are scores for \code{"sites"} or \code{"species"}.} 
   \item{rank}{The rank or the number of axes used in the approximation.
     The default is to use all axes (full rank) of the \code{"model"} or
@@ -58,22 +66,29 @@
 }
 \details{
   Function \code{fitted} gives the approximation of the original data
-  matrix from the ordination result either in the scale of the response
+  matrix or dissimilarities from the ordination result either in the 
+  scale of the response
   or as scaled internally by the function.  Function \code{residuals} gives
   the approximation of the original data from the unconstrained
   ordination.  With argument \code{type = "response"} the
   \code{fitted.cca} and \code{residuals.cca} function 
   both give the same marginal totals as the original data matrix, and
-  their entries do not add up to the original data. They are defined so
+  their entries do not add up to the original data. 
+  Functions \code{fitted.capscale} and \code{residuals.capscale} give the
+  dissimilarities with \code{type = "response"}, but these are not additive,
+  but the \code{"working"} scores are additive. 
+  All variants of \code{fitted} and \code{residuals} are defined so
   that for model \code{mod <- cca(y ~ x)}, \code{cca(fitted(mod))} is equal
   to constrained ordination, and \code{cca(residuals(mod))} is equal to
   unconstrained part of the ordination.
 
   Function \code{predict} can find the estimate of the original data
-  matrix (\code{type = "response"}) with any rank. With \code{rank =
-    "full"} it is identical to \code{fitted}.  In addition, the function
+  matrix or dissimilarites (\code{type = "response"}) with any rank. 
+  With \code{rank = "full"} it is identical to \code{fitted}.
+  In addition, the function
   can find the species scores or site scores from the community data
-  matrix.  The function can be used with new data, and it can be used to
+  matrix for \code{\link{cca}} or \code{\link{rda}}.  
+  The function can be used with new data, and it can be used to
   add new species or site scores to existing ordinations.  The function
   returns (weighted) orthonormal scores by default, and you must
   specify explicit \code{scaling} to
@@ -122,7 +137,7 @@
 }
 
 \value{
-  The functions return matrices or vectors as is appropriate.
+  The functions return matrices, vectors or dissimilarities as is appropriate.
 }
 \references{
   Greenacre, M. J. (1984). Theory and applications of correspondence

Modified: branches/1.15/man/wcmdscale.Rd
===================================================================
--- branches/1.15/man/wcmdscale.Rd	2009-08-20 16:48:34 UTC (rev 932)
+++ branches/1.15/man/wcmdscale.Rd	2009-08-20 17:57:50 UTC (rev 933)
@@ -48,6 +48,9 @@
     \code{eig} is true.}
   \item{x}{the doubly centred and weighted distance matrix if \code{x.ret} is true.}
   \item{weights}{Weights.}
+  \item{negaxes}{A matrix of scores for axes with negative eigenvalues scaled 
+     by the absolute eigenvalues similarly as \code{points}. This is \code{NULL}
+     if there are no negative eigenvalues or \code{k} was specified, and would not     include negative eigenvalues.}
 }
 \references{
   Gower, J. C. (1966)  
@@ -78,5 +81,12 @@
 ## eigenvalues in CA
 procrustes(ord, ca, choices=1:19, scaling = 1)
 plot(procrustes(ord, ca, choices=1:2, scaling=1))
+## Reconstruction of non-Euclidean distances with negative eigenvalues
+d <- vegdist(dune)
+ord <- wcmdscale(d, eig = TRUE)
+## Only positive eigenvalues:
+cor(d, dist(ord$points))
+## Correction with negative eigenvalues:
+cor(d, sqrt(dist(ord$points)^2 - dist(ord$negaxes)^2))
 }
 \keyword{multivariate}



More information about the Vegan-commits mailing list