Learn R Programming

{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.4.1

License

GPL (>= 2)

Maintainer

Last Published

August 25th, 2023

Functions in robCompositions (2.4.1)

alcoholreg

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

Principal component analysis of compositional tables based on backwards pivot coordinates
cancer

hospital discharges on cancer and distribution of age
cenLRinv

Inverse centred logratio mapping
bpcTabWrapper

Backwards pivot coordinates and their inverse
cenLR

Centred logratio coefficients
clustCoDa_qmode

Q-mode cluster analysis for compositional parts
coffee

coffee data set
constSum

Constant sum
compositionalSpline

Compositional spline
compareMahal

Compares Mahalanobis distances from two approaches
coord

Coordinate representation of compositional tables
bpcReg

Classical and robust regression based on backwards pivot coordinates
corCoDa

Correlations for compositional data
ced

Compositional error deviation
cubeCoord

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

malignant neoplasms cancer
bpcTab

Backwards pivot coordinates and their inverse
bpcRegTab

Classical and robust regression based on backwards pivot coordinates
chorizonDL

C-horizon of the Kola data with rounded zeros
daFisher

Discriminant analysis by Fisher Rule.
daCoDa

Linear and quadratic discriminant analysis for compositional data.
efsa

efsa nutrition consumption
election

election data
educFM

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

economic indicators
expenditures

synthetic household expenditures toy data set
clustCoDa

Cluster analysis for compositional data
expendituresEU

mean consumption expenditures data.
fcenLR

fcenLR transformation (functional)
fcenLRinv

Inverse of fcenLR transformations (functional)
electionATbp

Austrian presidential election data
employment2

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

fcenLRp transformation (functional)
employment

employment in different countries by gender and status.
employment_df

Employment in different countries by gender and status.
gmean_sum

Geometric mean
govexp

government spending
impRZalr

alr EM-based imputation of rounded zeros
fcenLRu

fcenLRu transformation (functional)
impKNNa

Imputation of missing values in compositional data using knn methods
impCoda

Imputation of missing values in compositional data
indTab

Independence table
gm

gmean
ind2x2

Independence 2x2 compositional table
haplogroups

haplogroups data.
honey

honey compositions
gjovik

gjovik
intArray

Interaction array
intTab

Interaction table
ilr.2x2

ilr coordinates in 2x2 compositional tables
laborForce

labour force by status in employment
foodbalance

country food balances
mortality

mortality and life expectancy in the EU
landcover

European land cover
gemas

GEMAS geochemical data set
mortality_tab

mortality table
impAll

Replacement of rounded zeros and missing values.
is.equivalent

equivalence class
outCoDa

Outlier detection for compositional data
imputeBDLs

EM-based replacement of rounded zeros in compositional data
pfa

Factor analysis for compositional data
isic32

ISIC codes by name
perturbation

Perturbation and powering
pTab

Propability table
machineOperators

machine operators
lifeExpGdp

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

Distribution of manufacturing output
int2x2

Interaction 2x2 table
rSDev

Relative simplicial deviance
lmCoDaX

Classical and robust regression of non-compositional (real) response on compositional and non-compositional predictors
instw

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

Orthonormal basis
plot.smoothSpl

plot smoothSpl
impRZilr

EM-based replacement of rounded zeros in compositional data
stats

Classical estimates for tables
smoothSplinesVal

Estimate density from histogram - for different alpha
smoothSplines

Estimate density from histogram
precipitation

24-hour precipitation
missPatterns

missing or zero pattern structure.
socExp

social expenditures
imputeUDLs

Imputation of values above an upper detection limit in compositional data
plot.pcaCoDa

Plot method
payments

special payments
pivotCoord

Pivot coordinates and their inverse
mcad

metabolomics mcad data set
nutrients_branded

nutrient contents (branded)
norm1

Normalize a vector to length 1
rdcm

relative difference between covariance matrices
nutrients

nutrient contents
teachingStuff

teaching stuff
trapzc

Trapezoidal formula for numerical integration
robCompositions-package

Robust Estimation for Compositional Data.
ternaryDiag

Ternary diagram
summary.imp

Summary method for objects of class imp
phd

PhD students in the EU
variation

Robust and classical variation matrix
skyeLavas

aphyric skye lavas data
zeroOut

Detection of outliers of zero-inflated data
pcaCoDa

Robust principal component analysis for compositional data
unemployed

unemployed of young people
trondelagC

regional geochemical survey of soil C in Norway
rcodes

codes for UNIDO tables
weightedPivotCoord

Weighted pivot coordinates
ternaryDiagAbline

Adds a line to a ternary diagram.
print.imp

Print method for objects of class imp
ternaryDiagPoints

Add points or lines to a given ternary diagram.
production

production splitted by nationality on enterprise level
rSDev.test

Relative simplicial deviance tests
tabCoord

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

Adds tolerance ellipses to a ternary diagram.
phd_totals

PhD students in the EU (totals)
trondelagO

regional geochemical survey of soil O in Norway
saffron

saffron compositions
plot.imp

Plot method for objects of class imp
ZBsplineBasis

ZB-spline basis
addLR

Additive logratio coordinates
SDev

Simplicial deviance
balances

Balance calculation
aDist

Aitchison distance
addLRinv

Inverse additive logratio mapping
arcticLake

arctic lake sediment data
alcohol

alcohol consumptions by country and type of alcohol
GDPsatis

GDP satisfaction
adjust

Adjusting for original scale
ageCatWorld

child, middle and eldery population
adtestWrapper

Wrapper for Anderson-Darling tests
adtest

Anderson-Darling Normality Tests
biplot.pcaCoDa

Biplot method
bootnComp

Bootstrap to find optimal number of components
biomarker

biomarker
biplot.factanal

Biplot method
bpc

Backwards pivot coordinates and their inverse
bpcPca

Principal component analysis based on backwards pivot coordinates