[Vegan-commits] r1616 - in branches/1.17: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun May 29 16:46:58 CEST 2011


Author: jarioksa
Date: 2011-05-29 16:46:57 +0200 (Sun, 29 May 2011)
New Revision: 1616

Modified:
   branches/1.17/R/ordiR2step.R
   branches/1.17/R/specnumber.R
   branches/1.17/inst/ChangeLog
   branches/1.17/man/MOStest.Rd
   branches/1.17/man/diversity.Rd
   branches/1.17/man/ordistep.Rd
   branches/1.17/man/vegan-package.Rd
Log:
merged 41588, 1609, 1614, 1615: MOStest.Rd, ordiR2step and speed.ups

Modified: branches/1.17/R/ordiR2step.R
===================================================================
--- branches/1.17/R/ordiR2step.R	2011-05-29 14:10:26 UTC (rev 1615)
+++ branches/1.17/R/ordiR2step.R	2011-05-29 14:46:57 UTC (rev 1616)
@@ -23,10 +23,15 @@
         scope <- delete.response(formula(scope))
     if (!inherits(scope, "formula"))
         scope <- reformulate(scope)
-    R2.all <- RsquareAdj(update(object, scope))$adj.r.squared
+    R2.all <- RsquareAdj(update(object, scope))
     ## Check that the full model can be evaluated
-    if (is.na(R2.all))
-        stop("the upper scope cannot be fitted (too many terms?)")
+    if (is.na(R2.all$adj.r.squared)) {
+        if (R2.all$r.squared > 0.999)
+            stop("the upper scope cannot be fitted (too many terms?)")
+        else
+            stop("upper scope cannot be fitted (Condition() in scope?)")
+    }
+    R2.all <- R2.all$adj.r.squared
     ## Collect data to anotab returned as the 'anova' object
     anotab <-  list()
     ## Step forward and continue as long as R2.adj improves and R2.adj

Modified: branches/1.17/R/specnumber.R
===================================================================
--- branches/1.17/R/specnumber.R	2011-05-29 14:10:26 UTC (rev 1615)
+++ branches/1.17/R/specnumber.R	2011-05-29 14:46:57 UTC (rev 1616)
@@ -1,6 +1,13 @@
 `specnumber` <-
-    function(x, MARGIN = 1)
+    function(x, groups, MARGIN = 1)
 {
+    if (!missing(groups)) {
+        if (length(groups) == 1)
+            groups <- rep(groups, nrow(x))
+        x <- aggregate(x, list(groups), max)
+        rownames(x) <- x[,1]
+        x <- x[,-1]
+    }
     if (length(dim(x)) > 1)
         apply(x > 0, MARGIN, sum)
     else

Modified: branches/1.17/inst/ChangeLog
===================================================================
--- branches/1.17/inst/ChangeLog	2011-05-29 14:10:26 UTC (rev 1615)
+++ branches/1.17/inst/ChangeLog	2011-05-29 14:46:57 UTC (rev 1616)
@@ -4,6 +4,12 @@
 
 Version 1.17-11 (opened April 29, 2011)
 
+	* merged r1615: inconsistent notatation in MOStest.Rd.
+
+	* merged r1614: ordiR2step more informative.
+
+	* merged r1609: specnumber gained 'groups'.
+
 	* merged r1603: cca/rda support functions failed with prc() and
 	now refuse its results.
 
@@ -15,6 +21,8 @@
 
 	* merged r1598: doc of nobs in cca.object.Rd.
 
+	* merged r1588: speed-up of examples.
+
 	* nobs: copied nobs() methods for vegan from r1596.
 	
 Version 1.17-10 (released April 27, 2011)

Modified: branches/1.17/man/MOStest.Rd
===================================================================
--- branches/1.17/man/MOStest.Rd	2011-05-29 14:10:26 UTC (rev 1615)
+++ branches/1.17/man/MOStest.Rd	2011-05-29 14:46:57 UTC (rev 1616)
@@ -56,7 +56,7 @@
   The function fits a quadratic curve \eqn{\mu = b_0 + b_1 x + b_2
   x^2} with given \code{\link{family}} and link function.  If \eqn{b_2
   < 0}, this defines a unimodal curve with highest point at \eqn{u =
-  -b_2/(2 b_3)} (ter Braak & Looman 1986). If \eqn{b_2 > 0}, the
+  -b_1/(2 b_2)} (ter Braak & Looman 1986). If \eqn{b_2 > 0}, the
   parabola has a minimum at \eqn{u} and the response is sometimes
   called \dQuote{bimodal}.  The null hypothesis is that the extreme
   point \eqn{u} is located within the interval given by points

Modified: branches/1.17/man/diversity.Rd
===================================================================
--- branches/1.17/man/diversity.Rd	2011-05-29 14:10:26 UTC (rev 1615)
+++ branches/1.17/man/diversity.Rd	2011-05-29 14:46:57 UTC (rev 1616)
@@ -18,7 +18,7 @@
 rrarefy(x, sample)
 drarefy(x, sample)
 fisher.alpha(x, MARGIN = 1, se = FALSE, ...)
-specnumber(x, MARGIN = 1)
+specnumber(x, groups, MARGIN = 1)
 }
 
 \arguments{
@@ -30,6 +30,8 @@
   \item{sample}{Subsample size for rarefying community, either a single
     value or a vector.}
   \item{se}{Estimate standard errors.}
+  \item{groups}{A grouping factor: if given, finds the total number of
+    species in each group.}
   \item{...}{Parameters passed to \code{\link{nlm}}}
 }
 \details{
@@ -77,8 +79,9 @@
   Normal inference.
   
   Function \code{specnumber} finds the number of species. With
-  \code{MARGIN = 2}, it finds frequencies of species. The function is
-  extremely simple, and shortcuts are easy in plain \R.
+  \code{MARGIN = 2}, it finds frequencies of species. If \code{groups}
+  is given, finds the total number of species in each group (see 
+  example on finding one kind of beta diversity with this option).
   
   Better stories can be told about Simpson's index than about
   Shannon's index, and still grander narratives about
@@ -138,12 +141,19 @@
 invsimp <- diversity(BCI, "inv")
 ## Unbiased Simpson of Hurlbert 1971 (eq. 5):
 unbias.simp <- rarefy(BCI, 2) - 1
+## Fisher alpha
 alpha <- fisher.alpha(BCI)
+## Plot all
 pairs(cbind(H, simp, invsimp, unbias.simp, alpha), pch="+", col="blue")
 ## Species richness (S) and Pielou's evenness (J):
 S <- specnumber(BCI) ## rowSums(BCI > 0) does the same...
 J <- H/log(S)
-
+## beta diversity defined as gamma/alpha - 1:
+data(dune)
+data(dune.env)
+alpha <- with(dune.env, tapply(specnumber(dune), Management, mean))
+gamma <- with(dune.env, specnumber(dune, Management))
+gamma/alpha - 1
 }
 \keyword{ univar }
 

Modified: branches/1.17/man/ordistep.Rd
===================================================================
--- branches/1.17/man/ordistep.Rd	2011-05-29 14:10:26 UTC (rev 1615)
+++ branches/1.17/man/ordistep.Rd	2011-05-29 14:46:57 UTC (rev 1616)
@@ -139,7 +139,6 @@
 
 ## With scope present, the default direction is "both"
 ordistep(mod0, scope = formula(mod1), perm.max = 200)
-ordistep(rda(dune ~ 1, dune.env), scope = formula(mod1), perm.max = 200)
 
 ## Example without scope. Default direction is "backward"
 ordistep(mod1, perm.max = 200) 
@@ -161,7 +160,6 @@
 
 ## Example of ordiR2step with direction = "forward"
 step.res <- ordiR2step(mod0, scope = formula(mod1), direction="forward") 
-step.res <- ordiR2step(mod0, scope = formula(mod1), direction="forward", trace=0) 
 step.res$anova  # Summary table
 }
 

Modified: branches/1.17/man/vegan-package.Rd
===================================================================
--- branches/1.17/man/vegan-package.Rd	2011-05-29 14:10:26 UTC (rev 1615)
+++ branches/1.17/man/vegan-package.Rd	2011-05-29 14:46:57 UTC (rev 1616)
@@ -76,14 +76,12 @@
 mod1 <- rda(dune ~ ., dune.env)
 mod1
 plot(mod1)
-## Overall permutation test for all variables
-anova(mod1)
-## Permutation test for terms added sequentially
-anova(mod1, by = "term")
 ## Automatic selection of variables by permutation P-values
 mod <- ordistep(mod0, scope=formula(mod1))
 mod
 plot(mod)
+## Permutation test for all variables
+anova(mod)
 ## Permutation test of "type III" effects, or significance when a term
 ## is added to the model after all other terms
 anova(mod, by = "margin")



More information about the Vegan-commits mailing list