# Re: [R] mixtures as outcome variables

From: Kjetil Brinchmann Halvorsen <kjetil_at_acelerate.com>
Date: Fri 25 Mar 2005 - 11:28:51 EST

Kjetil Brinchmann Halvorsen wrote:

> Jason W. Martinez wrote:
>
>> Dear R-users,
>>
>> I have an outcome variable and I'm unsure about how to treat it. Any
>>
> If you only concentrate on the relative proportions, this are called
> compositional data. I f your data are in
> mydata (n x 4), you obtain compositions by
> sweep(mydata, 1, apply(mydata, 1, sum), "/")
>
> There are not (AFAIK) specific functions/packages for R for
> compositional data AFAIK, but you
> can try googling. Aitchison has a monography (Chapman & Hall) and a
>
> One way to start might be lm's or anova on the symmetric logratio
> transform of the
> compositons. The R function lm can take a multivariate response, but
> some extra programming will be needed
> for interpretation. With simulated data:
>
> > slr
> function(y) { # y should sum to 1
> v <- log(y)
> return( v - mean(v) ) }
> > testdata <- matrix( rgamma(120, 2,3), 30, 4)
> > str(testdata)
> num [1:30, 1:4] 0.200 0.414 0.311 2.145 0.233 ...
> > comp <- sweep(testdata, 1, apply(testdata,1,sum), "/")
> # To get the symmetric logratio transform:
> comp <- t(apply(comp, 1, slr))
> # Observe:
> apply(cov(comp), 1, sum)
> [1] -5.551115e-17 2.775558e-17 5.551115e-17 -2.775558e-17
> > lm( comp ~ 1)
>
> Call:
> lm(formula = comp ~ 1)
>
> Coefficients:
> [,1] [,2] [,3] [,4] (Intercept)
> 0.17606 0.06165 -0.03783 -0.19988

Followup:

> mmod <- manova(comp ~ x)
> summary(mmod)
Error in summary.manova(mmod) : residuals have rank 3 < 4  >

So the manova() function cannot be used. I guess MANOVA for compositional data should be
a straight extension, but it must be programmed , standard manova cannot be used.

Kjetil

```--

Kjetil Halvorsen.

Peace is the most effective weapon of mass construction.
--  Mahdi Elmandjra

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help