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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 12 18:02:58 CET 2011


Author: gsimpson
Date: 2011-03-12 18:02:58 +0100 (Sat, 12 Mar 2011)
New Revision: 1539

Modified:
   pkg/vegan/R/ordisurf.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/ordisurf.Rd
Log:
add 'method' argument

Modified: pkg/vegan/R/ordisurf.R
===================================================================
--- pkg/vegan/R/ordisurf.R	2011-03-12 15:53:39 UTC (rev 1538)
+++ pkg/vegan/R/ordisurf.R	2011-03-12 17:02:58 UTC (rev 1539)
@@ -16,15 +16,16 @@
 }
 
 `ordisurf.default` <-
-    function (x, y, choices = c(1, 2), knots = 10, family = "gaussian", 
-              col = "red", thinplate = TRUE, add = FALSE, display = "sites", 
+    function (x, y, choices = c(1, 2), knots = 10, family = "gaussian",
+              col = "red", thinplate = TRUE, add = FALSE, display = "sites",
               w = weights(x), main, nlevels = 10, levels, labcex = 0.6,
-              bubble = FALSE, cex = 1, select = FALSE, ...) 
+              bubble = FALSE, cex = 1, select = FALSE,
+              method = "GCV.Cp", ...)
 {
     weights.default <- function(object, ...) NULL
     GRID = 31
     w <- eval(w)
-    if (!is.null(w) && length(w) == 1) 
+    if (!is.null(w) && length(w) == 1)
         w <- NULL
     require(mgcv)  || stop("Requires package 'mgcv'")
     X <- scores(x, choices = choices, display = display, ...)
@@ -43,15 +44,15 @@
         mod <- gam(y ~ x1 + x2, family = family, weights = w)
     else if (knots == 1)
         mod <- gam(y ~ poly(x1, 1) + poly(x2, 1),
-                   family = family, weights = w)
+                   family = family, weights = w, method = method)
     else if (knots == 2)
         mod <- gam(y ~ poly(x1, 2) + poly(x2, 2) + poly(x1, 1):poly(x2, 1),
-                   family = family, weights = w)
-    else if (thinplate) 
-        mod <- gam(y ~ s(x1, x2, k = knots), family = family, 
-                   weights = w, select = select)
-    else mod <- gam(y ~ s(x1, k = knots) + s(x2, k = knots), 
-                    family = family, weights = w, select = select)
+                   family = family, weights = w, method = method)
+    else if (thinplate)
+        mod <- gam(y ~ s(x1, x2, k = knots), family = family,
+                   weights = w, select = select, method = method)
+    else mod <- gam(y ~ s(x1, k = knots) + s(x2, k = knots), family = family,
+                    weights = w, select = select, method = method)
     xn1 <- seq(min(x1), max(x1), len=GRID)
     xn2 <- seq(min(x2), max(x2), len=GRID)
     newd <- expand.grid(x1 = xn1, x2 = xn2)
@@ -77,13 +78,13 @@
         plot(X, asp = 1, cex = cex, ...)
     }
     if (!missing(main) || (missing(main) && !add)) {
-        if (missing(main)) 
+        if (missing(main))
             main <- yname
         title(main = main)
     }
-    if (missing(levels)) 
+    if (missing(levels))
         levels <- pretty(range(fit, finite = TRUE), nlevels)
-    
+
     contour(xn1, xn2, matrix(fit, nrow=GRID), col = col, add = TRUE,
             levels = levels, labcex = labcex,
             drawlabels = !is.null(labcex) && labcex > 0)

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-03-12 15:53:39 UTC (rev 1538)
+++ pkg/vegan/inst/ChangeLog	2011-03-12 17:02:58 UTC (rev 1539)
@@ -8,6 +8,9 @@
 	the model. Also now accepts `gam()` argument `select` to add an
 	extra penalty to smooths so they can be penalized to zero (i.e.
 	removed from the model). This is a form of model selection.
+	Estimation of smoothing parameters can now be determined via
+	argument `method`. Both `select` and `method` have been set to
+	defaults that were implied in previous versions of the function.
 
 	* metaMDSrotate: can now rotate > 2-dim solutions so that the
 	first axis is parallel to a given vector and all others are

Modified: pkg/vegan/man/ordisurf.Rd
===================================================================
--- pkg/vegan/man/ordisurf.Rd	2011-03-12 15:53:39 UTC (rev 1538)
+++ pkg/vegan/man/ordisurf.Rd	2011-03-12 17:02:58 UTC (rev 1539)
@@ -13,7 +13,7 @@
 \method{ordisurf}{default}(x, y, choices=c(1, 2), knots=10, family="gaussian", col="red",
      thinplate = TRUE, add = FALSE, display = "sites",
      w = weights(x), main, nlevels = 10, levels, labcex = 0.6,
-     bubble = FALSE, cex = 1, select = FALSE, ...)
+     bubble = FALSE, cex = 1, select = FALSE, method = "GCV.Cp", ...)
 \method{ordisurf}{formula}(formula, data, ...)
 \method{calibrate}{ordisurf}(object, newdata, ...)
 }
@@ -57,6 +57,15 @@
     of fitting can completely remove terms from the model. If the
     corresponding smoothing parameter is estimated as zero then the extra
     penalty has no effect.}
+  \item{method}{character; the smoothing parameter estimation
+    method. Options allowed are: \code{"GCV.Cp"} uses GCV for models with
+    unknown scale parameter and Mallows' Cp/UBRE/AIC for models with
+    known scale; \code{"GACV.Cp"} as for \code{"GCV.Cp"} but uses GACV
+    (Generalised Approximate CV) instead of GCV; \code{"REML"} and
+    \code{"ML"} use restricted maximum likelihood or maximum likelihood
+    estimation for both known and unknown scale; and \code{"P-REML"} and
+    \code{"P-ML"} use REML or ML estimation but use a Pearson estimate
+    of the scale.}
   \item{formula, data}{Alternative definition of the fitted model as
     \code{x ~ y}, or left-hand side is the ordination \code{x} and
     right-hand side the single fitted continuous variable



More information about the Vegan-commits mailing list