vegandevs / vegan

R package for community ecologists: popular ordination methods, ecological null models & diversity analysis
https://vegandevs.github.io/vegan/
GNU General Public License v2.0
453 stars 98 forks source link

permustats for anova.cca #122

Closed eduardszoecs closed 9 years ago

eduardszoecs commented 9 years ago

I just noticed that there is no permustats method for anova.cca.

Shouldn't be hard to implement: Just return F.perm from permutest with the anova.cca-object and write a permustats.anova.cca method.

Why is this? Maybe not the clutter the anova.cca object?

gavinsimpson commented 9 years ago

Will have to think on this some; what should we do with with by = "axis" and by = "margin"? Where we would have multiple rounds of sampling distributions depending on how many axes or variables are under test.

A matrix representation would possibly be suitable, with a column per variable/axis?

jarioksa commented 9 years ago

We even document that permustats is not available for anova.cca results but only for permutest.cca. It is possible to change the functions so that they return permutation results for permustats, but requires quite a lot of work. If I remember correctly, laziness was the reason not changing these functions.

The anova.cca function returns an object of class anova and it is displayed with stats:::print.anova. The output should be compatible with that function and return only a single ANOVA table. The permutation results could be returned as an attribute that is ignored by stats:::print.anova.

Quite a few functions need changing. We have the following call trees for permustats.cca in current vegan:

anova.cca -> permutest.cca
anova.cca -> anova.ccalist -> permutest.cca
anova.cca -> anova.ccabyterm -> anova.ccalist -> permutest.cca
anova.cca -> anova.ccabymargin -> permutest.cca
anova.cca -> anova.ccabyaxis -> permutest.cca

All these cases should be covered. This is possible but requires work. This is not among my top priorities, but pull requests are welcome (after critical review).

eduardszoecs commented 9 years ago

A matrix representation would possibly be suitable, with a column per variable/axis?

@gavinsimpson Jupp, that is what is done e.g. in adonis().

@jarioksa I know that it's documented. I'm just using anova.cca more than permutest and though it would be a nice plus...

All these cases should be covered. This is possible but requires work. This is not among my top priorities, but pull requests are welcome (after critical review).

I'll have a longer train trip this weekend (to SEFS 9) -> I'll try to implement this.

BTW: We will give a short workshop @SEFS ("Data analysis in freshwater ecology using R"), where I will present ordinations using the vegan package. You can find my materials here.

jarioksa commented 9 years ago

@EDiLD Fine!

eduardszoecs commented 9 years ago

I implemented permustats for all anova.cca\* functions. See here for a (moreorless detailed) description, diff and test cases.

Will make a pull request after you took a look over my changes.

jarioksa commented 9 years ago

@EDiLD this looks fine. I pulled your branch and ran some quick tests, and everything seemed to work smoothly, and the results were consistent. This certainly is a useful addition to vegan because many of anova.cca are difficult and tedious to implement manually as permutest.cca cases. Please make a PR so that other developers also can try this and comment on the code.

jarioksa commented 9 years ago

@EDiLD this also needs documentation (man/permustats.Rd).

eduardszoecs commented 9 years ago

Thanks @jarioksa for your feedback. Will document and send a pull request later this day.

eduardszoecs commented 9 years ago

I've checked only with R CMD check (one note about vegan3d). R CMD check --as-cran is currently not working at my end (hangs on checking CRAN feasabilty) - don't know why...

eduardszoecs commented 9 years ago

R CMD check --as-cran with current R-devel on a Linux machine:

_R_CHECK_CRAN_INCOMING_=FALSE ./R-devel.sh CMD check --as-cran vegan_2.4-0.tar.gz

* using log directory ‘vegan.Rcheck’
* using R Under development (unstable) (2015-03-06 r67945)
* using platform: x86_64-unknown-linux-gnu (64-bit)
* using session charset: UTF-8
* using option ‘--as-cran’
* checking for file ‘vegan/DESCRIPTION’ ... OK
* this is package ‘vegan’ version ‘2.4-0’
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘vegan’ can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking ‘build’ directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... NOTE
Found the following assignments to the global environment:
File ‘vegan/R/orditkplot.R’:
  assign(dumpName, xy, envir = .GlobalEnv)
  assign(dumpName, xy, envir = .GlobalEnv)
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd line widths ... OK
* checking Rd cross-references ... NOTE
Package unavailable to check Rd xrefs: ‘vegan3d’
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking contents of ‘data’ directory ... OK
* checking data for non-ASCII characters ... OK
* checking data for ASCII and uncompressed saves ... OK
* checking line endings in C/C++/Fortran sources/headers ... OK
* checking line endings in Makefiles ... OK
* checking for GNU extensions in Makefiles ... OK
* checking compiled code ... OK
* checking sizes of PDF files under ‘inst/doc’ ... OK
* checking installed files from ‘inst/doc’ ... OK
* checking files in ‘vignettes’ ... OK
* checking examples ... OK
Examples with CPU or elapsed time > 5s
                 user system elapsed
ordistep       16.516 11.310  10.922
add1.cca       10.031  8.117   6.091
vegan-package   9.520  6.214   6.687
prc             7.856  5.724   4.956
specaccum       5.378  3.470   3.723
radfit          4.744  3.872   3.308
multipart       4.242  3.444   2.397
ordipointlabel  6.844  0.243   6.749
ordisurf        3.776  3.167   2.188
adipart         3.849  3.061   2.269
tsallis         5.353  0.157   5.299
* checking differences from ‘vegan-Ex.Rout’ to ‘vegan-Ex.Rout.save’ ... OK

647c647
< ... procrustes: rmse 1.094373e-06  max resid 1.88838e-06 
---
> ... procrustes: rmse 1.09439e-06  max resid 1.88838e-06 
1533a1534,1535
> Warning in cmdscale(X, k = k, eig = TRUE, add = add) :
>   only 22 of the first 23 eigenvalues are > 0
2610d2611
< Warning: package 'MASS' was built under R version 3.2.1
3663c3664
< ... procrustes: rmse 4.525312e-06  max resid 1.281822e-05 
---
> ... procrustes: rmse 4.525314e-06  max resid 1.281822e-05 
5484,5490c5485,5490
< > ###   permustats.anova.cca permustats.CCorA permustats.envfit
< > ###   permustats.factorfit permustats.mantel permustats.mrpp permustats.mso
< > ###   permustats.oecosimu permustats.ordiareatest
< > ###   permustats.permutest.betadisper permustats.permutest.cca
< > ###   permustats.protest permustats.vectorfit summary.permustats
< > ###   densityplot.permustats density.permustats qqnorm.permustats
< > ###   qqmath.permustats
---
> > ###   permustats.CCorA permustats.envfit permustats.factorfit
> > ###   permustats.mantel permustats.mrpp permustats.mso permustats.oecosimu
> > ###   permustats.ordiareatest permustats.permutest.betadisper
> > ###   permustats.permutest.cca permustats.protest permustats.vectorfit
> > ###   summary.permustats densityplot.permustats density.permustats
> > ###   qqnorm.permustats qqmath.permustats
6039c6039
< [1,] 5.998486e-18 -1.64959e-17
---
> [1,] 3.038945e-17 1.218602e-17
7167c7167
< Chenalbu 0.6033850 5.329071e-15
---
> Chenalbu 0.6033850 6.883383e-15
8399c8399
< -1.110223e-16 -6.661338e-16 -7.216450e-16  1.665335e-16  2.498002e-16 
---
>  2.220446e-16 -1.276756e-15 -1.054712e-15  1.942890e-16  1.387779e-16 
8401c8401
<  1.110223e-16 -1.526557e-16 -8.326673e-17  2.775558e-17  2.081668e-17 
---
>  1.387779e-16 -1.387779e-17 -1.387779e-16  2.359224e-16  2.775558e-17 
8403c8403
<  1.179612e-16  5.551115e-17  6.245005e-17  4.510281e-17  8.673617e-18 
---
>  1.387779e-16  0.000000e+00  3.469447e-17  2.775558e-17  1.561251e-17 
8405c8405
< -3.469447e-18 -1.561251e-17  5.204170e-18  3.035766e-17 
---
>  0.000000e+00  1.734723e-18  1.127570e-17  1.196959e-16 
8414c8414
< -7.105e-14 
---
> -4.263e-14 
** found \donttest examples: check also with --run-donttest
* checking for unstated dependencies in ‘tests’ ... OK
* checking tests ...
  Running ‘oecosimu-tests.R’
  Comparing ‘oecosimu-tests.Rout’ to ‘oecosimu-tests.Rout.save’ ... OK
  Running ‘vegan-tests.R’ [100s/42s]
  Comparing ‘vegan-tests.Rout’ to ‘vegan-tests.Rout.save’ ... OK
 OK
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in ‘inst/doc’ ... OK
* checking running R code from vignettes ...
   ‘decision-vegan.Rnw’ ... OK
   ‘diversity-vegan.Rnw’ ... OK
   ‘intro-vegan.Rnw’ ... OK
 OK
* checking re-building of vignette outputs ... OK
* checking PDF version of manual ... OK
* DONE

Status: 2 NOTEs
See
  ‘/home/edisz/Documents/R-Stuff/Code/own/devel/vegan.Rcheck/00check.log’
for details.
jarioksa commented 9 years ago

closed with PR #123