balance {compositions} | R Documentation |
Compute balances for a compositional dataset.
Description
Compute balances in a compositional dataset.
Usage
balance(X,...)
## S3 method for class 'acomp'
balance(X,expr,...)
## S3 method for class 'rcomp'
balance(X,expr,...)
## S3 method for class 'aplus'
balance(X,expr,...)
## S3 method for class 'rplus'
balance(X,expr,...)
balance01(X,...)
## S3 method for class 'acomp'
balance01(X,expr,...)
## S3 method for class 'rcomp'
balance01(X,expr,...)
balanceBase(X,...)
## S3 method for class 'acomp'
balanceBase(X,expr,...)
## S3 method for class 'rcomp'
balanceBase(X,expr,...)
## S3 method for class 'acomp'
balanceBase(X,expr,...)
## S3 method for class 'rcomp'
balanceBase(X,expr,...)
Arguments
X |
compositional dataset (or optionally just its column names for balanceBase) |
expr |
a |
... |
for future perposes |
Details
For acomp
-compositions balances are defined as orthogonal
projections representing the log ratio of the geometric means of
subsets of elements. Based on a recursive subdivision (provided by the
expr=
) this projections provide a (complete or incomplete) basis of
the clr-plane. The basis is given by the balanceBase
functions. The transform is given by the balance
functions. The
balance01
functions are a backtransform of the balances to the
amount of the first portion if this was the only balance in a 2
element composition, providing an "interpretation" for the values of
the balances.
The package tries to give similar concepts for the other scales.
For rcomp
objects the concept is mainly unchanges but augmented
by a virtual component 1, which always has portion 1.
For
rcomp
objects, we choose not a "orthogonal" transformation
since such a concept anyway does not really exist in the given space,
but merily use the difference of one subset to the other. The
balance01 is than not really a transform of the balance but simply the
portion of the first group of parts in all contrasted parts.
For rplus
objects we just used an analog to generalisation from
the rcomp
defintion as aplus
is generalized from
acomp
. However at this time we have no idea wether this has any
usefull interpretation.
Value
balance |
a matrix (or vector) with the corresponding balances of the dataset. |
balance01 |
a matrix (or vector) with the corresponding balances in the dataset transformed in the given geometry to a value between 0 and 1. |
balanceBase |
a matrix (or vector) with column vectors giving the transform in the cdt-transform used to achiev the correponding balances. |
References
https://ima.udg.edu/Activitats/CoDaWork08/ Papers of Boogaart and Tolosana https://ima.udg.edu/Activitats/CoDaWork05/ Paper of Egozcue
See Also
Examples
X <- rnorm(100)
Y <- rnorm.acomp(100,acomp(c(A=1,B=1,C=1)),0.1*diag(3))+acomp(t(outer(c(0.2,0.3,0.4),X,"^")))
colnames(Y) <- c("A","B","C")
subComps <- function(X,...,all=list(...)) {
X <- oneOrDataset(X)
nams <- sapply(all,function(x) paste(x[[2]],x[[3]],sep=","))
val <- sapply(all,function(x){
a = X[,match(as.character(x[[2]]),colnames(X)) ]
b = X[,match(as.character(x[[2]]),colnames(X)) ]
c = X[,match(as.character(x[[3]]),colnames(X)) ]
return(a/(b+c))
})
colnames(val)<-nams
val
}
pairs(cbind(ilr(Y),X),panel=function(x,y,...) {points(x,y,...);abline(lm(y~x))})
pairs(cbind(balance(Y,~A/B/C),X),panel=function(x,y,...) {points(x,y,...);abline(lm(y~x))})
pairwisePlot(balance(Y,~A/B/C),X)
pairwisePlot(X,balance(Y,~A/B/C),panel=function(x,y,...) {plot(x,y,...);abline(lm(y~x))})
pairwisePlot(X,balance01(Y,~A/B/C))
pairwisePlot(X,subComps(Y,A~B,A~C,B~C))
balance(rcomp(Y),~A/B/C)
balance(aplus(Y),~A/B/C)
balance(rplus(Y),~A/B/C)