[R] Package 'compositions', function acomp() With Missing Data

Rich Shepard rshepard at appl-ecosys.com
Mon Sep 29 19:53:15 CEST 2014


   The acomp() function works well on data sets with no missing data. For
example:

win.acomp <- acomp(win.cast, parts=2:6)
> win.acomp
      Filterer   Gatherer  Grazer     Predator  Shredder 
[1,] 0.06670000 0.6000000 0.06670000 0.2444000 0.02220000
[2,] 0.06120612 0.5714571 0.06120612 0.2653265 0.04080408
[3,] 0.04350000 0.6232000 0.10140000 0.2174000 0.01450000
[4,] 0.04400000 0.5934000 0.06590000 0.2637000 0.03300000
[5,] 0.05000000 0.4333000 0.06670000 0.3667000 0.08330000
[6,] 0.01610000 0.6290000 0.03230000 0.2903000 0.03230000
attr(,"class")
[1] acomp

   When the data set has one missing value, acomp() produces output but
changes the missing value from MAR (Missing At Random) to MNAR (Missing Not
At Random) when the missing variable is in quotes ...

> burns.cast
     sampdate Filterer Gatherer Grazer Predator Shredder
1 2000-07-18   0.0550   0.5596 0.0734   0.2294   0.0826
2 2003-07-08   0.0734   0.6147 0.0183   0.2294   0.0642
3 2005-07-13   0.1161   0.5714 0.0357   0.1696   0.1071
4 2006-06-28   0.1000   0.4667 0.1500   0.1333   0.1500
5 2010-09-14   0.0778   0.6111 0.0444   0.1889   0.0778
6 2011-07-13   0.0879   0.5714 0.0659   0.2747       NA
7 2012-07-11   0.1042   0.5313 0.0625   0.2396   0.0625
8 2013-07-11   0.0723   0.5542 0.0602   0.2651   0.0482

> burns.acomp <- acomp(burns.cast, parts=2:6, MAR='NA')
> burns.acomp
      Filterer   Gatherer  Grazer     Predator  Shredder 
[1,] 0.05500000 0.5596000 0.07340000 0.2294000 0.08260000
[2,] 0.07340000 0.6147000 0.01830000 0.2294000 0.06420000
[3,] 0.11611161 0.5714571 0.03570357 0.1696170 0.10711071
[4,] 0.10000000 0.4667000 0.15000000 0.1333000 0.15000000
[5,] 0.07780000 0.6111000 0.04440000 0.1889000 0.07780000
[6,] 0.08790879 0.5714571 0.06590659 0.2747275       MNAR
[7,] 0.10418958 0.5312469 0.06249375 0.2395760 0.06249375
[8,] 0.07230000 0.5542000 0.06020000 0.2651000 0.04820000
attr(,"class")
[1] acomp

... or BDL (Below Detection Limits) when the missing variable is without
quotes:

burns.acomp <- acomp(burns.cast, parts=2:6, MAR=NA)
> burns.acomp
      Filterer   Gatherer  Grazer     Predator  Shredder 
[1,] 0.05500000 0.5596000 0.07340000 0.2294000 0.08260000
[2,] 0.07340000 0.6147000 0.01830000 0.2294000 0.06420000
[3,] 0.11611161 0.5714571 0.03570357 0.1696170 0.10711071
[4,] 0.10000000 0.4667000 0.15000000 0.1333000 0.15000000
[5,] 0.07780000 0.6111000 0.04440000 0.1889000 0.07780000
[6,] 0.08790879 0.5714571 0.06590659 0.2747275        BDL
[7,] 0.10418958 0.5312469 0.06249375 0.2395760 0.06249375
[8,] 0.07230000 0.5542000 0.06020000 0.2651000 0.04820000
attr(,"class")
[1] acomp

   The dput() output for burns.cast is attached.

   How should the acomp() command be formated when there are values missing
at random?

Rich
-------------- next part --------------
structure(list(sampdate = structure(c(11156, 12241, 12977, 13327, 
14866, 15168, 15532, 15897), class = "Date"), Filterer = c(0.055, 
0.0734, 0.1161, 0.1, 0.0778, 0.0879, 0.1042, 0.0723), Gatherer = c(0.5596, 
0.6147, 0.5714, 0.4667, 0.6111, 0.5714, 0.5313, 0.5542), Grazer = c(0.0734, 
0.0183, 0.0357, 0.15, 0.0444, 0.0659, 0.0625, 0.0602), Predator = c(0.2294, 
0.2294, 0.1696, 0.1333, 0.1889, 0.2747, 0.2396, 0.2651), Shredder = c(0.0826, 
0.0642, 0.1071, 0.15, 0.0778, NA, 0.0625, 0.0482)), .Names = c("sampdate", 
"Filterer", "Gatherer", "Grazer", "Predator", "Shredder"), row.names = c(NA, 
-8L), class = "data.frame")


More information about the R-help mailing list