Skip to content

Vegan: Anova.CCA accessing original data using option by="margin"

5 messages · Steve Pawson, Gavin Simpson, Jari Oksanen

#
Hello,

I am attempting to use the ANOVA.CCA function with the by="margin" option.
The process works fine using the by="terms" option and I note in the Vegan
manual that Jari suggests that an error may occur if the anova does not have
access to the data on the original constraints.

This is the error that I get:

Error in dimnames(x) <- dn : 
  length of 'dimnames' [2] not equal to array extent

My question is, does anyone know if this error relates to what Jari is
referring to (or is it a different problem), and if it is, how do I link the
anova to the original constraints?

Many thanks for any help provided.

Regards

Steve

--
View this message in context: http://r.789695.n4.nabble.com/Vegan-Anova-CCA-accessing-original-data-using-option-by-margin-tp3893005p3893005.html
Sent from the R help mailing list archive at Nabble.com.
#
On Mon, 2011-10-10 at 23:51 -0700, Steve Pawson wrote:
It is almost impossible to answer that without a lot more information.
For starters, what does traceback() say when run immediately *after* you
get the error?

G

  
    
7 days later
#
Dear Gavin,

My apologies for the delay in responding to your request for further information I have been travelling for work since you replied and have only just returned to email contact.

The output from the traceback is as follows
# This is the capscale model that I called
This is the ANOVA by margin option with the error
Error in dimnames(x) <- dn :
  length of 'dimnames' [2] not equal to array extent

Corresponding traceback
9: `colnames<-`(`*tmp*`, value = c("CAP1", "CAP0"))
8: capscale(formula = log(beetles + 1) ~ size + Clearfell + Absolute.Distance +
       Distance_from_edge + clearfell.harvest_area + Canopy.Cover +
       X500mnative + Litter3 + X500mexotic + X5000exotic + Condition(AdjLong +
       AdjLat + AdjLat.2 + AdjLat.2.long + AdjLong.3) + Condition(size +
       Clearfell + Absolute.Distance + Distance_from_edge + clearfell.harvest_area +
       Canopy.Cover + Litter3 + X500mexotic + X5000exotic + AdjLong +
       AdjLat + AdjLat.2 + AdjLat.2.long + AdjLong.3), data = environ,
       distance = "bray")
7: eval(expr, envir, enclos)
6: eval(call, parent.frame())
5: update.default(object, fla)
4: update(object, fla)
3: anova.ccabymargin(object, alpha = alpha, beta = beta, step = step,
       perm.max = perm.max, by = NULL, ...)
2: anova.cca(beetlecap, by = "margin")
1: anova(beetlecap, by = "margin")

I note that in the traceback point 8 it appears that my original model statement has been modified to include all my environmental predictors as conditions as well as all the original conditional variables that I wished to partial out.

Any help on finding the cause of this error greatly appreciated, if it helps I can provide you with data files in a personal email.

Kind regards


Steve Pawson




-----Original Message-----
From: Gavin Simpson [mailto:gavin.simpson at ucl.ac.uk]
Sent: Wednesday, 12 October 2011 1:31 a.m.
To: Steve Pawson
Cc: r-help at r-project.org
Subject: Re: [R] Vegan: Anova.CCA accessing original data using option by="margin"
On Mon, 2011-10-10 at 23:51 -0700, Steve Pawson wrote:
It is almost impossible to answer that without a lot more information.
For starters, what does traceback() say when run immediately *after* you
get the error?

G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




This e-mail and any attachments may contain information which is confidential or subject to copyright. If you receive this e-mail in error, please delete it.
Scion does not accept responsibility for anything in this e-mail which is not provided in the  course of Scion?s usual business or for any computer virus, data corruption, interference or delay arising from this e-mail.
1 day later
#
Steve Pawson <Steve.Pawson <at> scionresearch.com> writes:
information I have been travelling for
Distance_from_edge+
X5000exotic +
distance = "bray")
clearfell.harvest_area +
[...clip...]

Dear Steve Pawson,

With the help of this message I was able to construct an example that gives 
the same error message -- this does not prove that the cause of the problem
is the same, but it is possible.

It may be that your *huge* model has redundant variables that cannot be
analysed in marginal test: the other variables explain all, and the marginal
effect of some variables is zero. With that a high number of variables as you
have, this is very likely. It seems that capscale() cannot cope with this case.

I fixed capscale in http://vegan.r-forge.r-project.org and now it handles
smoothly these redundant variables (skips them in permutation test, and
reports df=0). From your point of view it may be unfortunate that I released
a new version of vegan a couple of hours before checking R-News mail, and
therefore this fix is not yet in the next release, and as we just had a release
we probably (hopefully) will not have a new revision very soon. So your
choices are either to use the vegan version in R-Forge (which must be at 
least r1958) or simplify your model so that you don't have redundant variables.
One way of achieving this is to use command

alias(beetlecap, names = TRUE)

which will list the names of the variables that cannot be analysed. You
can remove these variables without influencing your fitted model, because
they really are redundant variables.

Cheers, Jari Oksanen