[Vegan-commits] r2807 - in branches/2.0: . R inst man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 5 12:50:52 CET 2013


Author: jarioksa
Date: 2013-12-05 12:50:52 +0100 (Thu, 05 Dec 2013)
New Revision: 2807

Removed:
   branches/2.0/R/confint.fisherfit.R
   branches/2.0/R/plot.profile.fisherfit.R
   branches/2.0/R/profile.fisherfit.R
Modified:
   branches/2.0/NAMESPACE
   branches/2.0/R/boxplot.specaccum.R
   branches/2.0/R/decostand.R
   branches/2.0/R/factorfit.R
   branches/2.0/R/fisher.alpha.R
   branches/2.0/R/fisherfit.R
   branches/2.0/R/nestednodf.R
   branches/2.0/R/ordiArrowMul.R
   branches/2.0/R/plot.specaccum.R
   branches/2.0/R/print.cca.R
   branches/2.0/R/print.fisherfit.R
   branches/2.0/R/renyiaccum.R
   branches/2.0/R/specaccum.R
   branches/2.0/R/tsallisaccum.R
   branches/2.0/R/vectorfit.R
   branches/2.0/inst/ChangeLog
   branches/2.0/man/diversity.Rd
   branches/2.0/man/fisherfit.Rd
   branches/2.0/man/renyi.Rd
   branches/2.0/man/specaccum.Rd
   branches/2.0/man/tsallis.Rd
   branches/2.0/vignettes/diversity-vegan.Rnw
Log:
merge small bug fixes and enhancements to 2.0-10 (up to r2641)

Modified: branches/2.0/NAMESPACE
===================================================================
--- branches/2.0/NAMESPACE	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/NAMESPACE	2013-12-05 11:50:52 UTC (rev 2807)
@@ -131,7 +131,6 @@
 # confint: stats -- also uses MASS:::confint.glm & MASS:::profile.glm
 # does this work with namespaces??
 S3method(confint, MOStest)
-S3method(confint, fisherfit)
 # cophenetic: stats
 S3method(cophenetic, spantree)
 # density: stats
@@ -264,7 +263,6 @@
 S3method(plot, preston)
 S3method(plot, prestonfit)
 S3method(plot, procrustes)
-S3method(plot, profile.fisherfit)
 S3method(plot, rad)
 S3method(plot, radfit)
 S3method(plot, radfit.frame)
@@ -360,7 +358,6 @@
 # profile: stats
 # see note on 'confint'
 S3method(profile, MOStest)
-S3method(profile, fisherfit)
 S3method(profile, humpfit)
 # radfit: vegan
 S3method(radfit, data.frame)

Modified: branches/2.0/R/boxplot.specaccum.R
===================================================================
--- branches/2.0/R/boxplot.specaccum.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/boxplot.specaccum.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,11 +1,11 @@
-"boxplot.specaccum" <-
+`boxplot.specaccum` <-
     function(x, add=FALSE, ...)
 {
     if (x$method != "random")
         stop("boxplot available only for method=\"random\"")
     if (!add) {
         plot(x$sites, x$richness, type="n", xlab="Sites", ylab="Species",
-             ylim=c(1, max(x$richness)),  ...)
+             ylim=c(1, max(x$richness, na.rm = TRUE)),  ...)
     }
     tmp <- boxplot(data.frame(t(x$perm)), add=TRUE, at=x$sites, axes=FALSE, ...)
     invisible(tmp)

Deleted: branches/2.0/R/confint.fisherfit.R
===================================================================
--- branches/2.0/R/confint.fisherfit.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/confint.fisherfit.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,6 +0,0 @@
-"confint.fisherfit" <-
-    function (object, parm, level=0.95,  ...)
-{
-    if (!require(MASS)) stop("Needs packages MASS .. not found")
-    confint(profile(object), level=level, ...)
-}

Modified: branches/2.0/R/decostand.R
===================================================================
--- branches/2.0/R/decostand.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/decostand.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,4 +1,4 @@
-"decostand" <-
+`decostand` <-
     function (x, method, MARGIN, range.global, logbase = 2, na.rm = FALSE, ...) 
 {
     wasDataFrame <- is.data.frame(x)
@@ -34,7 +34,7 @@
         if (missing(MARGIN)) 
             MARGIN <- 1
         tmp <- apply(x^2, MARGIN, sum, na.rm = na.rm)
-        tmp <- pmax(k, sqrt(tmp))
+        tmp <- pmax(.Machine$double.eps, sqrt(tmp))
         x <- sweep(x, MARGIN, tmp, "/")
     }, range = {
         if (missing(MARGIN)) 

Modified: branches/2.0/R/factorfit.R
===================================================================
--- branches/2.0/R/factorfit.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/factorfit.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -41,7 +41,7 @@
                             var = double(1), PACKAGE = "vegan")$var
                 tmp[i] <- 1 - invar/totvar
             }
-            pval.this <- (sum(tmp > r.this) + 1)/(permutations + 1)
+            pval.this <- (sum(tmp >= r.this) + 1)/(permutations + 1)
             pval <- c(pval, pval.this)
         }
     }

Modified: branches/2.0/R/fisher.alpha.R
===================================================================
--- branches/2.0/R/fisher.alpha.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/fisher.alpha.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,12 +1,12 @@
-"fisher.alpha" <-
-    function (x, MARGIN = 1, se = FALSE, ...) 
+`fisher.alpha` <-
+    function (x, MARGIN = 1, ...) 
 {
     x <- as.matrix(x)
     if(ncol(x) == 1)
         x <- t(x)
     sol <- apply(x, MARGIN, fisherfit)
     out <-  unlist(lapply(sol, function(x) x$estimate))
-    if (se) {
+    if (FALSE) {
         out <- list(alpha = out)
         out$se <- unlist(lapply(sol, function(x) sqrt(diag(solve(x$hessian)))[1]))
         out$df.residual <- unlist(lapply(sol, df.residual))

Modified: branches/2.0/R/fisherfit.R
===================================================================
--- branches/2.0/R/fisherfit.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/fisherfit.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,24 +1,49 @@
-"fisherfit" <-
-    function (x, ...) 
+## Fisher alpha is actually based only on the number of species S and
+## number of individuals.
+
+`fisherfit` <-
+    function(x, ...)
 {
-    Dev.logseries <- function(n.r, p, N) {
-        r <- as.numeric(names(n.r))
-        x <- N/(N + p)
-        logmu <- log(p) + log(x) * r - log(r)
-        lhood <- -sum(n.r * (logmu - log(n.r)) + 1) - p * log(1 - 
-                                                              x)
-        lhood
+    nr <- as.fisher(x)
+    S <- sum(nr)
+    N <- sum(x)
+    ## Solve 'x' (Fisher alpha).
+    d1fun <- function(x, S, N) x * log(1 + N/x) - S
+    ## We may need to bracket the interval
+    hi <- 50
+    lo <- 1
+    tries <- 0
+    repeat {
+        sol <- try(uniroot(d1fun, c(lo, hi), S = S, N = N, ...), silent = TRUE)
+        if (inherits(sol, "try-error")) {
+            if(d1fun(hi, S, N) < 0)
+                hi <- 2*hi
+            if(d1fun(lo, S, N) > 0)
+                lo <- lo/2
+            tries <- tries + 1
+        }
+        else break
+        ## alpha can tend to +Inf: set root = NA etc.
+        if (tries > 200) {
+            sol <- list(root = NA, f.root = NA, iter = NA, init.it = NA,
+                        estim.prec = NA)
+            break
+        }
     }
-    tmp <- as.rad(x)
-    N <- sum(x)
-    tmp <- tmp/N
-    p <- 1/sum(tmp^2)
-    n.r <- as.fisher(x)
-    LSeries <- nlm(Dev.logseries, n.r = n.r, p = p, N = N, 
-                   hessian = TRUE, ...)
-    LSeries$df.residual <- sum(x > 0) - 1
-    LSeries$nuisance <- N/(N + LSeries$estimate)
-    LSeries$fisher <- n.r
-    class(LSeries) <- "fisherfit"
-    LSeries
+    ## 'extendInt' arg was added in R r63162 | maechler | 2013-07-03
+    ## 11:47:22 +0300 (Wed, 03 Jul 2013). Latest release is R 3.0.2 of
+    ## 2013-09-25, but it still does not have the argument.  In the
+    ## future we may switch to the following:
+
+    ##sol <- uniroot(d1fun, c(1,50), extendInt = "yes", S = S, N = N, ...)
+    
+    nuisance <- N/(N + sol$root)
+    ## we used nlm() earlier, and the following output is compatible
+    out <- list(estimate = sol$root, hessian = NA,
+                iterations = sol$iter, df.residual = NA,
+                nuisance = nuisance, fisher = nr,
+                estim.prec = sol$estim.prec,
+                code = 2*is.na(sol$estim.prec) + 1)
+    class(out) <- "fisherfit"
+    out
 }

Modified: branches/2.0/R/nestednodf.R
===================================================================
--- branches/2.0/R/nestednodf.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/nestednodf.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -22,7 +22,7 @@
     }
     nr <- NROW(comm)
     nc <- NCOL(comm)
-    fill <- sum(rfill)/length(comm)
+    fill <- sum(rfill)/prod(dim(comm))
     N.paired.rows <- numeric(nr * (nr - 1)/2)
     N.paired.cols <- numeric(nc * (nc - 1)/2)
     counter <- 0
@@ -35,7 +35,7 @@
             if (weighted) {
                 second <- comm[j, ]
                 N.paired.rows[counter] <-
-                    sum(first - second > 0 & second > 0)/sum(second > 0)
+                    sum(first - second >= 0 & second > 0)/sum(second > 0)
             }
             else {
                 N.paired.rows[counter] <-
@@ -53,7 +53,7 @@
             if (weighted) {
                 second <- comm[, j]
                 N.paired.cols[counter] <-
-                    sum(first - second > 0 & second > 0)/sum(second > 0)
+                    sum(first - second >= 0 & second > 0)/sum(second > 0)
             }
             else {
                 N.paired.cols[counter] <-

Modified: branches/2.0/R/ordiArrowMul.R
===================================================================
--- branches/2.0/R/ordiArrowMul.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/ordiArrowMul.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -5,7 +5,7 @@
 {
     u <- par("usr")
     u <- u - rep(at, each = 2)
-    r <- c(range(x[,1]), range(x[,2]))
+    r <- c(range(x[,1], na.rm = TRUE), range(x[,2], na.rm = TRUE))
     ## 'rev' takes care of reversed axes like xlim(1,-1)
     rev <- sign(diff(u))[-2]
     if (rev[1] < 0)

Deleted: branches/2.0/R/plot.profile.fisherfit.R
===================================================================
--- branches/2.0/R/plot.profile.fisherfit.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/plot.profile.fisherfit.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,16 +0,0 @@
-`plot.profile.fisherfit` <-
-    function (x, type = "l", ...) 
-{
-    tmp <- attr(x, "original.fit")
-    est <- tmp$coefficients
-    se <- tmp$std.err
-    alpha <- x$alpha[, 1]
-    tau <- x$alpha[, 2]
-    sp <- spline(tau, alpha)
-    plot(sp$x, sp$y, type = type, xlab = "alpha", ylab = "tau", 
-         ...)
-    abline(-est/se, 1/se, lty = 2)
-    abline(v = est, lty = 3)
-    abline(h = 0, lty = 3)
-    invisible()
-}

Modified: branches/2.0/R/plot.specaccum.R
===================================================================
--- branches/2.0/R/plot.specaccum.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/plot.specaccum.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,17 +1,32 @@
 `plot.specaccum` <-
-    function(x, add = FALSE, ci = 2, ci.type = c("bar","line","polygon"), 
-             col = par("fg"), ci.col = col, ci.lty = 1, xlab,
-             ylab = x$method, ylim, xvar = c("sites", "individuals"), ...)
+    function(x, add = FALSE, random = FALSE, ci = 2,
+             ci.type = c("bar","line","polygon"), col = par("fg"), ci.col = col,
+             ci.lty = 1, xlab, ylab = x$method, ylim,
+             xvar = c("sites", "individuals", "effort"), ...)
 {
+    if(random && x$method != "random")
+        stop("random = TRUE can be used only with method='random'")
     xvar <- match.arg(xvar)
+    ## adjust weights to number of sites
+    if (random && !is.null(x$weights) && xvar == "sites") {
+        n <- length(x$effort)
+        adj <- n/x$effort[n]
+    } else {
+        adj <- 1
+    }
     xaxvar <- x[[xvar]]
     if (missing(xlab))
         xlab <- paste(toupper(substring(xvar, 1, 1)),
                               substring(xvar, 2), sep="")
+    if (random)
+        ci <- FALSE
     ci.type <- match.arg(ci.type)
     if (!add) {
         if (missing(ylim))
-            ylim <- c(1, max(x$richness, x$richness + ci*x$sd))
+            if (random)
+                ylim <- c(1, max(x$perm, na.rm = TRUE))
+            else
+                ylim <- c(1, max(x$richness, x$richness + ci*x$sd, na.rm = TRUE))
         plot(xaxvar, x$richness, xlab=xlab, ylab=ylab, ylim=ylim,
              type="n", ...)
     }
@@ -25,6 +40,21 @@
                  c(x$richness - ci*x$sd, rev(x$richness + ci*x$sd)), col=ci.col,
                  lty=ci.lty,  ...)
                )
-    lines(xaxvar, x$richness,col=col, ...)
+    if (random) {
+        if (is.null(x$weights)) {
+            for(i in seq_len(NCOL(x$perm)))
+                lines(xaxvar, x$perm[,i], col=col, ...)
+        } else {
+            for(i in seq_len(NCOL(x$perm)))
+                lines(x$weights[,i]*adj, x$perm[,i], col=col, ...)
+        }
+    } else
+        lines(xaxvar, x$richness,col=col, ...)
     invisible()
 }
+
+`lines.specaccum` <-
+    function(x, ...)
+{
+    plot(x, add = TRUE, ...)
+}

Modified: branches/2.0/R/print.cca.R
===================================================================
--- branches/2.0/R/print.cca.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/print.cca.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -27,7 +27,7 @@
     ## Remove "Proportion" if only one component
     if (is.null(x$CCA) && is.null(x$pCCA))
         tbl <- tbl[,-2]
-    printCoefmat(tbl, digits = digits, na.print = "")
+    printCoefmat(tbl, digits = digits, na.print = "", zap.ind = 1:2)
     cat("Inertia is", x$inertia, "\n")
     if (!is.null(x$CCA$alias))
         cat("Some constraints were aliased because they were collinear (redundant)\n")

Modified: branches/2.0/R/print.fisherfit.R
===================================================================
--- branches/2.0/R/print.fisherfit.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/print.fisherfit.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,12 +1,8 @@
-"print.fisherfit" <-
+`print.fisherfit` <-
     function (x, ...) 
 {
     cat("\nFisher log series model\n")
-    cat("No. of species:", sum(x$fisher), "\n\n")
-    out <- cbind(x$estimate, sqrt(diag(solve(x$hessian))))
-    colnames(out) <- c("Estimate", "Std. Error")
-    rownames(out) <- "alpha"
-    printCoefmat(out)
-    cat("\n")
+    cat("No. of species:", sum(x$fisher), "\n")
+    cat("Fisher alpha:  ", x$estimate, "\n\n")
     invisible(x)
 }

Deleted: branches/2.0/R/profile.fisherfit.R
===================================================================
--- branches/2.0/R/profile.fisherfit.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/profile.fisherfit.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,43 +0,0 @@
-"profile.fisherfit" <-
-    function (fitted, alpha = 0.01, maxsteps = 20, del = zmax/5, ...) 
-{
-    Dev.logseries <- function(n.r, p, N) {
-        r <- as.numeric(names(n.r))
-        x <- N/(N + p)
-        logmu <- log(p) + log(x) * r - log(r)
-        lhood <- -sum(n.r * (logmu - log(n.r)) + 1) - p * log(1 -
-                                                              x)
-        lhood
-    }
-    par <- fitted$estimate
-    names(par) <- "alpha"
-    std.err <- sqrt(diag(solve(fitted$hessian)))
-    minll <- fitted$minimum
-    nr <- fitted$fisher
-    N <- sum(as.numeric(names(nr)) * nr)
-    zmax <- sqrt(qchisq(1 - alpha/2, 1))
-    zi <- 0
-    bi <- par
-    for (sgn in c(-1, 1)) {
-        step <- 0
-        z <- 0
-        b <- 0
-        while ((step <- step + 1) < maxsteps && abs(z) < zmax) {
-            b <- par + sgn * step * del * std.err
-            fm <- Dev.logseries(nr, b, N)
-            zz <- 2 * (fm - minll)
-            if (zz > -0.001) 
-                zz <- max(zz, 0)
-            else stop("profiling has found a better solution, so original fit had not converged")
-            z <- sgn * sqrt(zz)
-            bi <- c(bi, b)
-            zi <- c(zi, z)
-        }
-    }
-    si <- order(bi)
-    out <- list()
-    out$alpha <- data.frame(tau = zi[si], par.vals = bi[si])
-    attr(out, "original.fit") <- list(coefficients = par, std.err = std.err)
-    class(out) <- c("profile.fisherfit", "profile.glm", "profile")
-    out
-}

Modified: branches/2.0/R/renyiaccum.R
===================================================================
--- branches/2.0/R/renyiaccum.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/renyiaccum.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,6 +1,9 @@
 `renyiaccum` <-
-function(x, scales=c(0, 0.5, 1, 2, 4, Inf), permutations = 100, raw = FALSE, ...)
-{ 
+function(x, scales=c(0, 0.5, 1, 2, 4, Inf), permutations = 100,
+         raw = FALSE, subset, ...)
+{
+    if (!missing(subset))
+        x <- subset(x, subset)
     x <- as.matrix(x)
     n <- nrow(x)
     p <- ncol(x)

Modified: branches/2.0/R/specaccum.R
===================================================================
--- branches/2.0/R/specaccum.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/specaccum.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,7 +1,15 @@
 `specaccum` <-
     function (comm, method = "exact", permutations = 100, conditioned=TRUE,
-              gamma="jack1", ...)
+              gamma="jack1", w = NULL, subset, ...)
 {
+    METHODS <- c("collector", "random", "exact", "rarefaction", "coleman")
+    method <- match.arg(method, METHODS)
+    if (!is.null(w) && !(method %in% c("random", "collector")))
+        stop(gettextf("weights 'w' can be only used with methods 'random' and 'collector'"))
+    if (!missing(subset)) {
+        comm <- subset(comm, subset)
+        w <- subset(w, subset)
+    }
     x <- comm
     x <- as.matrix(x)
     x <- x[, colSums(x) > 0, drop=FALSE]
@@ -15,22 +23,34 @@
     accumulator <- function(x, ind) {
         rowSums(apply(x[ind, ], 2, cumsum) > 0)
     }
-    METHODS <- c("collector", "random", "exact", "rarefaction", "coleman")
-    method <- match.arg(method, METHODS)
     specaccum <- sdaccum <- sites <- perm <- NULL
     if (n == 1 && method != "rarefaction")
         message("No actual accumulation since only 1 site provided")
     switch(method, collector = {
         sites <- 1:n
+        xout <- weights <- cumsum(w)
         specaccum <- accumulator(x, sites)
     }, random = {
         perm <- array(dim = c(n, permutations))
+        if (!is.null(w))
+            weights <- array(dim = c(n, permutations))
         for (i in 1:permutations) {
-            perm[, i] <- accumulator(x, sample(n))
+            perm[, i] <- accumulator(x, ord <- sample(n))
+            if(!is.null(w))
+                weights[,i] <- cumsum(w[ord])
         }
         sites <- 1:n
-        specaccum <- apply(perm, 1, mean)
-        sdaccum <- apply(perm, 1, sd)
+        if (is.null(w)) {
+            specaccum <- apply(perm, 1, mean)
+            sdaccum <- apply(perm, 1, sd)
+        } else {
+            sumw <- sum(w)
+            xout <- seq(sumw/n, sumw, length.out = n)
+            intx <- sapply(seq_len(n), function(i)
+                           approx(weights[,i], perm[,i], xout = xout)$y)
+            specaccum <- apply(intx, 1, mean)
+            sdaccum <- apply(intx, 1, sd)
+        }
     }, exact = {
         freq <- colSums(x > 0)
         freq <- freq[freq > 0]
@@ -87,6 +107,10 @@
     })
     out <- list(call = match.call(), method = method, sites = sites,
                 richness = specaccum, sd = sdaccum, perm = perm)
+    if (!is.null(w)) {
+        out$weights <- weights
+        out$effort <- xout
+    }
     if (method == "rarefaction")
         out$individuals <- ind
     class(out) <- "specaccum"

Modified: branches/2.0/R/tsallisaccum.R
===================================================================
--- branches/2.0/R/tsallisaccum.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/tsallisaccum.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -1,6 +1,9 @@
 tsallisaccum <-
-function (x, scales = seq(0, 2, 0.2), permutations = 100, raw = FALSE, ...)
+function (x, scales = seq(0, 2, 0.2), permutations = 100, raw = FALSE,
+          subset, ...)
 {
+    if (!missing(subset))
+        x <- subset(x, subset)
     x <- as.matrix(x)
     n <- nrow(x)
     p <- ncol(x)

Modified: branches/2.0/R/vectorfit.R
===================================================================
--- branches/2.0/R/vectorfit.R	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/R/vectorfit.R	2013-12-05 11:50:52 UTC (rev 2807)
@@ -18,6 +18,7 @@
     H <- qr.fitted(Q, Pw)
     heads <- qr.coef(Q, Pw)
     r <- diag(cor(H, Pw)^2)
+    r[is.na(r)] <- 0
     heads <- decostand(heads, "norm", 2)
     heads <- t(heads)
     if (is.null(colnames(X))) 

Modified: branches/2.0/inst/ChangeLog
===================================================================
--- branches/2.0/inst/ChangeLog	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/inst/ChangeLog	2013-12-05 11:50:52 UTC (rev 2807)
@@ -4,8 +4,17 @@
 
 Version 2.0-10 (opened December 5, 2013)
 
+	* merge 2641: subset in renyi/spec/tsallisaccum.
+	* merge 2630,1,2: fisherfit new algo and delete profile & confint.
+	* merge 2628,9: plot vectorfit *should* work with constant
+	(non-variable) vectors: partial conflict, needs checking.
+	* merge 2627: zap zeros in print.cca.
+	* merge 2626: nestednodf fill and consinstency in quantitative
+	data.
 	* merge 2527: adapt permutest.betadisper to the CRAN release of
 	permute 0.8-0.
+	* merge 2451, 2454, 2455, 2465: weighted specaccum.
+	* conflicts (not applied): r2625 (oecosimu), 2638 (oecosimu.Rd)
 
 Version 2.0-9 (released September 25, 2013)
 

Modified: branches/2.0/man/diversity.Rd
===================================================================
--- branches/2.0/man/diversity.Rd	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/man/diversity.Rd	2013-12-05 11:50:52 UTC (rev 2807)
@@ -20,7 +20,7 @@
 drarefy(x, sample)
 rarecurve(x, step = 1, sample, xlab = "Sample Size", ylab = "Species",
    label = TRUE, ...)
-fisher.alpha(x, MARGIN = 1, se = FALSE, ...)
+fisher.alpha(x, MARGIN = 1, ...)
 specnumber(x, groups, MARGIN = 1)
 }
 
@@ -86,11 +86,7 @@
   \code{fisher.alpha} estimates the \eqn{\alpha} parameter of
   Fisher's logarithmic series (see \code{\link{fisherfit}}). 
   The estimation is possible only for genuine
-  counts of individuals. The function can optionally return standard
-  errors of \eqn{\alpha}.  These should be regarded only as rough
-  indicators of the accuracy: the confidence limits of \eqn{\alpha} are
-  strongly non-symmetric and the standard errors cannot be used in
-  Normal inference.
+  counts of individuals. 
   
   Function \code{specnumber} finds the number of species. With
   \code{MARGIN = 2}, it finds frequencies of species. If \code{groups}

Modified: branches/2.0/man/fisherfit.Rd
===================================================================
--- branches/2.0/man/fisherfit.Rd	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/man/fisherfit.Rd	2013-12-05 11:50:52 UTC (rev 2807)
@@ -2,9 +2,6 @@
 \alias{fisherfit}
 \alias{as.fisher}
 \alias{plot.fisherfit}
-\alias{profile.fisherfit}
-\alias{confint.fisherfit}
-\alias{plot.profile.fisherfit}
 \alias{prestonfit}
 \alias{prestondistr}
 \alias{as.preston}
@@ -25,9 +22,6 @@
 }
 \usage{
 fisherfit(x, ...)
-\method{confint}{fisherfit}(object, parm, level = 0.95, ...)
-\method{profile}{fisherfit}(fitted, alpha = 0.01, maxsteps = 20, del = zmax/5, 
-    ...)
 prestonfit(x, tiesplit = TRUE, ...)
 prestondistr(x, truncate = -1, ...)
 \method{plot}{prestonfit}(x, xlab = "Frequency", ylab = "Species", bar.col = "skyblue", 
@@ -45,12 +39,6 @@
 \arguments{
   \item{x}{Community data vector for fitting functions or their result
     object for \code{plot} functions.}
-  \item{object, fitted}{Fitted model.}
-  \item{parm}{Not used.}
-  \item{level}{The confidence level required.}
-  \item{alpha}{The extend of profiling as significance.}
-  \item{maxsteps}{Maximum number of steps in profiling.}
-  \item{del}{Step length.}
   \item{tiesplit}{Split frequencies \eqn{1, 2, 4, 8} etc between adjacent 
     octaves.}
   \item{truncate}{Truncation point for log-Normal model, in log2
@@ -73,9 +61,8 @@
 \details{
   In Fisher's logarithmic series the expected
   number of species \eqn{f} with \eqn{n} observed individuals is
-  \eqn{f_n = \alpha x^n / n} (Fisher et al. 1943). The estimation
-  follows Kempton & Taylor (1974) and uses function
-  \code{\link{nlm}}. The estimation is possible only for genuine
+  \eqn{f_n = \alpha x^n / n} (Fisher et al. 1943).
+  The estimation is possible only for genuine
   counts of individuals. The parameter \eqn{\alpha} is used as a
   diversity index, and \eqn{\alpha} and its standard error can be
   estimated with a separate function \code{\link{fisher.alpha}}. The
@@ -84,20 +71,6 @@
   function \code{as.fisher} transforms abundance data into Fisher
   frequency table.
 
-  Function  \code{fisherfit} estimates the standard error of
-  \eqn{\alpha}{alpha}. However, the confidence limits cannot be directly
-  estimated from the standard errors, but you should use function
-  \code{confint} based on profile likelihood. Function \code{confint}
-  uses function \code{\link[MASS]{confint.glm}} of the \pkg{MASS}
-  package, using \code{profile.fisherfit} for the profile
-  likelihood. Function \code{profile.fisherfit} follows
-  \code{\link[MASS]{profile.glm}} and finds the \eqn{\tau}{tau} parameter or
-  signed square root of two times log-Likelihood profile. The profile can
-  be inspected with a \code{plot} function which shows the \eqn{\tau}{tau}
-  and a dotted line corresponding to the Normal assumption: if standard
-  errors can be directly used in Normal inference these two lines
-  are similar.
-
   Preston (1948) was not satisfied with Fisher's model which seemed to
   imply infinite species richness, and postulated that rare species is
   a diminishing class and most species are in the middle of frequency
@@ -162,11 +135,8 @@
   \code{method}. Function \code{prestondistr} omits the entry
   \code{fitted}.  The function \code{fisherfit} returns the result of
   \code{\link{nlm}}, where item \code{estimate} is \eqn{\alpha}. The
-  result object is amended with the following items:
-  \item{df.residuals}{Residual degrees of freedom.}
-  \item{nuisance}{Parameter \eqn{x}.}  \item{fisher}{Observed data
-  from \code{as.fisher}.}
-
+  result object is amended with the \code{nuisance} parameter and item
+  \code{fisher} for the observed data from \code{as.fisher}
 }
 \references{
   Fisher, R.A., Corbet, A.S. & Williams, C.B. (1943). The relation
@@ -174,10 +144,6 @@
   random sample of animal population. \emph{Journal of Animal Ecology}
   12: 42--58.
 
-  Kempton, R.A. & Taylor, L.R. (1974). Log-series and log-normal
-  parameters as diversity discriminators for
-  Lepidoptera. \emph{Journal of Animal Ecology} 43: 381--399.
-
   Preston, F.W. (1948) The commonness and rarity of
   species. \emph{Ecology} 29, 254--283.
 
@@ -186,7 +152,7 @@
   distribution. \emph{Journal of Animal Ecology} 74, 409--422.
 }
 
-\author{Bob O'Hara (\code{fisherfit}) and Jari Oksanen. }
+\author{Bob O'Hara and Jari Oksanen. }
 
 \seealso{\code{\link{diversity}}, \code{\link{fisher.alpha}},
   \code{\link{radfit}}, \code{\link{specpool}}. Function
@@ -200,8 +166,6 @@
 data(BCI)
 mod <- fisherfit(BCI[5,])
 mod
-plot(profile(mod))
-confint(mod)
 # prestonfit seems to need large samples
 mod.oct <- prestonfit(colSums(BCI))
 mod.ll <- prestondistr(colSums(BCI))

Modified: branches/2.0/man/renyi.Rd
===================================================================
--- branches/2.0/man/renyi.Rd	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/man/renyi.Rd	2013-12-05 11:50:52 UTC (rev 2807)
@@ -14,16 +14,17 @@
   \code{renyiaccum} finds these statistics with accumulating sites.
 }
 \usage{
-renyi(x, scales = c(0, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, Inf), hill = FALSE)
+renyi(x, scales = c(0, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, Inf),
+   hill = FALSE)
 \method{plot}{renyi}(x, ...)
 renyiaccum(x, scales = c(0, 0.5, 1, 2, 4, Inf), permutations = 100, 
-    raw = FALSE, ...)
-\method{plot}{renyiaccum} (x, what = c("mean", "Qnt 0.025", "Qnt 0.975"), type = "l", 
+    raw = FALSE, subset, ...)
+\method{plot}{renyiaccum}(x, what = c("mean", "Qnt 0.025", "Qnt 0.975"), type = "l", 
     ...)
-\method{persp}{renyiaccum} (x, theta = 220, col = heat.colors(100), zlim, ...)
+\method{persp}{renyiaccum}(x, theta = 220, col = heat.colors(100), zlim, ...)
 rgl.renyiaccum(x, rgl.height = 0.2, ...)
 }
-%- maybe also 'usage' for other objects documented here.
+
 \arguments{
   \item{x}{Community data matrix or plotting object. }
   \item{scales}{Scales of \enc{Rényi}{Renyi} diversity.}
@@ -33,6 +34,8 @@
   \item{raw}{if \code{FALSE} then return summary statistics of
     permutations, and if \code{TRUE} then returns the individual
     permutations.}
+  \item{subset}{logical expression indicating sites (rows) to keep: missing
+    values are taken as \code{FALSE}.}
   \item{what}{Items to be plotted.}
   \item{type}{Type of plot, where \code{type = "l"} means lines.}
   \item{theta}{Angle defining the viewing direction (azimuthal) in

Modified: branches/2.0/man/specaccum.Rd
===================================================================
--- branches/2.0/man/specaccum.Rd	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/man/specaccum.Rd	2013-12-05 11:50:52 UTC (rev 2807)
@@ -17,10 +17,11 @@
 }
 \usage{
 specaccum(comm, method = "exact", permutations = 100,
-          conditioned =TRUE, gamma = "jack1",  ...)
-\method{plot}{specaccum}(x, add = FALSE, ci = 2, ci.type = c("bar", "line", "polygon"), 
-    col = par("fg"), ci.col = col, ci.lty = 1, xlab, 
-    ylab = x$method, ylim, xvar = c("sites", "individuals"), ...)
+          conditioned =TRUE, gamma = "jack1",  w = NULL, subset, ...)
+\method{plot}{specaccum}(x, add = FALSE, random = FALSE, ci = 2, 
+    ci.type = c("bar", "line", "polygon"), col = par("fg"), ci.col = col, 
+    ci.lty = 1, xlab, ylab = x$method, ylim, 
+    xvar = c("sites", "individuals", "effort"), ...)
 \method{boxplot}{specaccum}(x, add = FALSE, ...)
 fitspecaccum(object, model, method = "random", ...)
 \method{plot}{fitspecaccum}(x, col = par("fg"), lty = 1, xlab = "Sites", 
@@ -43,9 +44,14 @@
   \item{conditioned}{ Estimation of standard deviation is conditional on
     the empirical dataset for the exact SAC}
   \item{gamma}{Method for estimating the total extrapolated number of species in the
-    survey area by function \code{\link{specpool}}} 
+    survey area by function \code{\link{specpool}}}
+  \item{w}{Weights giving the sampling effort (an experimental feature
+    that may be removed).}
+  \item{subset}{logical expression indicating sites (rows) to keep: missing
+    values are taken as \code{FALSE}.}
   \item{x}{A \code{specaccum} result object}
   \item{add}{Add to an existing graph.}
+  \item{random}{\dots}
   \item{ci}{Multiplier used to get confidence intervals from standard
     deviation (standard error of the estimate). Value \code{ci = 0}
     suppresses drawing confidence intervals.}

Modified: branches/2.0/man/tsallis.Rd
===================================================================
--- branches/2.0/man/tsallis.Rd	2013-12-05 11:14:49 UTC (rev 2806)
+++ branches/2.0/man/tsallis.Rd	2013-12-05 11:50:52 UTC (rev 2807)
@@ -9,65 +9,112 @@
 }
 \usage{
 tsallis(x, scales = seq(0, 2, 0.2), norm = FALSE, hill = FALSE)
-tsallisaccum(x, scales = seq(0, 2, 0.2), permutations = 100, raw = FALSE, ...)
+tsallisaccum(x, scales = seq(0, 2, 0.2), permutations = 100, 
+   raw = FALSE, subset, ...)
 \method{persp}{tsallisaccum}(x, theta = 220, phi = 15, col = heat.colors(100), zlim, ...)
 }
-%- maybe also 'usage' for other objects documented here.
+
 \arguments{
   \item{x}{Community data matrix or plotting object. }
   \item{scales}{Scales of Tsallis diversity.}
-  \item{norm}{Logical, if \code{TRUE} diversity values are normalized by their maximum (diversity value at equiprobability conditions).}
+
+  \item{norm}{Logical, if \code{TRUE} diversity values are normalized
+    by their maximum (diversity value at equiprobability conditions).}
+
   \item{hill}{Calculate Hill numbers.}
-  \item{permutations}{Number of random permutations in accumulating sites.}
-  \item{raw}{If \code{FALSE} then return summary statistics of permutations, and if TRUE then returns the individual permutations.}
-  \item{theta, phi}{angles defining the viewing direction. \code{theta} gives the azimuthal direction and \code{phi} the colatitude.}
-  \item{col}{Colours used for surface.}
-  \item{zlim}{Limits of vertical axis.}
-  \item{\dots}{Other arguments which are passed to \code{tsallis} and to graphical functions.}
+  
+  \item{permutations}{Number of random permutations in accumulating
+    sites.}
 
-}
-\details{
-The Tsallis diversity (also equivalent to Patil and Taillie diversity) is a one-parametric generalised entropy function, defined as:
+  \item{raw}{If \code{FALSE} then return summary statistics of
+    permutations, and if TRUE then returns the individual
+    permutations.}
 
+  \item{subset}{logical expression indicating sites (rows) to keep:
+    missing values are taken as \code{FALSE}.}
+
+  \item{theta, phi}{angles defining the viewing
+    direction. \code{theta} gives the azimuthal direction and
+    \code{phi} the colatitude.}
+  
+  \item{col}{Colours used for surface.}  \item{zlim}{Limits of
+  vertical axis.}  
+
+  \item{\dots}{Other arguments which are passed to \code{tsallis} and
+    to graphical functions.}
+
+} 
+
+\details{ The Tsallis diversity (also equivalent to Patil and Taillie
+diversity) is a one-parametric generalised entropy function, defined
+as:
+
 \deqn{H_q = \frac{1}{q-1} (1-\sum_{i=1}^S p_i^q)}{H.q = 1/(q-1)(1-sum(p^q))}
 
-where \eqn{q} is a scale parameter, \eqn{S} the number of species in the sample (Tsallis 1988, Tothmeresz 1995). This diversity is concave for all \eqn{q>0}, but non-additive (Keylock 2005). For \eqn{q=0} it gives the number of species minus one, as \eqn{q} tends to 1 this gives Shannon diversity, for \eqn{q=2} this gives the Simpson index (see function \code{\link{diversity}}).
+where \eqn{q} is a scale parameter, \eqn{S} the number of species in
+the sample (Tsallis 1988, Tothmeresz 1995). This diversity is concave
+for all \eqn{q>0}, but non-additive (Keylock 2005). For \eqn{q=0} it
+gives the number of species minus one, as \eqn{q} tends to 1 this
+gives Shannon diversity, for \eqn{q=2} this gives the Simpson index
+(see function \code{\link{diversity}}).
 
-If \code{norm = TRUE}, \code{tsallis} gives values normalized by the maximum:
+If \code{norm = TRUE}, \code{tsallis} gives values normalized by the
+maximum:
 
 \deqn{H_q(max) = \frac{S^{1-q}-1}{1-q}}{H.q(max) = (S^(1-q)-1)/(1-q)}
 
-where \eqn{S} is the number of species. As \eqn{q} tends to 1, maximum is defined as \eqn{ln(S)}.
+where \eqn{S} is the number of species. As \eqn{q} tends to 1, maximum
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/vegan -r 2807


More information about the Vegan-commits mailing list