gsiPrinBal: The canonical basis in the clr plane used for ilr and ipt...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Compute the basis of a clr-plane, to use with isometric log-ratio or planar transform of a (dataset of) compositions.

Usage

1
2
          gsi.PrinBal( x, method="PBhclust" )
          

Arguments

x

a data set (required)

method

method to build the principal balances; currently, one of "PBhclust", "PBmaxvar" or "PBangprox"

Details

Method "PBhclust" generates a Ward cluster analysis of the parts (not of the observations!) using as distance between parts the variation matrix.

Method "PBmaxvar" splits all parts in two groups after a PCA (those with positive weight against those with negative weight in the first PC), and then checks for each element whether moving it increases the variance of the resulting balance. The largest variance balance is chosen. That variance is removed, and each of the groups of parts is analysed recursively.

Method "angprox" calculates all possible balances (exhaustive combinations of "ncol(x)" elements split in three groups: +1, 0 and -1), and computes their angles with the first PC. The nearest balance is chosen. Its variance is substracted, and the algorithm is repeated recursively ensuring orthogonality of the next splittings with respect to the balances already chosen. This method creates a temporary file ".APtable" that can be removed after execution (or copypasted in your logfiles).

Note that more methods can appear in the future, and that, except "PBhclust", all methods can be VERY slow. Extensive reprogramming of these routines can be expected in the future.

Value

All methods give a matrix containing by columns the basis elements for the canonical basis of the clr-plane used for the ilr and ipt transform. Principal Balances are balance bases approximating Principal Component in certain ways, depending on the specific method chosen.

Author(s)

J.J. Egozcue (programming "PBmaxvar") and R. Tolosana-Delgado (programming other methods and wrapper)

References

Pawlowsky-Glahn, V., J.J. Egozcue and R. Tolosana-Delgado (2011) Principal Balances. In: Egozcue, J.J., R. Tolosana-Delgado and M.I. Ortego (eds) Proceedings of CoDaWork'2011, the 4th International Workshop on Compositional Data Analysis. CIMNE, Barcelona (E)

http://congress.cimne.com/codawork11/frontal/ProgIntro.asp

See Also

ilrBase,ilr,clr

Examples

1
2
3
4
5
data("Hydrochem")
x = acomp(Hydrochem[,c(6:10)])
(v1 = gsi.PrinBal(x, "PBhclust"))
(v2 = gsi.PrinBal(x, "PBmaxvar"))
(v3 = gsi.PrinBal(x, "PBangprox"))

Example output

Loading required package: tensorA

Attaching package: 'tensorA'

The following object is masked from 'package:base':

    norm

Loading required package: robustbase
Loading required package: energy
Loading required package: bayesm
Welcome to compositions, a package for compositional data analysis.
Find an intro with "? compositions"


Attaching package: 'compositions'

The following objects are masked from 'package:stats':

    cor, cov, dist, var

The following objects are masked from 'package:base':

    %*%, scale, scale.default

Warning message:
In structure(c(), class = c(class(x), class(y))) :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
  Consider 'structure(list(), *)' instead.
The "ward" method has been renamed to "ward.D"; note new "ward.D2"
           [,1]       [,2]       [,3]       [,4]
[1,]  0.0000000  0.0000000 -0.8164966  0.3651484
[2,]  0.0000000 -0.7071068  0.0000000 -0.5477226
[3,]  0.0000000  0.7071068  0.0000000 -0.5477226
[4,] -0.7071068  0.0000000  0.4082483  0.3651484
[5,]  0.7071068  0.0000000  0.4082483  0.3651484
Warning messages:
1: In structure(c(), class = c(class(x), class(y))) :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
  Consider 'structure(list(), *)' instead.
2: In structure(c(), class = c(class(x), class(y))) :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
  Consider 'structure(list(), *)' instead.
3: In structure(c(), class = c(class(x), class(y))) :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
  Consider 'structure(list(), *)' instead.
4: In structure(c(), class = c(class(x), class(y))) :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
  Consider 'structure(list(), *)' instead.
5: In structure(c(), class = c(class(x), class(y))) :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
  Consider 'structure(list(), *)' instead.
6: In structure(c(), class = c(class(x), class(y))) :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
  Consider 'structure(list(), *)' instead.
7: In structure(c(), class = c(class(x), class(y))) :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
  Consider 'structure(list(), *)' instead.
8: In structure(c(), class = c(class(x), class(y))) :
  Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
  Consider 'structure(list(), *)' instead.
[1] "gsi.PrinBal: starting computations of slow methods"
[1] "order partition"
[1] 1
[1] "variance comparison"
[1] 0.002890197
[1] 0.002890197 0.045132900 0.002525831 0.001454577 0.040664555
[1] "variance comparison"
[1] 0.0451329
[1] 0.030088600 0.002890197 0.022100889 0.036187625 0.000000000
[1] "order partition"
[1] 2
[1] "variance comparison"
[1] 0.02466114
[1] 0.00897336 0.00000000 0.01420149 0.00510670 0.00000000
[1] "order partition"
[1] 3
[1] "variance comparison"
[1] 0.002747665
[1] 0.0021049124 0.0000000000 0.0005780394 0.0000000000 0.0000000000
[1] "order partition"
[1] 4
[1] "variance comparison"
[1] 0.0008727463
[1] 0 0 0 0 0
         [,1]       [,2]       [,3]       [,4]
H   0.2236068  0.2886751  0.4082483  0.7071068
Na  0.2236068 -0.8660254  0.0000000  0.0000000
K   0.2236068  0.2886751  0.4082483 -0.7071068
Mg  0.2236068  0.2886751 -0.8164966  0.0000000
Ca -0.8944272  0.0000000  0.0000000  0.0000000
There were 37 warnings (use warnings() to see them)
[1] "gsi.PrinBal: starting computations of slow methods"
         [,1]       [,2]       [,3]       [,4]
H   0.2236068  0.2886751 -0.4082483  0.7071068
Na  0.2236068  0.2886751 -0.4082483 -0.7071068
K  -0.8944272  0.0000000  0.0000000  0.0000000
Mg  0.2236068 -0.8660254  0.0000000  0.0000000
Ca  0.2236068  0.2886751  0.8164966  0.0000000
There were 16 warnings (use warnings() to see them)

compositions documentation built on May 30, 2017, 3:25 a.m.