Learn R Programming

⚠️There's a newer version (2.4.1) of this package.Take me there.

{robCompositions}

Robust Methods for Compositional Data

using robCompositions

data(expenditures)

p1 <- pcaCoDa(expenditures)

plot(p1)

What is it?

  • 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.

Goals

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

Getting Started

Dependencies

The package has dependencies on

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

Installation

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

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

Examples

k nearest neighbor imputation

data(expenditures)

expenditures[1,3]

expenditures[1,3] <- NA

impKNNa(expenditures)$xImp[1,3]

iterative model based imputation

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)

pca

data(expenditures)

p1 <- pcaCoDa(expenditures)

p1

plot(p1)

outlier detection

data(expenditures)

oD <- outCoDa(expenditures)

oD

plot(oD)

transformations

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))

Copy Link

Version

Install

install.packages('robCompositions')

Monthly Downloads

1,518

Version

2.0.0

License

GPL-2

Maintainer

Last Published

February 8th, 2016

Functions in robCompositions (2.0.0)

constSum

Constant sum
adtestWrapper

Wrapper for Anderson-Darling tests
bootnComp

Bootstrap to find optimal number of components
lifeExpGdp

Life expectancy and GDP (2008) for EU-countries
ternaryDiagPoints

Add points or lines to a given ternary diagram.
outCoDa

Outlier detection for compositional data
coffee

coffee data set
biplot.pcaCoDa

Biplot method
imputeBDLs

EM-based replacement of rounded zeros in compositional data
ternaryDiagEllipse

Adds tolerance ellipses to a ternary diagram.
biplot.factanal

Biplot method
addLRinv

Additive logistic transformaton
lmCoDaX

Classical and robust regression of non-compositional response on compositional predictors
gemas

Gemas geochemical data set
cancer

Hospital discharges on cancer and distribution of age
mortality

Mortality and life expectancy in the EU
print.imp

Print method for objects of class imp
impAll

Replacement of rounded zeros and missing values.
impRZilr

EM-based replacement of rounded zeros in compositional data
isomLR

Isometric log-ratio transformation
adtest

Anderson-Darling Normality Tests
cenLRinv

Inverse centred log-ratio transformation
economy

Economic indicators
summary.imp

Summary method for objects of class imp
machineOperators

machine operators
arcticLake

Arctic lake sediment data
impCoda

Imputation of missing values in compositional data
pcaCoDa

Robust principal component analysis for compositional data
phd

PhD Students in the EU
compareMahal

Compares Mahalanobis distances from two approaches
variation

Robust and classical variation matrix
plot.imp

Plot method for objects of class imp
daFisher

Discriminant analysis by Fisher Rule.
expenditures

Synthetic household expenditures toy data set
trondelagC

Regional geochemical survey of soil C in Norway
addLR

Additive log-ratio transformation
laborForce

Labour force by status in employment
ternaryDiag

Ternary diagram
adjust

Adjusting for original scale
aDist

Aitchison distance
haplogroups

Haplogroups data.
expendituresEU

Mean consumption expenditures data.
robCompositions-package

Robust Estimation for Compositional Data.
ternaryDiagAbline

Adds a line to a ternary diagram.
impRZalr

alr EM-based Imputation for Rounded Zeros
zeroOut

Detection of outliers of zero-inflated data
gm

geometric mean
trondelagO

Regional geochemical survey of soil O in Norway
cenLR

Centred log-ratio transformation
mcad

Metabolomics mcad data set
orthbasis

Orthonormal basis
impKNNa

Imputation of missing values in compositional data using knn methods
skyeLavas

Aphyric skye lavas data
pfa

Factor analysis for compositional data
plot.pcaCoDa

Plot method
missPatterns

missing or zero pattern structure.