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

953

Version

2.1.0

License

GPL (>= 2)

Maintainer

Matthias Templ

Last Published

April 15th, 2019

Functions in robCompositions (2.1.0)

cenLR

Centred logratio coefficients
cancerMN

malignant neoplasms cancer
int2x2

Interaction 2x2 table
ced

Compositional error deviation
gemas

GEMAS geochemical data set
educFM

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

gjovik
instw

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

election data
machineOperators

machine operators
cenLRinv

Inverse centred logratio mapping
biplot.factanal

Biplot method
alcoholreg

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

Coordinate representation of compositional tables
pcaCoDa

Robust principal component analysis for compositional data
corCoDa

Correlations for compositional data
manu_abs

Distribution of manufacturing output
arcticLake

arctic lake sediment data
daFisher

Discriminant analysis by Fisher Rule.
adtestWrapper

Wrapper for Anderson-Darling tests
perturbation

Perturbation and powering
biplot.pcaCoDa

Biplot method
bootnComp

Bootstrap to find optimal number of components
balances

Balance calculation
biomarker

biomarker
economy

economic indicators
clustCoDa

Cluster analysis for compositional data
cancer

hospital discharges on cancer and distribution of age
chorizonDL

C-horizon of the Kola data with rounded zeros
employment2

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

Q-mode cluster analysis for compositional parts
employment_df

Employment in different countries by gender and status.
expendituresEU

mean consumption expenditures data.
expenditures

synthetic household expenditures toy data set
mcad

metabolomics mcad data set
coffee

coffee data set
electionATbp

Austrian presidential election data
phd_totals

PhD students in the EU (totals)
pivotCoord

Pivot coordinates and their inverse
compareMahal

Compares Mahalanobis distances from two approaches
missPatterns

missing or zero pattern structure.
constSum

Constant sum
cubeCoord

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

gmean
daCoDa

Linear and quadratic discriminant analysis for compositional data.
indTab

Independence table
gmean_sum

Geometric mean
ind2x2

Independence 2x2 compositional table
rdcm

relative difference between covariance matrices
orthbasis

Orthonormal basis
employment

employment in different countries by gender and status.
outCoDa

Outlier detection for compositional data
isic32

ISIC codes by name
ilr.2x2

ilr coordinates in 2x2 compositional tables
robCompositions-package

Robust Estimation for Compositional Data.
impAll

Replacement of rounded zeros and missing values.
govexp

government spending
laborForce

labour force by status in employment
plot.imp

Plot method for objects of class imp
plot.pcaCoDa

Plot method
impCoda

Imputation of missing values in compositional data
intArray

Interaction array
imputeBDLs

EM-based replacement of rounded zeros in compositional data
imputeUDLs

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

haplogroups data.
impRZalr

alr EM-based imputation of rounded zeros
impKNNa

Imputation of missing values in compositional data using knn methods
precipitation

24-hour precipitation
print.imp

Print method for objects of class imp
intTab

Interaction table
lifeExpGdp

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

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

EM-based replacement of rounded zeros in compositional data
lmCoDaX

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

Classical estimates for tables
ternaryDiagEllipse

Adds tolerance ellipses to a ternary diagram.
teachingStuff

teaching stuff
pTab

Propability table
payments

special payments
production

production splitted by nationality on enterprise level
rSDev

Relative simplicial deviance
summary.imp

Summary method for objects of class imp
mortality

mortality and life expectancy in the EU
mortality_tab

mortality table
ternaryDiagPoints

Add points or lines to a given ternary diagram.
nutrients

nutrient contents
unemployed

unemployed of young people
nutrients_branded

nutrient contents (branded)
zeroOut

Detection of outliers of zero-inflated data
rSDev.test

Relative simplicial deviance tests
rcodes

codes for UNIDO tables
variation

Robust and classical variation matrix
pfa

Factor analysis for compositional data
phd

PhD students in the EU
skyeLavas

aphyric skye lavas data
socExp

social expenditures
trondelagC

regional geochemical survey of soil C in Norway
trondelagO

regional geochemical survey of soil O in Norway
ternaryDiag

Ternary diagram
ternaryDiagAbline

Adds a line to a ternary diagram.
SDev

Simplicial deviance
GDPsatis

GDP satisfaction
addLRinv

Inverse additive logratio mapping
adjust

Adjusting for original scale
ageCatWorld

child, middle and eldery population
alcohol

alcohol consumptions by country and type of alcohol
adtest

Anderson-Darling Normality Tests
aDist

Aitchison distance
addLR

Additive logratio coordinates