Revision a53065a09c3fce65a63e137deb5bccb6162e6cff authored by Matthias Templ on 18 November 2020, 20:10 UTC, committed by cran-robot on 18 November 2020, 20:10 UTC
1 parent 9ae1e67
Raw File
%\VignetteIndexEntry{Overview of the robCompostions package}



\title{Overview of the robCompositons package. Compositional Data Analysis using Robust Methods.}
\authors{M. TEMPL$^{1,3}$, P. FILZMOSER$^1$ and K. HRON$^2$}
\affiliation{$^1$Department of Statistics and Probability Theory -  
Vienna University of Technology, Austria \email{}\\
$^2$Department of Mathematical Analysis and Applications of Mathematics -  
Palack\'y University, Czech Republic\\
$^3$Statistics Austria, Vienna, Austria}


\section{Few Words about R and CoDa}

The free and open-source programming language and software environment
\texttt{R} \citep{R} is currently both, the most widely used and most popular
software for statistics and data analysis. In addition, \texttt{R} becomes
quite popular as a (programming) language, ranked
currently (February 2011) on place 25 at the TIOBE Programming Community Index 
(e.g., Matlab: 29, SAS: 30, see 

The basic \texttt{R} environment can be downloaded from the
comprehensive \texttt{R} archive network
(\href{}{}). \texttt{R} is
enhanceable via \textit{packages} which consist of code and structured standard
documentation including code application examples and possible further documents
(so called \textit{vignettes}) showing further applications of the
packages. \\    

Two contributed packages for compositional data analysis comes with 
\texttt{R}, version~2.12.1.: 
the package  \texttt{compositions} \citep{Boo10} and the
package \texttt{robCompositions} \citep{Templ11R}.

Package \texttt{compositions} provides functions for the consistent 
analysis of compositional data and positive
numbers in the way proposed originally by John Aitchison 

In addition to the basic functionality and estimation procedures
in package \texttt{compositions}, package \texttt{robCompositions} provides
tools for a (classical) and robust multivariate statistical analysis of
compositional data together with corresponding graphical tools. In addition,
several data sets are provided as well as useful utility functions.

\section{Motivation to Robust Statistics}

Both measurement errors and population outliers can have a high influence on classical estimators. 
Arbitrary results may be the consequence, because outliers may have a large
influence and wrong interpretation of estimations may result. In addition, 
checking model assumptions is then often not possible since 
outliers may disturb the applied model itself. All these problems may be avoided
when applying methods based on robust estimators. \\

To be more specific, a simple analysis is done in the following by applying
principal component analysis - using function \texttt{pcaCoDa()} of package
\texttt{robCompositions} - to the \textit{Arctic Lake sediment data set}
\citep{Ait86}. We show the effect of outliers on a \textbf{simplyfied example for
demostration purposes}. However, the same problems occur in higher dimensions
where usually principal component analysis is applied mostly for dimension
reduction purposes. 

 \subfigure[Ternary diagram of the arcticLake data]{
 \subfigure[Ilr transformed arcticLake data]{
 \subfigure[First principal component for ilr transformed data.]{
 \subfigure[First principal component back-transformed to original scale.]{
  The upper left graphic  \subref{fig:ternary} shows a ternary diagram of the
  \textit{Arctic Lake Sediment Data}. In the upper right graphic
  \subref{fig:ilr}, the ilr-transformed data are shown and the first principal component is displayed
  in Figure~\subref{fig:pca1} while the first principal
  component is shown in the ternary diagram in Figure~\subref{fig:pca2}.}

Figure~\ref{fig:ternary} shows the 3-part compositions of the Arctic Lake
Sedimanet Data in a ternary diagram. Few outliers are clearly visible, like the
two ones with higher percentages in the \textit{silc}-part.
After transforming the parts by using the isometric log-ratio transformation
\citep{EPMB03}, outliers are still visible (see Figure~\ref{fig:ilr}).
For obtaining the principal components, the eigenvalues of the 
covariance matrix need to be derived. A robust estimation of the underlying
covariance matrix leads to robust principal components. 
Figure~\ref{fig:pca1} shows the direction of the first principal component
when using different covariance estimators:
classical estimation (black solid line), and robust estimation using
the MM estimator \citep[see, e.g.,][]{MMY06} (dotted line in grey),
and the (fast) MCD estimator \citep{Rousseeuw99} (black coloured dashed line)
with high degree of robustness. 
It is easy to see that the first principal component is attracted by the few
outliers in the lower right plot, while the principal
components obtained from robust estimates are not. Finally, in Figure~\ref{fig:pca2}
the first principal components of the classical and the robust estimators are
shown in the ternary diagram. Again, it is easy to see that the first principal
component from classical estimation is highly influenced, especially by the
two outliers having higher concentration in silt. The line does not follow
the main part of the data. \\     

This example shows that robust estimation is important to get reliable estimates
for multivariate analysis of compositional data, especially when using more
complex data than this simple 3-part composition.

\section{Available Functionality}

In the following the data sets and most important functions of package
\texttt{robCompositions} are briefly described. Note, that almost all print and
summary functions are not listed here, but their description is available in 

\subsection{Data sets}

Several compositional data sets are included in the package, like:\\

  \texttt{arcticLake} & The Artic Lake Sediment Data from the Aitchison book
  \citep{Ait86}. \\
  \texttt{coffee} & The Coffee Data contain 27 commercially available coffee
  samples of different origins \citep[see][]{Kor09}. \\
  \texttt{expenditures} & The Household Expenditures Data on five commodity
     groups of 20 single men from the Aitchison book \citep{Ait86}. \\
  \texttt{expendituresEU} & Mean consumption expenditure of households at
     EU-level (2005) provided by Eurostat.\\
  \texttt{haplogroups} &   Distribution of European Y-chromosome DNA (Y-DNA)
  haplogroups by region in percentages, from Eupedia. \\
  \texttt{machineOperators} & This data set from \cite[][p. 382]{Ait86}
  contains compositions of eight-hour shifts of 27 machine operators. \\
  \texttt{phd} &  PhD students in Europe based on the standard classification
  system splitted by different kind of studies (given as percentages), provided by
     Eurostat 2009. \\
  \texttt{skyeLavas} & AFM compositions of 23 aphyric Skye lavas 
                    \citep[][p. 360]{Ait86}.

\subsection{Basic functions}

Basic utility functions like log-ratio transformations but also functions
which specially written in \texttt{C} (for e.g. to compute distances between
compositions) are implemented in the package. The most important are:\\

  \texttt{aDist(x, y)} & Computes the Aitchison distance between two
  observations or between two data sets. The underlying code is written in
  \texttt{C} and allows a fast computation also for large data sets. \\ 
  \texttt{constSum(x, const=1)} & Closes compositions to sum up to a given
  constant (default 1). \\
  \texttt{robVariation(x, robust=TRUE)} & Estimates the variation matrix
  with robust or classical methods. \\ 
  \texttt{ternaryDiag(x, \ldots)} & Ternary diagram, optionally with grid. \\
  \texttt{alr(x, ivar=ncol(x))} & The alr transformation moves $D$-part
  compositional data from the simplex into a ($D-1$)-dimensional real space. \\ 
  \texttt{invalr(x, \ldots)} & Inverse
  additive log-ratio transformation, often called additive logistic transform.
  The function allows also to preserve absolute values when parameter class info
  is provided. \\
  \texttt{clr(x)} & The clr transformation moves $D$-part compositional
  data from the simplex into a $D$-dimensional real space. \\ 
  \texttt{invclr(x, useClassInfo = TRUE)} &  The inverse clr
  transformation. Absolute values are preserved optionally. \\
  \texttt{ilr(x)}  & An isometric log-ratio transformation with a special
  choice of the balances according to \cite{hron10}. \\ 
  \texttt{invilr(x.ilr)} & The inverse transformation of \texttt{ilr()}.

\subsection{Exploratory Tools}

Multivariate outlier detection can give a first impression about the
general data structure and quality \citep{MMY06}. This is also true
for compositional data. The compositions are firstly transformed to
the real space before robust methods are applied for outlier detection \citep{FH08}.

The (robust) compositional biplot displays both samples and variables of a data
matrix graphically in the form of scores and loadings of a principal component
analysis, preferably - because of interpretation of the biplot - after clr
transformation of the data \citep{FHR09}. 

The package comes with the following functionality for exploratory compositional
data analysis: \\

\texttt{outCoDa(x, \ldots)} & Outlier
detection for compositional data using classical and robust statistical methods
\texttt{plot.outCoDa} or \texttt{plot()} & Plots the Mahalanobis distances to detect potential outliers.
\texttt{pcaCoDa(x, method = "robust")} & 
This function applies robust principal component analysis for compositional 
data \citep{FHR09}. \\
\texttt{plot.pcaCoDa()} or \texttt{plot()} & Provides robust compositional

\subsection{Model-based Multivariate Estimation and Tests}

Outliers may lead to model misspecification, biased parameter
estimation and incorrect results. 

The main functionality of package \texttt{robCompositions} is provided on
model-based estimations, namely factor analysis \citep{FHRG09}, discriminant
analysis \citep{FHT09} and imputation of rounded zeros \citep{Palarea08} or
missing values \citep{hron10}.

The package provides the following functions:\\

\texttt{adtest(x, R = 1000, locscatt = "standard")} & This function provides
three kinds of Anderson-Darling normality Tests.  \\
\texttt{adtestWrapper(x, alpha = 0.05, R = 1000, robustEst = FALSE)} & A set of
Anderson-Darling tests are applied as proposed by \cite{Ait86}. \\
\texttt{summary.adtestWrapper} or \texttt{summary()}  & Summary of the
adtestWrapper results.\\
\texttt{alrEM(x, pos = ncol(x), dl = \ldots)} & A
modified EM alr-algorithm for replacing rounded zeros in compositional data sets \citep{Palarea08}. \\
 \texttt{daFisher(x, grp, \ldots)} &
 Discriminant analysis by Fishers rule \citep[as described in][]{FHT09}. \\
\texttt{impCoda(x, method = "ltsReg", \ldots)} & Iterative model-based 
 imputation of missing values using special balances \citep{hron10}.
\texttt{impKNNa(x, method = "knn", k = 3, \ldots)} &
    This function offers several k-nearest neighbor methods for the imputation
        of missing values in compositional data \citep{hron10}. \\
\texttt{plot.imp()} or \texttt{plot()} & This function provides several
diagnostic plots for the imputed data set in order to see how the imputed values are distributed in comparison with
the original data values \citep{Templ09}. \\
\texttt{pfa(x, factors, \ldots)}
 & Computes the principal factor analysis of the input data which are
 clr transformed first.

\section{Conclusion and Outline}

In this contribution we started with a short motivation why robustness is of
major concern in compositional data analysis.

We then briefly introduced and listed the methods implemented in package
More details about each function can be found in the manual of the package
\cite{Templ11R} and in the book chapter about
\texttt{robCompositions} in the forthcoming book \textit{Compositional Data
Analysis: Theory and Applications} \citep{Vera11}. \\

The package comes with the \textit{General Public Licence, version 2}, and can
simple be downloaded at
\ .\\

Future developments include further methods on replacing rounded zeros in the
data as well as to handle structural zeros. Furthermore, a graphical user
interface is currently developed. 

Comments and collaborations regarding the development of the package
are warmly welcome.

\bibliographystyle{chicago}   % name your BibTeX data base


Aitchison, J. (1986).
\newblock {\em {T}he {S}tatistical {A}nalysis of {C}ompositional {D}ata}.
\newblock Monographs on {S}tatistics and {A}pplied {P}robability. Chapman \&
  Hall Ltd., London (UK). (Reprinted in 2003 with additional material by The
  Blackburn Press).
\newblock 416 p.

\bibitem[\protect\citeauthoryear{van~den Boogaart, Tolosana, and Bren}{van~den
  Boogaart et~al.}{2010}]{Boo10}
van~den Boogaart, K.~G., R.~Tolosana, and M.~Bren (2010).
\newblock {\em compositions: Compositional Data Analysis}.
\newblock R package version 1.10-1.

\bibitem[\protect\citeauthoryear{Egozcue, Pawlowsky-Glahn, Mateu-Figueras,
and Barcel\'o-Vidal}{Egozcue et~al.}{2003}]{EPMB03}
Egozcue, J.J., V.~Pawlowsky-Glahn, G.~Mateu-Figueras, and C.~Barcel\'o-Vidal.
\newblock Isometric logratio transformations for compositional data analysis.
\newblock {\em Mathematical Geology\/}~{\em 35\/}(3), 279--300.

\bibitem[\protect\citeauthoryear{Filzmoser and Hron}{Filzmoser and Hron}
Filzmoser, P., and K.~Hron (2008).
\newblock Outlier detection for compositional data using robust methods. 
\newblock {\em Mathematical Geosciences\/}~{\em 40\/}(3), 233--248.

\bibitem[\protect\citeauthoryear{Filzmoser, Hron, and Reimann}{Filzmoser et~al.}
Filzmoser, P., K.~Hron, and C.~Reimann (2009a). 
\newblock Principal component analysis for
compositional data with outliers. 
\newblock {\em Environmetrics\/}~{\em 20\/}(6), 621--632.

\bibitem[\protect\citeauthoryear{Filzmoser, Hron, Reimann, and Garrett}{Filzmoser et~al.}
Filzmoser, P., K.~Hron, C.~Reimann, and R.G.~Garrett (2009b). 
\newblock Robust factor analysis for compositional data.
\newblock {\em Computers and Geosciences\/}~{\em 35}, 1854--1861.

\bibitem[\protect\citeauthoryear{Filzmoser, Hron, and Templ}{Filzmoser et~al.}
Filzmoser, P., K.~Hron, and M.~Templ (2009c). 
\newblock Discriminant analysis for compositional data and robust parameter estimation.
\newblock Technical Report SM-2009-3, Vienna University of Technology, Austria.
Submitted for publication.

\bibitem[\protect\citeauthoryear{Hron, Templ, and Filzmoser}{Hron
Hron, K., M.~Templ, and P.~Filzmoser (2010).
\newblock Imputation of missing values for compositional data using classical
  and robust methods.
\newblock {\em Computational Statistics and Data Analysis\/}~{\em 54\/}(12),
\newblock DOI:10.1016/j.csda.2009.11.023.

\bibitem[\protect\citeauthoryear{Korho\v{n}ov\'a, Hron, Klim\v{c}\'ikov\'a, Muller,
  Bedn\'ar, and Bart\'ak}{Korhonov\'a et~al.}{2009}]{Kor09}
Korho\v{n}ov\'a, M., K.~Hron, D.~Klim\v{c}\'ikov\'a, L.~M\"uller, P.~Bedn\'a\v{r}, and
  P.~Bart\'ak (2009).
\newblock Coffee aroma - statistical analysis of compositional data.
\newblock {\em Talanta\/}~{\em 80\/}(82), 710--715.

\bibitem[\protect\citeauthoryear{Maronna, Martin, and Yohai}{Maronna et~al.}
Maronna, R., D.~Martin, and V.~Yohai (2006).
\newblock {\em Robust {S}tatistics: {T}heory and {M}ethods}.
John Wiley {\&} Sons Canada Ltd., Toronto, ON.

\bibitem[Palarea-Albaladejo, and Martin-Fernandez (2008)]{Palarea08} 
Palarea-Albaladejo, J., and J.A. Mart\'{i}n-Fern\'{a}ndez (2008). 
\newblock A modified EM alr-algorithm for replacing rounded zeros in
compositional data sets. 
\newblock {\em Computers and Geosciences}, 34:\penalty0 902--917.

\bibitem[Pawlowsky-Glahn, and Buccianti (2011)]{Vera11}
Pawlowsky-Glahn, V., and A. Buccianti (2011).
\newblock {\em Compositional Data Analysis: Theory and Applications}. John Wiley
{\&} Sons Canada Ltd., Toronto, ON. Accepted for publication.

\bibitem[\protect\citeauthoryear{{R Development Core Team}}{{R Development Core
{R Development Core Team} (2010).
\newblock {\em R: A Language and Environment for Statistical Computing}.
\newblock Vienna, Austria: R Foundation for Statistical Computing.
\newblock {ISBN} 3-900051-07-0.

\bibitem[Rousseeuw and von Driessen(1999)]{Rousseeuw99}
Rousseeuw, P.J., and K. von Driessen (1999).
\newblock A fast algorithm for the minimum covariance determinant estimator.
\newblock \emph{Technometrics}, 41:\penalty0 212--223, 1999.

\bibitem[\protect\citeauthoryear{Templ, Hron, and Filzmoser}{Templ
Templ, M., K.~Hron, and P.~Filzmoser (2011).
\newblock {\em robCompositions: Robust Estimation for Compositional Data}.
\newblock Manual and package, version 1.4.4.

\bibitem[Templ, Filzmoser, and Hron (2009)]{Templ09}
Templ, M., P.~Filzmoser, and K.~Hron (2009).
\newblock Imputation of item non-responses in compositional data using robust
\newblock  \emph{Work Session on Statistical Data Editing}, 
Neuchatel, Switzerland, 11 pages.



back to top