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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Apr 20 23:28:48 CEST 2013


Author: gsimpson
Date: 2013-04-20 23:28:47 +0200 (Sat, 20 Apr 2013)
New Revision: 2492

Modified:
   pkg/vegan/R/ordisurf.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/ordisurf.Rd
Log:
adds fx argument to fit fixed degree freedom regression splines

Modified: pkg/vegan/R/ordisurf.R
===================================================================
--- pkg/vegan/R/ordisurf.R	2013-04-20 21:00:11 UTC (rev 2491)
+++ pkg/vegan/R/ordisurf.R	2013-04-20 21:28:47 UTC (rev 2492)
@@ -18,11 +18,10 @@
 `ordisurf.default` <-
     function (x, y, choices = c(1, 2), knots = 10, family = "gaussian",
               col = "red", isotropic = TRUE, thinplate = TRUE, bs = "tp",
-              add = FALSE, display = "sites",
-              w = weights(x), main, nlevels = 10, levels,
-              npoints = 31, labcex = 0.6,
-              bubble = FALSE, cex = 1, select = TRUE,
-              method = "REML", gamma = 1, plot = TRUE, ...)
+              fx = FALSE, add = FALSE, display = "sites", w = weights(x),
+              main, nlevels = 10, levels, npoints = 31, labcex = 0.6,
+              bubble = FALSE, cex = 1, select = TRUE, method = "REML",
+              gamma = 1, plot = TRUE, ...)
 {
     weights.default <- function(object, ...) NULL
     if(!missing(thinplate)) {
@@ -49,9 +48,14 @@
     x2 <- X[, 2]
     ## handle knots - allow vector of length up to two
     if (length(knots) > 2L)
-        warning("Number of knots supplied exceeds '2'. Only using the first two.")
+        warning("Length of 'knots' supplied exceeds '2'. Using the first two.")
     ## expand knots robustly, no matter what length supplied
     knots <- rep(knots, length.out = 2)
+    ## handle fx - allow vector of length up to two
+    if (length(fx) > 2L)
+        warning("Length of 'fx' supplied exceeds '2'. Using the first two.")
+    ## expand fx robustly, no matter what length supplied
+    fx <- rep(fx, length.out = 2)
     ## handle the bs - we only allow some of the possible options
     if (length(bs) > 2L)
         warning("Number of basis types supplied exceeds '2'. Only using the first two.")
@@ -75,18 +79,22 @@
         f <- formula(y ~ poly(x1, 2) + poly(x2, 2) + poly(x1, 1):poly(x2, 1))
     } else if (isotropic) {
         f <- formula(paste0("y ~ s(x1, x2, k = ", knots[1],
-                            ", bs = \"", bs[1], "\")"))
+                            ", bs = \"", bs[1], "\", fx = ", fx[1],")"))
     } else {
         if (any(bs %in% c("ad"))) {
             ## only "ad" for now, but "fs" should also not be allowed
             f <- formula(paste0("y ~ s(x1, k = ", knots[1],
-                                ", bs = \"", bs[1], "\") + s(x2, k = ",
-                                knots[2], ", bs = \"", bs[1], "\")"))
+                                ", bs = \"", bs[1],
+                                "\", fx = ", fx[1], ") + s(x2, k = ",
+                                knots[2], ", bs = \"", bs[2],
+                                "\", fx = ", fx[2], ")"))
         } else {
             f <- formula(paste0("y ~ te(x1, x2, k = c(",
                                 paste0(knots, collapse = ", "),
                                 "), bs = c(",
                                 paste0("\"", bs, "\"", collapse = ", "),
+                                "), fx = c(",
+                                paste0(fx, collapse = ", "),
                                 "))"))
         }
     }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2013-04-20 21:00:11 UTC (rev 2491)
+++ pkg/vegan/inst/ChangeLog	2013-04-20 21:28:47 UTC (rev 2492)
@@ -21,6 +21,11 @@
 	per ordination dimension considered. This is only of use with
 	anisotropic surfaces with `isotropic = FALSE`.
 
+	 - New argument `fx`; indicates whether the smoothers are fixed
+	degrees of freedom regression splines (`fx = FALSE`) or a
+	penalised regression spline (`fx = TRUE`). Can be a vector of
+	length 2 for anisotropic surfaces (`isotropic = FALSE`).
+
 	 - The number of locations in each ordination dimension at which the
 	fitted surface is evaluated can now be specified via new argument
 	`npoints`.

Modified: pkg/vegan/man/ordisurf.Rd
===================================================================
--- pkg/vegan/man/ordisurf.Rd	2013-04-20 21:00:11 UTC (rev 2491)
+++ pkg/vegan/man/ordisurf.Rd	2013-04-20 21:28:47 UTC (rev 2492)
@@ -13,10 +13,11 @@
 \usage{
 \method{ordisurf}{default}(x, y, choices = c(1, 2), knots = 10,
          family = "gaussian", col = "red", isotropic = TRUE,
-         thinplate = TRUE, bs = "tp", add = FALSE, display = "sites",
-         w = weights(x), main, nlevels = 10, levels, npoints = 31,
-         labcex = 0.6, bubble = FALSE, cex = 1, select = TRUE,
-         method = "REML", gamma = 1, plot = TRUE, ...)
+         thinplate = TRUE, bs = "tp", fx = FALSE, add = FALSE,
+         display = "sites", w = weights(x), main, nlevels = 10,
+         levels, npoints = 31, labcex = 0.6, bubble = FALSE,
+         cex = 1, select = TRUE, method = "REML", gamma = 1,
+         plot = TRUE, ...)
 
 \method{ordisurf}{formula}(formula, data, ...)
 
@@ -54,6 +55,10 @@
       "cr", "cs", "ds", "ps", "ad")}. See
     \code{\link[mgcv]{smooth.terms}} for an over view of what these
     refer to. The default is to use thin plate splines \code{"tp"}.}
+  \item{fx}{indicates whether the smoothers are fixed degree of freedom
+    regression splines (\code{fx = FALSE}) or penalised regression
+    splines (\code{fx = TRUE}). Can be a vector of length 2 for
+    anisotropic surfaces (\code{isotropic = FALSE}).}
   \item{add}{Add contours to an existing diagram or draw a new plot.}
   \item{display}{Type of scores known by \code{\link{scores}}: typically
     "sites" for ordinary site scores or "lc" for linear combination scores.}



More information about the Vegan-commits mailing list