[Vegan-commits] r499 - in pkg: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Sep 15 17:28:39 CEST 2008
Author: jarioksa
Date: 2008-09-15 17:28:39 +0200 (Mon, 15 Sep 2008)
New Revision: 499
Modified:
pkg/R/add1.cca.R
pkg/R/anova.ccabymargin.R
pkg/R/drop1.cca.R
pkg/inst/ChangeLog
pkg/man/anova.cca.Rd
Log:
fixes to remaining issues of add1/drop1 and 'scope' to anova.ccabyterm
Modified: pkg/R/add1.cca.R
===================================================================
--- pkg/R/add1.cca.R 2008-09-15 12:37:26 UTC (rev 498)
+++ pkg/R/add1.cca.R 2008-09-15 15:28:39 UTC (rev 499)
@@ -25,11 +25,7 @@
else
nfit <- update(object,
as.formula(paste(". ~ . +", tt)))
- ## Handle completely aliased terms
- if (is.null(nfit$CCA))
- tmp <- matrix(NA, 1, 5)
- else
- tmp <- anova(nfit, perm.max = perm.max, ...)
+ tmp <- anova(nfit, perm.max = perm.max, ...)
adds[i+1,] <- unlist(tmp[1,3:5])
}
colnames(adds) <- colnames(tmp)[3:5]
Modified: pkg/R/anova.ccabymargin.R
===================================================================
--- pkg/R/anova.ccabymargin.R 2008-09-15 12:37:26 UTC (rev 498)
+++ pkg/R/anova.ccabymargin.R 2008-09-15 15:28:39 UTC (rev 499)
@@ -1,7 +1,10 @@
`anova.ccabymargin` <-
- function(object, step=100,...)
-{
- trms <- drop.scope(object)
+ function(object, step=100, scope, ...)
+{
+ if (!missing(scope) && is.character(scope))
+ trms <- scope
+ else
+ trms <- drop.scope(object, scope)
alltrms <- labels(terms(object$terminfo))
keep <- trms %in% alltrms
trms <- trms[keep]
@@ -11,8 +14,9 @@
fla <- formula(object)
## Put all trms except current into Condition() and update
## formula
- if (ntrms > 1) {
- updfla <- paste("Condition(",paste(trms[-i], collapse="+"), ")")
+ if (length(alltrms) > 1) {
+ keeptrms <- alltrms[!(alltrms==trms[i])]
+ updfla <- paste("Condition(",paste(keeptrms, collapse="+"), ")")
fla <- update(fla, paste(". ~ . + ", updfla))
}
tmp <- update(object, fla)
Modified: pkg/R/drop1.cca.R
===================================================================
--- pkg/R/drop1.cca.R 2008-09-15 12:37:26 UTC (rev 498)
+++ pkg/R/drop1.cca.R 2008-09-15 15:28:39 UTC (rev 499)
@@ -6,9 +6,13 @@
out <- NextMethod("drop1", object, test="none", ...)
cl <- class(out)
if (test == "permutation") {
- adds <- anova(object, by = "margin", perm.max = perm.max, ...)
+ rn <- rownames(out)[-1]
+ if (missing(scope))
+ scope <- rn
+ adds <- anova(object, by = "margin", perm.max = perm.max,
+ scope = scope, ...)
nr <- nrow(adds)
- out <- cbind(out, rbind(NA, adds[-nr,3:5]))
+ out <- cbind(out, rbind(NA, adds[rn,3:5]))
class(out) <- cl
}
out
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2008-09-15 12:37:26 UTC (rev 498)
+++ pkg/inst/ChangeLog 2008-09-15 15:28:39 UTC (rev 499)
@@ -19,6 +19,13 @@
impossible. These used to stop with error, but now they return a
zeroed result so that things like anova(..., by = "term") and
drop1() work. Added function anova.ccanull to handle these cases.
+
+ * anova.cca(..., by = "margin") was handling wrongly 'x' in ~
+ Condition(x) + x + z, or model formulae where same variables were
+ used both as Conditions and (aliased) constraints.
+
+ * anova.cca(..., by = "margin") or function anova.ccabymargin
+ gained a 'scope' argument which is used in drop.scope().
Version 1.14-11 (closed September 10, 2008)
Modified: pkg/man/anova.cca.Rd
===================================================================
--- pkg/man/anova.cca.Rd 2008-09-15 12:37:26 UTC (rev 498)
+++ pkg/man/anova.cca.Rd 2008-09-15 15:28:39 UTC (rev 499)
@@ -109,7 +109,11 @@
variable). The terms are assessed sequentially from first to last, and
the order of the terms will influence their significances. Setting
\code{by = "margin"} will perform separate significance test for each
- marginal term in a model with all other terms. These are similar to
+ marginal term in a model with all other terms. The marginal test
+ also accepts a \code{scope} argument for the
+ \code{\link{drop.scope}} which can be a character vector
+ of term labels that are analysed, or a fitted model of lower scope.
+ The marginal effects are also known as
\dQuote{Type III} effects, but the current function only evaluates
marginal terms. It will, for instance, ignore main effects that are
included in interaction terms. In calculating pseudo-\eqn{F}, all
@@ -146,10 +150,16 @@
data(varespec)
data(varechem)
vare.cca <- cca(varespec ~ Al + P + K, varechem)
+## overall test
anova(vare.cca)
+## Test for axes
anova(vare.cca, by="axis", perm.max=500)
+## Sequential test for terms
anova(vare.cca, by="terms", permu=200)
+## Marginal or Type III effects
anova(vare.cca, by="margin")
+## Marginal test knows 'scope'
+anova(vare.cca, by = "m", scope="P")
}
\keyword{ multivariate }
\keyword{ htest }
More information about the Vegan-commits
mailing list