From the code, a correction is made if some eigenvalues are negative
even if correction="none":
lambda = (lambda - min(lambda))/(tr(Delta) - (n - 1)*min(lambda))
lambda: vector of eigenvalues
Delta: the centered distance matrix
The help page refers to eq. 9.27 in Legendre & Legendre (1998). I'll
have a look it later and clarify the help page if needed.
Best,
Emmanuel
Le 25/10/2018 à 04:07, David Bapst a écrit :
Emmanuel, I'm familiar with the two typical corrections. I'm just
curious why or what `pcoa` is reporting as ` "Rel_corr_eig"` when no
correction is defined by the user.
-Dave
On Tue, Oct 23, 2018 at 10:26 PM Emmanuel Paradis
<emmanuel.para...@ird.fr <mailto:emmanuel.para...@ird.fr>> wrote:
Hi David,
Have you tried one of the two possible corrections?
R> res <- pcoa(dmat)
R> res.lingoes <- pcoa(dmat, correction = "lingoes")
R> res.lingoes$note
[1] "Lingoes correction applied to negative eigenvalues: D' =
-0.5*D^2 -
0.310850908498892 , except diagonal elements"
The matrix $values of the output is different and contains the
corrected
eigenvalues in the second analysis:
R> names(res$values)
[1] "Eigenvalues" "Relative_eig" "Rel_corr_eig" "Broken_stick"
[5] "Cum_corr_eig" "Cumul_br_stick"
R> names(res.lingoes$values)
[1] "Eigenvalues" "Corr_eig" "Rel_corr_eig" "Broken_stick"
[5] "Cum_corr_eig" "Cum_br_stick"
R> any(res.lingoes$values$Corr_eig < 0)
[1] FALSE
Best,
Emmanuel
Le 23/10/2018 à 22:11, David Bapst a écrit :
> Hi all,
>
> Not exactly phylogenetic, but I've recently uncovered some odd
behavior
> with `pcoa` in `ape` and I was curious if anyone understood what was
> going on.
>
> Usually, if you don't have negative eigenvalues and aren't using a
> correction, `pcoa` will return the raw eigenvalues. However, I've
found
> if there are negative eigenvalues and no correction is used, even
though
> no correction is applied, the function will still return some
corrected
> relative eigenvalues, and cumulative corrected eigenvalues. What
> correction was used in this case is not clear.
>
> Here's some output using an example dataset from paleotree to
> demonstrate the weirdness, both without correction argument
specified
> and with it specified as "none".
>
> ```
> > library(ape)
> > library(paleotree)
> >
> > data(graptDisparity)
> > dmat<-graptDistMat
> > res<-pcoa(dmat)
> > str(res)
> List of 5
> $ correction: chr [1:2] "none" "1"
> $ note : chr "No correction was applied to the negative
eigenvalues"
> $ values :'data.frame': 183 obs. of 6 variables:
> ..$ Eigenvalues : num [1:183] 3.22 2.72 1.9 1.74 1.41 ...
> ..$ Relative_eig : num [1:183] 0.217 0.183 0.128 0.117 0.095 ...
> ..$ Rel_corr_eig : num [1:183] 0.0495 0.0424 0.031 0.0287
0.0241 ...
> ..$ Broken_stick : num [1:183] 0.0319 0.0264 0.0236 0.0218
0.0204 ...
> ..$ Cum_corr_eig : num [1:183] 0.0495 0.0919 0.1229 0.1517
0.1758 ...
> ..$ Cumul_br_stick: num [1:183] 0.0319 0.0583 0.082 0.1038
0.1242 ...
> $ vectors : num [1:183, 1:72] 0.0143 -0.1818 -0.1011 0.104
0.101 ...
> ..- attr(*, "dimnames")=List of 2
> .. ..$ : chr [1:183] "'Bulmanograptus' macilentus" "'Monograptus'
> arciformis" "'Monograptus' austerus" "'Paramplexograptus'
kiliani" ...
> .. ..$ : chr [1:72] "Axis.1" "Axis.2" "Axis.3" "Axis.4" ...
> $ trace : num 14.8
> - attr(*, "class")= chr "pcoa"
> >
> > data(graptDisparity)
> > dmat<-graptDistMat
> > res<-pcoa(dmat,correction="none")
> > str(res)
> List of 5
> $ correction: chr [1:2] "none" "1"
> $ note : chr "No correction was applied to the negative
eigenvalues"
> $ values :'data.frame': 183 obs. of 6 variables:
> ..$ Eigenvalues : num [1:183] 3.22 2.72 1.9 1.74 1.41 ...
> ..$ Relative_eig : num [1:183] 0.217 0.183 0.128 0.117 0.095 ...
> ..$ Rel_corr_eig : num [1:183] 0.0495 0.0424 0.031 0.0287
0.0241 ...
> ..$ Broken_stick : num [1:183] 0.0319 0.0264 0.0236 0.0218
0.0204 ...
> ..$ Cum_corr_eig : num [1:183] 0.0495 0.0919 0.1229 0.1517
0.1758 ...
> ..$ Cumul_br_stick: num [1:183] 0.0319 0.0583 0.082 0.1038
0.1242 ...
> $ vectors : num [1:183, 1:72] 0.0143 -0.1818 -0.1011 0.104
0.101 ...
> ..- attr(*, "dimnames")=List of 2
> .. ..$ : chr [1:183] "'Bulmanograptus' macilentus" "'Monograptus'
> arciformis" "'Monograptus' austerus" "'Paramplexograptus'
kiliani" ...
> .. ..$ : chr [1:72] "Axis.1" "Axis.2" "Axis.3" "Axis.4" ...
> $ trace : num 14.8
> - attr(*, "class")= chr "pcoa"
> ```
>
> Obviously if there are negative eigenvalues, a correction should
> probably be applied (although perhaps this is a bit of a
philosophical
> matter), but still its unclear why the corrected eigenvalues are
> calculated, or how they are calculated. They are clearly
different from
> the uncorrected values.
>
> Cheers,
> -Dave Bapst
>
>
> --
> David W. Bapst, PhD
> Asst Research Professor, Geology & Geophysics, Texas A & M University
> Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
> https://github.com/dwbapst/paleotree
>
> Pour nous remonter une erreur de filtrage, veuillez vous rendre ici
> <http://f.security-mail.net/54A3Bt5hcV>
>
>
--
David W. Bapst, PhD
Asst Research Professor, Geology & Geophysics, Texas A & M University
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
https://github.com/dwbapst/paleotree
_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/