Methods for analysis of compositional data including robust methods, imputation, methods to replace rounded zeros, (robust) outlier detection for compositional data, (robust) principal component analysis for compositional data, (robust) factor analysis for compositional data, (robust) discriminant analysis for compositional data (Fisher rule), robust regression with compositional predictors and (robust) Anderson-Darling normality tests for compositional data as well as popular log-ratio transformations (addLR, cenLR, isomLR, and their inverse transformations). In addition, visualisation and diagnostic tools are implemented as well as high and low-level plot functions for the ternary diagram.

Robust Methods for Compositional Data

```
using robCompositions
```

data(expenditures)

p1 <- pcaCoDa(expenditures)

plot(p1)

- Imputation of compositional data including robust methods, methods to impute rounded zeros
- Outlier detection for compositional data using robust methods
- Principal component analysis for compositional data using robust methods
- Factor analysis for compositional data using robust methods
- Discriminant analysis for compositional data (Fisher rule) using robust methods
- Robust regression with compositional predictors
- Anderson-Darling normality tests for compositional data
- log-ratio transformations (addLR, cenLR, isomLR, and their inverse transformations).
- In addition, visualisation and diagnostic tools are implemented as well as high and low-level plot functions for the ternary diagram.

- never use classical statistical methods on raw compositional data again.

The package has dependencies on

```
R (>= 2.10), utils, robustbase, rrcov, car (>= 2.0-0), MASS, pls
```

Installion of `robCompositions`

is really easy for registered users (when the R-tools are installed). Just use

```
library(devtools)
install_github("robCompositions", "matthias-da")
```

data(expenditures)

expenditures[1,3]

expenditures[1,3] <- NA

impKNNa(expenditures)$xImp[1,3]

data(expenditures)

x <- expenditures

x[1,3]

x[1,3] <- NA

xi <- impCoda(x)$xImp

xi[1,3]

s1 <- sum(x[1,-3])

impS <- sum(xi[1,-3])

xi[,3] * s1/impS

xi <- impKNNa(expenditures)

xi

summary(xi)

plot(xi, which=1)

plot(xi, which=2)

plot(xi, which=3)

data(expenditures)

p1 <- pcaCoDa(expenditures)

p1

plot(p1)

data(expenditures)

oD <- outCoDa(expenditures)

oD

plot(oD)

data(arcticLake)

x <- arcticLake

x.alr <- addLR(x, 2)

y <- addLRinv(x.alr)

addLRinv(addLR(x, 3))

data(expenditures)

x <- expenditures

y <- addLRinv(addLR(x, 5))

head(x)

head(y)

addLRinv(x.alr, ivar=2, useClassInfo=FALSE)

data(expenditures)

eclr <- cenLR(expenditures)

inveclr <- cenLRinv(eclr)

head(expenditures)

head(inveclr)

head(cenLRinv(eclr$x.clr))

require(MASS)

Sigma <- matrix(c(5.05,4.95,4.95,5.05), ncol=2, byrow=TRUE)

z <- isomLRinv(mvrnorm(100, mu=c(0,2), Sigma=Sigma))

Changes in robCompositions version 2.1.0

- new functions cubeCoord, cubeCoordWrapper, tabCoord, tabCoordWrapper
- new data set employment2
- new data set manu_abs

Changes in robCompositions version 2.0.10

- updated documentation
- going back to old version of imputeBDLs
- mcd based robust variation (instead of mad) in function variation

Changes in robCompositions version 2.0.9

- new method in imputeBDLs
- minor change in imputeBDLs
- new function imputeUDLs

Changes in robCompositions version 2.0.8

- old Rd files management to meet new CRAN policy

Changes in robCompositions version 2.0.7

- bug in daFisher resolved
- additional argment in missPattern
- imputeBDLs now includes a new method

Changes in robCompositions version 2.0.6

- new method for imputation of rounded zeros in imputeBDLs

Changes in robCompositions version 2.0.5

- improved documentation
- version of robCompositions fits now to the Springer book
- orthbasis now times -1
- ilr.2x2 now fits to the formulas in the book, and not for the paper
- bug in daFisher resolved
- bug in external variables in pcaCoDa solved
- registering C-code

Changes in robCompositions version 2.0.4

- aDist now again works for vectors
- added following data sets:
socExp,
cancerMN,
educFM,
electionATbp,
employment,
employment_df,
GDPsatis,
govexp,
instw,
isic32,
mortality_tab,
precipitation,

rcodes, teachingStuff, unemployed - corrected documentation for ageCatWorld data
- new functions: coord, gmean, gmean_sum, ilr.2x2, ind2x2, indTab, int2x2, indTab, int2x2, intArray, intTab, pTab, rSDev, rSDev.test.R, SDev, stats
- bug in daFisher solved and new adapted predict function

Changes in robCompositions version 2.0.3

- new function perturbation() and powering()
- new function for inner product (iprod())
- new funciton balances()
- addLR, cenLR with optional different base in logrithm
- isomLR with more possibilites for a normalizing constant
- isomLR depricated, using now pivotCoord instead
- isomLRinv depricated, using pivotCoordInv instead
- orthbasis() now returns also the basis vectors
- bug in aDist solved
- aDist now much faster
- new function center()
- method symm (symmetric balances) in pivotCoord

Changes in robCompositions version 2.0.2

- new function balZav()
- new function daCoDa()
- new function clustCoDa()
- new function corCoDa()
- aDist for single matrix
- pcaCoDa() with external variables
- new data set alcoholreg
- new data set alcohol
- new data set econom
- new data set ageCatWorld
- new data set election
- new data set laborForce
- new data set payments

Changes in robCompositions version 2.0.1

- discriminant analysis (daFisher) for n-group case
- discriminant analysis (daFisher) including predict
- discriminant analysis (daFisher) including misclassification rates

Changes in robCompositions version 2.0.0

- combined help for some S3methods
- function robVariation is now called variation
- new data sets

Changes in robCompositions version 1.9.1

- now with roxygen2 documentation
- minor modifications in impRZilr

Changes in robCompositions version 1.9.0

- bug in robVariations solved

Changes in robCompositions version 1.8.0

- critical bug in function impRZilr solved (did worked only correct for constant sum data)

Changes in robCompositions version 1.7.0

- bug in function impRZilr solved
- new bootstrap procedure for estimating the number of components within impRZilr
- description in function impRZilr adapted

Changes in robCompositions version 1.6.4

- deprecated functions alr, ilr, clr, invalr, invilr, invclr deleted
- bugfix and enhancement of impRZilr.R
- improvement of isomLR for high-dimensional data

Changes in robCompositions version 1.6.3

```
+ function impAll included.
+ robGUI excluded (is now put in the compositionsGUI package)
```

Changes in robCompositions version 1.6.2

```
+ alr, clr, ilr, invalr, invclr, invilr are now deprecated. The new functions are called
addLR, cenLR, isomLR, addLRinv, cenLRinv, isomLRinv
+ new functions gm, orthbasis, missPatterns and zeroPatterns
+ return instead of invisible return for all log-ratio transformations
```

Changes in robCompositions version 1.5.0

```
+ variable names in expendiure data corrected
+ graphical user interface added
+ vignette about an overview of the package added
+ alrEM() function now renamed in impRZalr() to be consistent with notation
```

Changes in robCompositions version 1.4.6

```
+ correct transformation of the detection limit in impRZilr when having not constant sum 1.
```

Changes in robCompositions version 1.4.5

```
+ Bug in alrEM fixed.
+ impRZilr included, but without documentation.
```

Changes in robCompositions version 1.4.4

```
+ Description for the Expenditures data changed. Wrong variable description fixed.
+ Wrong formula in robVariation method robust=FALSE fixed after an comment
from from Mark Engle (thanks!).
+ Improved code in 'CITATION' file.
```