Re: [R-sig-eco] Minimum Number of Observations for pcaCoDa?

2014-11-21 Thread Jari Oksanen
Rich,

It seems that the robust covariance matrix (? I assume it is that) is not 
non-negative definite... 

Function robCompositios::pcaCoDa seems to use function princomp of base R (or 
its stats package) as the engine to get the principal components. If that 
function is used for raw data, it stops with error message ('princomp' can 
only be used with more units than variables) if the number of columns is 
larger than the number of rows. However, it seems that it may still be able to 
handle these cases if you use covariance matrix, and the last (ncol  nrow) 
eigenvalues will be numerically zero -- that is: the covariance matrix is 
non-negative definite. Normal covariance matrices normally satisfy this (with 
provision of numerical precision), but it seems that the robust covariance 
matrix does not.

Actually, the warning is very clear and says: n  2 * p, i.e., possibly too 
small sample size. The condition I put above was only that n  p, but this 
seems to require that the number of rows is two times higher than the number of 
columns. Because this was not case, the warning came true and you got an error. 
So yes, you need more data if you wish to use this tool. 

Cheers, Jari Oksanen

From: r-sig-ecology-boun...@r-project.org r-sig-ecology-boun...@r-project.org 
on behalf of Rich Shepard rshep...@appl-ecosys.com
Sent: 21 November 2014 00:08
To: r-sig-ecology@r-project.org
Subject: [R-sig-eco] Minimum Number of Observations for pcaCoDa?

   The compositional data sets have few observations: 4 to 7 rows each, but
there are 5 parts (columns) for each row.

   I tried to use the robCompositions function pcaCoDa(). There was an error
and warning generated:

( winters.biplot - pcaCoDa(winters.coda) )
Error in princomp.default(xilr, covmat = cv, cor = FALSE) :
   covariance matrix is not non-negative definite
In addition: Warning message:
In covMcd(xilr, cor = FALSE) :
   n  2 * p, i.e., possibly too small sample size

   The matrix for winters.code has the counts:

   filter gather graze predate shred
1  3 27 3  11 1
2  3 28 3  13 2
3  3 43 7  15 1
4  4 54 6  24 3
5  3 26 4  22 5
6  1 39 2  18 2

   Same results with the data file winters.acomp:

  filtergather  graze   predate  shred
[1,] 0.0667 0.600 0.0667 0.244 0.0222
[2,] 0.06122449 0.5714286 0.06122449 0.2653061 0.04081633
[3,] 0.04347826 0.6231884 0.10144928 0.2173913 0.01449275
[4,] 0.04395604 0.5934066 0.06593407 0.2637363 0.03296703
[5,] 0.0500 0.433 0.0667 0.367 0.0833
[6,] 0.01612903 0.6290323 0.03225806 0.2903226 0.03225806
attr(,class)
[1] acomp

   Is there a minimum number of observations for PCA or was I using the
incorrect data format?

Rich

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


[R-sig-eco] Minimum Number of Observations for pcaCoDa?

2014-11-20 Thread Rich Shepard

  The compositional data sets have few observations: 4 to 7 rows each, but
there are 5 parts (columns) for each row.

  I tried to use the robCompositions function pcaCoDa(). There was an error
and warning generated:

( winters.biplot - pcaCoDa(winters.coda) )
Error in princomp.default(xilr, covmat = cv, cor = FALSE) :
  covariance matrix is not non-negative definite
In addition: Warning message:
In covMcd(xilr, cor = FALSE) :
  n  2 * p, i.e., possibly too small sample size

  The matrix for winters.code has the counts:

  filter gather graze predate shred
1  3 27 3  11 1
2  3 28 3  13 2
3  3 43 7  15 1
4  4 54 6  24 3
5  3 26 4  22 5
6  1 39 2  18 2

  Same results with the data file winters.acomp:

 filtergather  graze   predate  shred
[1,] 0.0667 0.600 0.0667 0.244 0.0222
[2,] 0.06122449 0.5714286 0.06122449 0.2653061 0.04081633
[3,] 0.04347826 0.6231884 0.10144928 0.2173913 0.01449275
[4,] 0.04395604 0.5934066 0.06593407 0.2637363 0.03296703
[5,] 0.0500 0.433 0.0667 0.367 0.0833
[6,] 0.01612903 0.6290323 0.03225806 0.2903226 0.03225806
attr(,class)
[1] acomp

  Is there a minimum number of observations for PCA or was I using the
incorrect data format?

Rich

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology