[Vegan-commits] r809 - in pkg/vegan: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Apr 21 11:54:57 CEST 2009
Author: jarioksa
Date: 2009-04-21 11:54:57 +0200 (Tue, 21 Apr 2009)
New Revision: 809
Modified:
pkg/vegan/DESCRIPTION
pkg/vegan/R/RsquareAdj.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/varpart.Rd
Log:
Made RsquareAdj generic, with methods for 'rda', 'cca' (NA), 'lm' and 'glm' objects (on P Legendre's request)
Modified: pkg/vegan/DESCRIPTION
===================================================================
--- pkg/vegan/DESCRIPTION 2009-04-15 12:36:02 UTC (rev 808)
+++ pkg/vegan/DESCRIPTION 2009-04-21 09:54:57 UTC (rev 809)
@@ -1,7 +1,7 @@
Package: vegan
Title: Community Ecology Package
Version: 1.16-18
-Date: April 15, 2009
+Date: April 21, 2009
Author: Jari Oksanen, Roeland Kindt, Pierre Legendre, Bob O'Hara, Gavin L. Simpson,
Peter Solymos, M. Henry H. Stevens, Helene Wagner
Maintainer: Jari Oksanen <jari.oksanen at oulu.fi>
Modified: pkg/vegan/R/RsquareAdj.R
===================================================================
--- pkg/vegan/R/RsquareAdj.R 2009-04-15 12:36:02 UTC (rev 808)
+++ pkg/vegan/R/RsquareAdj.R 2009-04-21 09:54:57 UTC (rev 809)
@@ -1,9 +1,51 @@
-"RsquareAdj" <-
-function(x, n, m, ...)
+`RsquareAdj` <-
+ function(x, ...)
{
+ UseMethod("RsquareAdj")
+}
+
+
+`RsquareAdj.default` <-
+ function(x, n, m, ...)
+{
if (m >= (n-1))
NA
else
1 - (1-x)*(n-1)/(n-m-1)
}
+## Use this with rda() results
+`RsquareAdj.rda` <-
+ function(x, ...)
+{
+ R2 <- x$CCA$tot.chi/x$tot.chi
+ m <- x$CCA$rank
+ n <- 1 + m + x$CA$rank + ifelse(is.null(x$pCCA), 0, x$pCCA$rank)
+ radj <- RsquareAdj(R2, n, m)
+ list(r.squared = R2, adj.r.squared = radj)
+}
+
+## cca result: no RsquareAdj
+RsquareAdj.cca <-
+ function(x, ...)
+{
+ NA
+}
+
+## Linear model: take the result from the summary
+RsquareAdj.lm <-
+ function(x, ...)
+{
+ summary(x)[c("r.squared", "adj.r.squared")]
+}
+
+## Generalized linear model: R2-adj only with Gaussian model
+RsquareAdj.glm <-
+ function(x, ...)
+{
+ if (family(x)$family == "gaussian")
+ summary.lm(x)[c("r.squared", "adj.r.squared")]
+ else
+ NA
+}
+
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2009-04-15 12:36:02 UTC (rev 808)
+++ pkg/vegan/inst/ChangeLog 2009-04-21 09:54:57 UTC (rev 809)
@@ -2,7 +2,13 @@
VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
-Version 1.16-18
+Version 1.16-18 (opened April 21, 2009)
+
+ * RsquareAdj: defined as generic function. The old RsquareAdj is
+ now the "default" method, and there are specific methods for
+ "rda", "cca" (= NA), "lm" and "glm" objects. Not yet documented,
+ but functions are listed as aliases in varpart.Rd. On Pierre
+ Legendre's request.
Version 1.16-17 (closed April 15, 2009)
Modified: pkg/vegan/man/varpart.Rd
===================================================================
--- pkg/vegan/man/varpart.Rd 2009-04-15 12:36:02 UTC (rev 808)
+++ pkg/vegan/man/varpart.Rd 2009-04-21 09:54:57 UTC (rev 809)
@@ -9,7 +9,14 @@
\alias{plot.varpart234}
\alias{plot.varpart}
\alias{plot.varpart234}
+% The RsquareAdj's should probably be documented in another file
\alias{RsquareAdj}
+\alias{RsquareAdj.default}
+\alias{RsquareAdj.rda}
+\alias{RsquareAdj.cca}
+\alias{RsquareAdj.lm}
+\alias{RsquareAdj.glm}
+% End RsquareAdj's (to be moved away from here)
\alias{simpleRDA2}
\title{Partition the Variation of Community Matrix by 2, 3, or 4 Explanatory Matrices }
More information about the Vegan-commits
mailing list