[Vegan-commits] r2453 - in pkg/vegan: R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 27 14:08:24 CET 2013


Author: jarioksa
Date: 2013-02-27 14:08:24 +0100 (Wed, 27 Feb 2013)
New Revision: 2453

Modified:
   pkg/vegan/R/nestedtemp.R
   pkg/vegan/inst/ChangeLog
Log:
nestedtemp failed with fill < 0.0038

Modified: pkg/vegan/R/nestedtemp.R
===================================================================
--- pkg/vegan/R/nestedtemp.R	2013-02-26 15:58:41 UTC (rev 2452)
+++ pkg/vegan/R/nestedtemp.R	2013-02-27 13:08:24 UTC (rev 2453)
@@ -48,7 +48,23 @@
     fillfun <- function(x, p) 1 - (1-(1-x)^p)^(1/p)
     intfun <- function(p, fill)
         integrate(fillfun, lower=0, upper=1, p=p)$value - fill
-    p <- uniroot(intfun, c(0,20), fill=fill)$root
+    ## 'p' will depend on 'fill', and fill = 0.0038 correspond to p =
+    ## 20. Sometimes the fill is lower, and therefore we try() to see
+    ## if we need to move the bracket up. We should need to do this
+    ## very rarely.
+    lo <- 0
+    hi <- 20
+    repeat{
+        sol <- try(uniroot(intfun, c(lo,hi), fill=fill), silent = TRUE)
+        if (inherits(sol, "try-error")) {
+            if (hi > 640) # bail out
+                stop(gettextf("matrix is too sparse, fill is %g"), fill)
+            lo <- hi
+            hi <- hi + hi
+        } else
+            break
+    }
+    p <- sol$root
     ## row coordinates of the fill line for all matrix entries
     out <- matrix(0, nrow=length(r), ncol=length(c))
     for (i in 1:length(r))

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2013-02-26 15:58:41 UTC (rev 2452)
+++ pkg/vegan/inst/ChangeLog	2013-02-27 13:08:24 UTC (rev 2453)
@@ -4,6 +4,12 @@
 
 Version 2.1-27 (opened Februray 22, 2013)
 
+	* nestedtemp: function failed if the matrix fill was < 0.38%,
+	because the fill line parameter was outside the original
+	estimation bracket. Now bracket is moved up if the estimation
+	fails. The problem was reported by Carsten Dormann (Univ Freiburg)
+	and Benjamin A. Sikes (Lincoln University, NZ).
+	
 	* specaccum: gained argument 'w' for weights to give the sampling
 	effort. This resurrects a feature that was introduced in r1505 (22
 	Feb 2011) and 1507, and removed in r1606 (26 May 2011). It seems



More information about the Vegan-commits mailing list