[Vegan-commits] r952 - in branches/1.15: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Aug 26 16:49:56 CEST 2009
Author: jarioksa
Date: 2009-08-26 16:49:56 +0200 (Wed, 26 Aug 2009)
New Revision: 952
Added:
branches/1.15/man/RsquareAdj.Rd
Modified:
branches/1.15/R/RsquareAdj.R
branches/1.15/inst/ChangeLog
branches/1.15/man/varpart.Rd
Log:
merged RsquareAdj methods to branches/1.15
Modified: branches/1.15/R/RsquareAdj.R
===================================================================
--- branches/1.15/R/RsquareAdj.R 2009-08-25 19:18:03 UTC (rev 951)
+++ branches/1.15/R/RsquareAdj.R 2009-08-26 14:49:56 UTC (rev 952)
@@ -1,9 +1,57 @@
-"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 <- nrow(x$CCA$u)
+ if (is.null(x$pCCA))
+ radj <- RsquareAdj(R2, n, m)
+ else
+ radj <- NA
+ list(r.squared = R2, adj.r.squared = radj)
+}
+
+## cca result: no RsquareAdj
+RsquareAdj.cca <-
+ function(x, ...)
+{
+ R2 <- x$CCA$tot.chi/x$tot.chi
+ m <- x$CCA$rank
+ n <- nrow(x$CCA$u)
+ radj <- NA
+ list(r.squared = R2, adj.r.squared = radj)
+}
+
+## 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: branches/1.15/inst/ChangeLog
===================================================================
--- branches/1.15/inst/ChangeLog 2009-08-25 19:18:03 UTC (rev 951)
+++ branches/1.15/inst/ChangeLog 2009-08-26 14:49:56 UTC (rev 952)
@@ -45,6 +45,8 @@
* copied mantel.correlog.
+ * merged RsquareAdj (rev809, 945, 946).
+
Version 1.15-3 (released June 17, 2009)
* merged revs 866 to 868: changed the way capscale displays
Copied: branches/1.15/man/RsquareAdj.Rd (from rev 945, pkg/vegan/man/RsquareAdj.Rd)
===================================================================
--- branches/1.15/man/RsquareAdj.Rd (rev 0)
+++ branches/1.15/man/RsquareAdj.Rd 2009-08-26 14:49:56 UTC (rev 952)
@@ -0,0 +1,69 @@
+\name{RsquareAdj}
+\alias{RsquareAdj}
+\alias{RsquareAdj.default}
+\alias{RsquareAdj.rda}
+\alias{RsquareAdj.cca}
+\alias{RsquareAdj.lm}
+\alias{RsquareAdj.glm}
+
+\Rdversion{1.1}
+\alias{RsquareAdj}
+
+\title{
+Adjusted R-square
+}
+\description{
+ The functions finds the adjusted R-square.
+}
+\usage{
+\method{RsquareAdj}{default}(x, n, m, ...)
+\method{RsquareAdj}{rda}(x, ...)
+}
+
+\arguments{
+
+ \item{x}{ Unadjusted R-squared or an object from which the terms for
+ evaluation or adjusted R-squared can be found.}
+
+ \item{n, m}{Number of observations and number of degrees of freedom
+ in the fitted model.}
+
+ \item{\dots}{ Other arguments (ignored).}
+}
+
+\details{ The default method finds the adjusted
+ R-squared from the unadjusted R-squared, number of observations, and
+ number of degrees of freedom in the fitted model. The specific
+ methods find this information from the fitted result
+ object. There are specific methods for \code{\link{rda}},
+ \code{\link{cca}}, \code{\link{lm}} and \code{\link{glm}}. Adjusted,
+ or even unandjusted, R-squared may not be available in some cases,
+ and then the functions will return \code{NA}. There is no adjusted
+ R-squared in \code{\link{cca}}, in partial \code{\link{rda}}, and
+ R-squared values are available only for \code{\link{gaussian}}
+ models in \code{\link{glm}}.
+}
+
+\value{ The functions return a list of items \code{r.squared} and
+\code{adj.r.squared}.
+}
+
+\references{
+ Peres-Neto, P., P. Legendre, S. Dray and D. Borcard. 2006. Variation
+ partioning of species data matrices: estimation and comparison of
+ fractions. \emph{Ecology} 87: 2614-2625. }
+
+\seealso{
+ \code{\link{varpart}} uses \code{RsquareAdj}.
+}
+\examples{
+data(mite)
+data(mite.env)
+## rda
+m <- rda(decostand(mite, "hell") ~ ., mite.env)
+RsquareAdj(m)
+## default method
+RsquareAdj(0.8, 20, 5)
+}
+\keyword{ univar }
+\keyword{ multivariate }
Modified: branches/1.15/man/varpart.Rd
===================================================================
--- branches/1.15/man/varpart.Rd 2009-08-25 19:18:03 UTC (rev 951)
+++ branches/1.15/man/varpart.Rd 2009-08-26 14:49:56 UTC (rev 952)
@@ -9,7 +9,6 @@
\alias{plot.varpart234}
\alias{plot.varpart}
\alias{plot.varpart234}
-\alias{RsquareAdj}
\alias{simpleRDA2}
\title{Partition the Variation of Community Matrix by 2, 3, or 4 Explanatory Matrices }
More information about the Vegan-commits
mailing list