[Vegan-commits] r1754 - in pkg/vegan: . R inst man tests/Examples

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 24 12:30:55 CEST 2011


Author: jarioksa
Date: 2011-08-24 12:30:54 +0200 (Wed, 24 Aug 2011)
New Revision: 1754

Added:
   pkg/vegan/R/predict.specaccum.R
Removed:
   pkg/vegan/R/fitted.specaccum.R
Modified:
   pkg/vegan/NAMESPACE
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/specaccum.Rd
   pkg/vegan/tests/Examples/vegan-Ex.Rout.save
Log:
remove fitted.specaccum: it was dangerous as it confused fitted for fitspecaccum

Modified: pkg/vegan/NAMESPACE
===================================================================
--- pkg/vegan/NAMESPACE	2011-08-24 08:03:33 UTC (rev 1753)
+++ pkg/vegan/NAMESPACE	2011-08-24 10:30:54 UTC (rev 1754)
@@ -157,7 +157,6 @@
 S3method(fitted, procrustes)
 S3method(fitted, radfit)
 S3method(fitted, rda)
-S3method(fitted, specaccum)
 # goodness: vegan
 S3method(goodness, cca)
 S3method(goodness, metaMDS)

Deleted: pkg/vegan/R/fitted.specaccum.R
===================================================================
--- pkg/vegan/R/fitted.specaccum.R	2011-08-24 08:03:33 UTC (rev 1753)
+++ pkg/vegan/R/fitted.specaccum.R	2011-08-24 10:30:54 UTC (rev 1754)
@@ -1,25 +0,0 @@
-`fitted.specaccum` <-
-    function(object, ...)
-{
-    object$richness
-}
-
-`predict.specaccum` <-
-    function(object, newdata, interpolation = c("linear", "spline"), ...)
-{
-    if (missing(newdata))
-        out <- object$richness
-    else {
-        interpolation <- match.arg(interpolation)
-        newdata <- drop(as.matrix(newdata))
-        if (length(dim(newdata)) > 1)
-            stop("function accepts only one variable as 'newdata'")
-        if (interpolation == "linear")
-            out <- approx(x = object$sites, y = object$richness,
-                          xout = newdata, rule = 1)$y
-        else
-            out <- spline(x = object$sites, y = object$richness,
-                          xout = newdata, ...)$y
-    }
-    out
-}

Copied: pkg/vegan/R/predict.specaccum.R (from rev 1753, pkg/vegan/R/fitted.specaccum.R)
===================================================================
--- pkg/vegan/R/predict.specaccum.R	                        (rev 0)
+++ pkg/vegan/R/predict.specaccum.R	2011-08-24 10:30:54 UTC (rev 1754)
@@ -0,0 +1,19 @@
+`predict.specaccum` <-
+    function(object, newdata, interpolation = c("linear", "spline"), ...)
+{
+    if (missing(newdata))
+        out <- object$richness
+    else {
+        interpolation <- match.arg(interpolation)
+        newdata <- drop(as.matrix(newdata))
+        if (length(dim(newdata)) > 1)
+            stop("function accepts only one variable as 'newdata'")
+        if (interpolation == "linear")
+            out <- approx(x = object$sites, y = object$richness,
+                          xout = newdata, rule = 1)$y
+        else
+            out <- spline(x = object$sites, y = object$richness,
+                          xout = newdata, ...)$y
+    }
+    out
+}

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-08-24 08:03:33 UTC (rev 1753)
+++ pkg/vegan/inst/ChangeLog	2011-08-24 10:30:54 UTC (rev 1754)
@@ -4,13 +4,13 @@
 
 Version 1.92-1 (opened August 23, 2011)
 
-	* specaccum, fitspecaccum: fitted() and predict() methods for
-	specaccum. The fitted() method returns the fitted richness, and
-	predict(..., newdata) can select items from richness with integer
-	'newdata'. For fitspecaccum(), the predict() is performed to each
-	fitted model, allowing non-interger values. There is no special
-	fitted() models, but fitspecaccum() is written so that default
-	fitted(), residuals() and coef() work.  
+	* specaccum, fitspecaccum: gained predict() methods. With
+	specaccum() predict(..., newdata) can estimate values for
+	'newdata' with linear or spline interpolation if necessary.
+	Without 'newdata' the function returns the the fitted expected
+	richness.  With fitspecaccum(), the predict.nls() is performed to
+	each fitted model. Function fitspecaccum() is written so that
+	default fitted(), residuals() and coef() work.
 
 	* NAMESPACE: imports nobs from permute_0.5-3 in R 2.12.2 and older
 	which do not yet have nobs() generic.

Modified: pkg/vegan/man/specaccum.Rd
===================================================================
--- pkg/vegan/man/specaccum.Rd	2011-08-24 08:03:33 UTC (rev 1753)
+++ pkg/vegan/man/specaccum.Rd	2011-08-24 10:30:54 UTC (rev 1754)
@@ -6,7 +6,6 @@
 \alias{boxplot.specaccum}
 \alias{fitspecaccum}
 \alias{plot.fitspecaccum}
-\alias{fitted.specaccum}
 \alias{predict.specaccum}
 \alias{predict.fitspecaccum}
 
@@ -26,7 +25,6 @@
 fitspecaccum(object, model, method = "random", ...)
 \method{plot}{fitspecaccum}(x, col = par("fg"), lty = 1, xlab = "Sites", 
     ylab = x$method, ...) 
-\method{fitted}{specaccum}(object, ...)
 \method{predict}{specaccum}(object, newdata, interpolation = c("linear", "spline"), ...)
 \method{predict}{fitspecaccum}(object, newdata, ...)
 }
@@ -106,13 +104,13 @@
   The function has a \code{plot} method. In addition, \code{method =
   "random"} has \code{summary} and \code{boxplot} methods. 
 
-  Function \code{fitted} returns the fitted values, and \code{predict}
-  can return the values corresponding to \code{newdata} using linear
-  (function \code{\link{approx}}) or spline (function
-  \code{\link{spline}}) interpolation. The function cannot extrapolate
-  with linear interpolation, and with spline the type and sensibility
-  of the extrapolation depends on argument \code{method} which can be
-  given and is passed to \code{\link{spline}}.
+  Function \code{predict} can return the values corresponding to
+  \code{newdata} using linear (\code{\link{approx}}) or spline
+  (\code{\link{spline}}) interpolation. The function cannot
+  extrapolate with linear interpolation, and with spline the type and
+  sensibility of the extrapolation depends on argument \code{method}
+  which is passed to \code{\link{spline}}.  If \code{newdata} is not
+  given, the function returns the values corresponding to the data.
 
   Function \code{fitspecaccum} fits a nonlinear (\code{\link{nls}})
   self-starting species accumulation model. The input \code{object}
@@ -133,9 +131,8 @@
   model specification and details.
 
   Function \code{predict} uses \code{\link{predict.nls}}, and you can
-  pass all arguments to that function. In addition, \R default methods
-  \code{fitted}, \code{residuals} and \code{coef} work on the result
-  object.
+  pass all arguments to that function. In addition, \code{fitted},
+  \code{residuals} and \code{coef} work on the result object.
 
   Nonlinear regression may fail for any reason, and some of the
   \code{fitspecaccum} models are fragile and may not succeed.  

Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save
===================================================================
--- pkg/vegan/tests/Examples/vegan-Ex.Rout.save	2011-08-24 08:03:33 UTC (rev 1753)
+++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save	2011-08-24 10:30:54 UTC (rev 1754)
@@ -4699,7 +4699,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x10287b4d8>
+<environment: 0x103b0b1c8>
 
 Estimated degrees of freedom:
 6.4351  total = 7.435071 
@@ -4715,7 +4715,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x1063282d0>
+<environment: 0x106462988>
 
 Estimated degrees of freedom:
 6.0761  total = 7.076141 
@@ -4871,7 +4871,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x106f94150>
+<environment: 0x106a3ced8>
 
 Estimated degrees of freedom:
 8.9275  total = 9.927492 
@@ -4884,7 +4884,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x10248f178>
+<environment: 0x106d97520>
 
 Estimated degrees of freedom:
 7.7529  total = 8.75294 
@@ -4897,7 +4897,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x107583468>
+<environment: 0x1066c0430>
 
 Estimated degrees of freedom:
 8.8962  total = 9.89616 
@@ -6024,8 +6024,8 @@
 > ### Name: specaccum
 > ### Title: Species Accumulation Curves
 > ### Aliases: specaccum print.specaccum summary.specaccum plot.specaccum
-> ###   boxplot.specaccum fitspecaccum plot.fitspecaccum fitted.specaccum
-> ###   predict.specaccum predict.fitspecaccum
+> ###   boxplot.specaccum fitspecaccum plot.fitspecaccum predict.specaccum
+> ###   predict.fitspecaccum
 > ### Keywords: univar models
 > 
 > ### ** Examples
@@ -6168,13 +6168,14 @@
       Asym       xmid      slope 
 258.440682   2.442061   1.858694 
 > fitted(mod1)
- [1]  90.7800 121.6098 139.0459 150.7116 159.2363 165.8306 171.1421 175.5532
- [9] 179.3056 182.5604 185.4292 187.9914 190.3056 192.4155 194.3545 196.1488
-[17] 197.8188 199.3810 200.8487 202.2329 203.5425 204.7851 205.9671 207.0937
-[25] 208.1696 209.1987 210.1844 211.1296 212.0371 212.9090 213.7474 214.5541
-[33] 215.3308 216.0789 216.7998 217.4947 218.1647 218.8109 219.4342 220.0355
-[41] 220.6157 221.1755 221.7156 222.2368 222.7397 223.2249 223.6930 224.1445
-[49] 224.5800 225.0000
+ [1]  94.34749 121.23271 137.45031 148.83053 157.45735 164.31866 169.95946
+ [8] 174.71115 178.78954 182.34254 185.47566 188.26658 190.77402 193.04337
+[15] 195.11033 197.00350 198.74606 200.35705 201.85227 203.24499 204.54643
+[22] 205.76612 206.91229 207.99203 209.01150 209.97609 210.89054 211.75903
+[29] 212.58527 213.37256 214.12386 214.84180 215.52877 216.18692 216.81820
+[36] 217.42437 218.00703 218.56767 219.10762 219.62811 220.13027 220.61514
+[43] 221.08369 221.53679 221.97528 222.39991 222.81138 223.21037 223.59747
+[50] 223.97327
 > plot(sp1)
 > ## Add Lomolino model using argument 'add'
 > plot(mod1, add = TRUE, col=2, lwd=2)
@@ -7121,7 +7122,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x1088e0720>
+<environment: 0x1083443f8>
 
 Estimated degrees of freedom:
 2  total = 3 
@@ -7586,7 +7587,7 @@
 > ### * <FOOTER>
 > ###
 > cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed:  102.422 1.06 104.995 0 0 
+Time elapsed:  104.154 1.15 107.798 0 0 
 > grDevices::dev.off()
 null device 
           1 



More information about the Vegan-commits mailing list