{"action":"created","issue":{"url":"https://api.github.com/repos/vegandevs/vegan/issues/126","labels_url":"https://api.github.com/repos/vegandevs/vegan/issues/126/labels{/name}","comments_url":"https://api.github.com/repos/vegandevs/vegan/issues/126/comments","events_url":"https://api.github.com/repos/vegandevs/vegan/issues/126/events","html_url":"https://github.com/vegandevs/vegan/pull/126","id":95990715,"number":126,"title":"Handle imaginary axes in capscale","user":{"login":"jarioksa","id":1432933,"avatar_url":"https://avatars.githubusercontent.com/u/1432933?v=3","gravatar_id":"","url":"https://api.github.com/users/jarioksa","html_url":"https://github.com/jarioksa","followers_url":"https://api.github.com/users/jarioksa/followers","following_url":"https://api.github.com/users/jarioksa/following{/other_user}","gists_url":"https://api.github.com/users/jarioksa/gists{/gist_id}","starred_url":"https://api.github.com/users/jarioksa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarioksa/subscriptions","organizations_url":"https://api.github.com/users/jarioksa/orgs","repos_url":"https://api.github.com/users/jarioksa/repos","events_url":"https://api.github.com/users/jarioksa/events{/privacy}","received_events_url":"https://api.github.com/users/jarioksa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2015-07-20T05:31:28Z","updated_at":"2015-08-01T15:36:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/vegandevs/vegan/pulls/126","html_url":"https://github.com/vegandevs/vegan/pull/126","diff_url":"https://github.com/vegandevs/vegan/pull/126.diff","patch_url":"https://github.com/vegandevs/vegan/pull/126.patch"},"body":"This PR was triggered by @legendre who wrote dbRDA to handle negative eigenvalues. Instead of nw quick functions, this PR changes `capscale` so that imaginary components (negative eigenvalues) are taken into account in total inertia in partial, constrained and residual components. Earlier we only gave real part of these components and the negative components were only given for the overall model. The PR follows \r\n\r\nMcArdle, B.H. & Anderson, M.J. (2001). Fitting multivariate models\r\n     to community data: a comment on distance-based redundancy\r\n     analysis. *Ecology* **82,** 290-297.\r\n\r\nNew `print`ed output will give the components and their proportions and add a new column of sum of eigenvalues for partitions and the sum of negative eigenvalues when needed:\r\n```\r\n              Inertia Proportion Eigenvals Rank\r\nTotal          4.2990     1.0000    4.5940     \r\nConstrained    1.4690     0.3416    1.5000    3\r\nUnconstrained  2.8300     0.6584    3.0940   14\r\nImaginary                          -0.2950    5\r\nInertia is squared Bray distance \r\n```\r\n\r\nThe permutation tests in `permutest.cca` also change: in `capscale` they will now permute Gower transformed dissimilarity matrix instead of raw data. The results will now be identical to `adonis` when the same permutation matrix is used. When Euclidean distances are used, `capscale`, `rda` and `adonis` will give identical results -- although internal implementations are very different. BTW, I think `adonis` could be much simplified using the same pattern as `capscale`.\r\n\r\nNow `RsquareAdj.rda` works for `capscale` and separete `RsquareAdj.capscale` function was removed (that function refused to give *R*^2 when there were negative eigenvalues)."},"comment":{"url":"https://api.github.com/repos/vegandevs/vegan/issues/comments/126928621","html_url":"https://github.com/vegandevs/vegan/pull/126#issuecomment-126928621","issue_url":"https://api.github.com/repos/vegandevs/vegan/issues/126","id":126928621,"user":{"login":"legendre","id":1571740,"avatar_url":"https://avatars.githubusercontent.com/u/1571740?v=3","gravatar_id":"","url":"https://api.github.com/users/legendre","html_url":"https://github.com/legendre","followers_url":"https://api.github.com/users/legendre/followers","following_url":"https://api.github.com/users/legendre/following{/other_user}","gists_url":"https://api.github.com/users/legendre/gists{/gist_id}","starred_url":"https://api.github.com/users/legendre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/legendre/subscriptions","organizations_url":"https://api.github.com/users/legendre/orgs","repos_url":"https://api.github.com/users/legendre/repos","events_url":"https://api.github.com/users/legendre/events{/privacy}","received_events_url":"https://api.github.com/users/legendre/received_events","type":"User","site_admin":false},"created_at":"2015-08-01T15:36:42Z","updated_at":"2015-08-01T15:36:42Z","body":"Hi Jari.\n\nThat's very good news: all variance decomposition statistics of our functions agree! The R-square, adjusted R-square and F statistics all identical to those of dbRDA.D.\n\nI note that the capscale \"Eigenvalues for constrained axes\" are all a bit larger than my RDA eigenvalues. Is that something that you can fix \n\nFor the RDA ordination scores, they were easy to obtain in my function, where they are the eigenvectors of matrix H%*%G%*%H, rescaled by the square root of the eigenvalues. But I understand the role of \"history\" in programming, and the capscale code has a different history, which may make it more difficult to compute these ordination axes.\n\nI have to go to a family gathering now. Later today, I will try again to pull the code from the imaginary-capscale branch of your personal depository.\n\nPierre\n\n========\n\nLe 2015-08-01 à 02:03, Jari Oksanen <notifications@github.com> a écrit :\n\n> Pierre @legendre: it seems you are using a wrong branch: the new capscale code is in branch imaginary-capscale of my personal repository that makes this pull request. See my previous message on pulling that specific branch. With that branch and with this current PR, your example will give:\n> \n> Call: capscale(formula = d ~ SubsDens + WatrCont + Substrate + Shrub +\n> Topo, data = x)\n> \n>               Inertia Proportion Eigenvals Rank\n> Total          1.1247     1.0000    1.1365     \n> Constrained    0.7640     0.6793    0.7712    6\n> Unconstrained  0.3607     0.3207    0.3653    4\n> Imaginary                          -0.0118    1\n> Inertia is squared Bray distance \n> \n> Eigenvalues for constrained axes:\n>    CAP1    CAP2    CAP3    CAP4    CAP5    CAP6 \n> 0.26140 0.20928 0.15725 0.08198 0.04349 0.01777 \n> \n> Eigenvalues for unconstrained axes:\n>    MDS1    MDS2    MDS3    MDS4 \n> 0.14801 0.12889 0.05817 0.03024 \n> This agrees with your dbRDA.D for the constrained component. Please note also the new formatting (some of the last zeros will be a result of unlucky rounding followed by padding with zeros in R, and I'll fix that in a separate commit). The ANOVA statistics are equal as well:\n> \n> Permutation test for capscale under reduced model\n> Permutation: free\n> Number of permutations: 999\n> \n> Model: capscale(formula = d ~ SubsDens + WatrCont + Substrate + Shrub + Topo, data = x)\n>          Df Variance     F Pr(>F)\n> Model     6  0.76401 1.412  0.125\n> Residual  4  0.36072  \n> R-squares agree as well:\n> \n> > RsquareAdj(m0)\n> $r.squared\n> [1] 0.6792855\n> \n> $adj.r.squared\n> [1] 0.1982138\n> The ordination scores still disagree, because capscale only ordinates the real components and ignores the imaginary part. I haven't figured out yet how to do this without large redesign of capscale, but I'll inspect the issue.\n> \n> —\n> Reply to this email directly or view it on GitHub.\n> \n\n---\nPierre Legendre ------------------- Courriel: Pierre.Legendre@UMontreal.CA\nDépartement de sciences biologiques,\nUniversité de Montréal,\nC.P. 6128, succ. Centre-ville,                        Tel.: (514) 343-7591\nMontréal, Québec H3C 3J7, Canada                      Fax : (514) 343-2293\n                  http://www.numericalecology.com/\n** Nouveaux livres --\n** Borcard, Gillet & Legendre 2011: Numerical ecology with R (Springer).\n** Legendre & Legendre 2012: Numerical ecology, 3rd English ed (Elsevier).\n** Borcard, Gillet & Legendre 2014: Numerical ecology with R, Chinese ed.\n\n"}}