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

979

Version

2.3.1

License

GPL (>= 2)

Maintainer

Matthias Templ

Last Published

September 20th, 2021

Functions in robCompositions (2.3.1)

ageCatWorld

child, middle and eldery population
corCoDa

Correlations for compositional data
compositionalSpline

Compositional spline
coord

Coordinate representation of compositional tables
alcohol

alcohol consumptions by country and type of alcohol
constSum

Constant sum
alcoholreg

regional alcohol per capita (15+) consumption by WHO region
cancer

hospital discharges on cancer and distribution of age
ced

Compositional error deviation
arcticLake

arctic lake sediment data
biomarker

biomarker
biplot.factanal

Biplot method
cancerMN

malignant neoplasms cancer
expendituresEU

mean consumption expenditures data.
bootnComp

Bootstrap to find optimal number of components
biplot.pcaCoDa

Biplot method
fcenLRinv

Inverse of fcenLR transformations (functional)
cenLR

Centred logratio coefficients
chorizonDL

C-horizon of the Kola data with rounded zeros
fcenLRu

fcenLRu transformation (functional)
cenLRinv

Inverse centred logratio mapping
balances

Balance calculation
economy

economic indicators
impAll

Replacement of rounded zeros and missing values.
compareMahal

Compares Mahalanobis distances from two approaches
daFisher

Discriminant analysis by Fisher Rule.
impRZilr

EM-based replacement of rounded zeros in compositional data
clustCoDa

Cluster analysis for compositional data
electionATbp

Austrian presidential election data
clustCoDa_qmode

Q-mode cluster analysis for compositional parts
election

election data
coffee

coffee data set
cubeCoord

Coordinate representation of a compositional cube and of a sample of compositional cubes
indTab

Independence table
imputeBDLs

EM-based replacement of rounded zeros in compositional data
fcenLRp

fcenLRp transformation (functional)
isic32

ISIC codes by name
fcenLR

fcenLR transformation (functional)
impCoda

Imputation of missing values in compositional data
efsa

efsa nutrition consumption
foodbalance

country food balances
laborForce

labour force by status in employment
educFM

education level of father (F) and mother (M)
gm

gmean
instw

value added, output and input for different ISIC codes and countries.
lifeExpGdp

life expectancy and GDP (2008) for EU-countries
pcaCoDa

Robust principal component analysis for compositional data
daCoDa

Linear and quadratic discriminant analysis for compositional data.
perturbation

Perturbation and powering
ilr.2x2

ilr coordinates in 2x2 compositional tables
honey

honey compositions
employment_df

Employment in different countries by gender and status.
govexp

government spending
int2x2

Interaction 2x2 table
gmean_sum

Geometric mean
haplogroups

haplogroups data.
expenditures

synthetic household expenditures toy data set
impKNNa

Imputation of missing values in compositional data using knn methods
impRZalr

alr EM-based imputation of rounded zeros
nutrients_branded

nutrient contents (branded)
nutrients

nutrient contents
intTab

Interaction table
plot.smoothSpl

plot smoothSpl
lmCoDaX

Classical and robust regression of non-compositional (real) response on compositional predictors
plot.imp

Plot method for objects of class imp
pTab

Propability table
is.equivalent

equivalence class
smoothSplinesVal

Estimate density from histogram - for different alpha
mortality

mortality and life expectancy in the EU
plot.pcaCoDa

Plot method
mortality_tab

mortality table
pfa

Factor analysis for compositional data
payments

special payments
phd

PhD students in the EU
skyeLavas

aphyric skye lavas data
smoothSplines

Estimate density from histogram
precipitation

24-hour precipitation
employment2

Employment in different countries by Sex, Age, Contract, Value
employment

employment in different countries by gender and status.
stats

Classical estimates for tables
socExp

social expenditures
intArray

Interaction array
mcad

metabolomics mcad data set
missPatterns

missing or zero pattern structure.
summary.imp

Summary method for objects of class imp
zeroOut

Detection of outliers of zero-inflated data
rSDev

Relative simplicial deviance
weightedPivotCoord

Weighted pivot coordinates
rSDev.test

Relative simplicial deviance tests
tabCoord

Coordinate representation of compositional tables and a sample of compositional tables
variation

Robust and classical variation matrix
gemas

GEMAS geochemical data set
pivotCoord

Pivot coordinates and their inverse
teachingStuff

teaching stuff
phd_totals

PhD students in the EU (totals)
saffron

saffron compositions
robCompositions-package

Robust Estimation for Compositional Data.
ternaryDiagAbline

Adds a line to a ternary diagram.
ternaryDiag

Ternary diagram
rcodes

codes for UNIDO tables
unemployed

unemployed of young people
trondelagO

regional geochemical survey of soil O in Norway
trapzc

Trapezoidal formula for numerical integration
rdcm

relative difference between covariance matrices
trondelagC

regional geochemical survey of soil C in Norway
ind2x2

Independence 2x2 compositional table
machineOperators

machine operators
imputeUDLs

Imputation of values above an upper detection limit in compositional data
manu_abs

Distribution of manufacturing output
gjovik

gjovik
orthbasis

Orthonormal basis
outCoDa

Outlier detection for compositional data
print.imp

Print method for objects of class imp
production

production splitted by nationality on enterprise level
ternaryDiagEllipse

Adds tolerance ellipses to a ternary diagram.
ternaryDiagPoints

Add points or lines to a given ternary diagram.
addLRinv

Inverse additive logratio mapping
aDist

Aitchison distance
SDev

Simplicial deviance
ZBsplineBasis

ZB-spline basis
GDPsatis

GDP satisfaction
adjust

Adjusting for original scale
adtest

Anderson-Darling Normality Tests
adtestWrapper

Wrapper for Anderson-Darling tests
addLR

Additive logratio coordinates