s-news
[Top] [All Lists]

Basic Compositional Data Analysis functions for S+/R

To: s-news@lists.biostat.wustl.edu
Subject: Basic Compositional Data Analysis functions for S+/R
From: Joel_Reynolds@fws.gov
Date: Tue, 30 Dec 2003 16:28:51 -0900
Happy Holidays.

Many years ago Dean Billheimer was kind enough to send me his S-Plus code
for creating ternary plots and some other topics related to compositional
data analysis.  I've since amended and, in some cases, further documented
these functions.  Prof. Aitchison's Compositional Data Analysis shortcourse
a 1.5 years ago motivated me to finish cleaning up my versions of that code
and create new S-Plus/R code for the basic log-ratio transformations, etc.

A recent conversation with a colleague reminded me that I never distributed
any of this; here it is.

The attached zip file contains function scripts, help files, a sample data
set, and some example test scripts.  The file
CompositionFunctionIndexDec03.txt briefly describes each function and which
script file it resides in.

Please send any corrections/bugs/suggestions to me.  I hope to expand the
collection as I encounter relevant projects/needs.

### A variety of S-Plus/R functions for basic compositional data analysis.
################################
# Authors: Joel H. Reynolds (Joel_Reynolds@fws.gov)
#       & Dean Billheimer (dean.billheimer@mcmail.vanderbilt.edu)
################################
# Last Edits - Fall 2002
################################

S+ Compositional Functions:

Name            Location
# Basic Operations:
Closure.f
        project compositional data to appropriately dimensioned
        simplex.
        BasicSummaries.ssc
CompositionAddition.f
        'Add' two compositions; two vectors, two matrices, or
        a matrix and a vector. Positive component values only.
        BasicSummaries.ssc
CompositionDifference.f
        'Subtract' two compositions; two vectors, two matrices,
        or a matrix and a vector.  Positive component values only.
        BasicSummaries.ssc
CompositionDistance.f
        Calculate Aitchison's Simplex Metric, which actually is
        calculated on the centered log-ratio transformed compositions.
        It does, however, satisfy all the properties of a metric.
        Positive component values only.
        BasicSummaries.ssc

# Transformations:
AdditiveLogRatio.f
        Apply Aitchison's additive log-ratio transformation to
        a vector or matrix of composition observations.
        BasicSummaries.ssc
InvAdditiveLogRatio.f
        Apply the inverse of Aitchison's additive log-ratio
        transformation to a vector or matrix of multivariate observations.
        BasicSummaries.ssc
CenteredLogRatio.f
        Apply Aitchison's centered log-ratio transformation to
        a vector or matrix of composition observations.
        Positive component values only.
        BasicSummaries.ssc
InvCenteredLogRatio.f
        Apply the inverse of Aitchison's centered log-ratio
        transformation to a vector or matrix of multivariate observations.
        BasicSummaries.ssc
DoublyCenterLogRatio.f
        Internally called function to apply the centered
        log-ratio transformation to a matrix of composition observations,
        then sweep out the column means so it is doubly centered.
        Positive component values only.
        BasicSummaries.ssc

# Estimators:
CompositionCenter.f
        Calculate the 'center' of a matrix of composition observations;
        that is, the simplex projection of the column-wise geometric means.
        Positive component values only.
        BasicSummaries.ssc
CenteredLogRatioCovariance.f
        Calculate the var-covariance matrix of the centered
        log-ratio transformations of a matrix of composition observations.
        Positive component values only.
        BasicSummaries.ssc

Plots:
CompositionBiplot.f
        Takes a matrix of composition observations, applies the Doubly
Centered
        Log-Ratio transformation, calculates the svd of the resulting
matrix, then
        creates a biplot showing the component dependence relations and the
case
        scores.  The relevant svd results are also returned as a result.
        Positive component values only.
        BasicSummaries.ssc
triplot.f
        create ternary diagram of 3-part compositional data
        DeansFuncs.ssc
tripoints.f
        add points to a ternary diagram
        DeansFuncs.ssc
triplotvector.f
        creates a ternary plot with a line segment connecting
        two 3-part compositions on a ternary plot.
        DeansFuncs.ssc
triproj.f
        calculates the projection of 3-part composition data
        to the 2-dimensional ternary graph.
        DeansFuncs.ssc
tricontour.f
        calculate contours of an independent variable and add
        them to a ternary plot.
        DeansFuncs.ssc
tetraprojection.fcn
        Creates an exploded view (2-d) graph of a four dimensional
        composition tetrahedron - basically displaying all four
        three-component ternary plots.
        tetraprojplot.ssc
tetraprojectionline.fcn
        Adds marginal lines connecting two four-component compositions
        on the four three-component ternary plots after a call to
        tetraprojection.fcn().
        tetraprojlineplot.ssc
webplot.f
        radar or spider graphs of compositional data
        DeansFuncs.ssc
weblines.f
        add lines to a webplot
        DeansFuncs.ssc

rmultnom.f
        generate random samples from a multinomial distribution.
        DeansFuncs.ssc
tricontour.f
        calculate contours of an independent variable and add
        them to a ternary plot.
        DeansFuncs.ssc



Example & checking files
BasicSummaryChecks.ssc

(See attached file: CompFunctionsDec03.zip)


Cheers,
Joel



Joel H. Reynolds, Biometrician

Division of Natural Resources
US Fish & Wildlife Service
1011 E. Tudor Rd., mailstop 221
Anchorage, AK 99503
Voice: (907) 786-3914
FAX: (907) 786-3905

Attachment: CompFunctionsDec03.zip
Description: Zip archive

<Prev in Thread] Current Thread [Next in Thread>
  • Basic Compositional Data Analysis functions for S+/R, Joel_Reynolds <=