# [R] Manova question.

Jens Schumacher jschum at bgc-jena.mpg.de
Tue Jun 15 17:52:15 CEST 2004

```knussear wrote:

> Hi list,
>
> I'm attempting to re-create a Repeated Measures Compositional Analysis as
>  described in the work by Aebischer et. al. (Ecology. 1993. 74(5):
> 1313-1325).
>
> In this paper they describe transitions of data into a log ratio
> difference matrix, from which they obtain two matrices using a monova
> routine.
>
> I am able to produce the second of the two matrices, but I'm having
> trouble with the first.
>
> the difference matrix going in is given here.
>
> Animal    Scrub    Bl wood    Con wood     Grass
> 1    0.970    -2.380    -5.154    -9.408
> 2    1.217    -0.173    -4.955    -5.521
> 3    1.178    -0.248    -4.089    0.338
> 4    0.520    0.466    -4.801    -1.946
> 5    8.445    9.319    10.753    8.171
> 6    8.654    9.327    10.732    8.152
> 7    8.429    9.350    10.818    8.141
> 8    9.120    9.565    3.813    8.127
> 9    9.227    9.882    3.813    7.779
> 10    9.423    8.086    3.813    8.539
> 11    9.626    9.392    3.813    8.135
> 12    9.234    8.302    3.813    8.537
> 13    8.672    8.908    9.832    8.416
>
>
> And the first of the matrices is given here, and is "matrix of
> mean-corrected sums of squares and cross products calculated from the
> difference matrix."
>
>
>     Scrub    Bl wood    Con wood     Grass
> Scrub    179.52    214.59    244.58    273.75
> Bl wood    214.59    268.44    314.35    343.86
> Con wood     244.58    314.35    471.09    400.22
> Grass    273.75    343.86    400.22    477.78
>
>
> From manova on the data set I can get the diagonal of the matrix, but
> not the others.
>
> manova(y ~ NULL)
>
> Terms:
>                 Residuals
> Scrub            179.5273
> Bl.wood          268.4347
> Con.wood         471.0845
> Grass            477.8014
> Deg. of Freedom        12
>
>
> Could anyone offer a suggestion ?
>
> Thanks
>
>
> Ken
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
>
>
Let   data.matrix    be the above difference matrix. You obtain the "raw
sums of squares and cross-products matrix" by

R2 <- t(data.matrix) %*% data.matrix

or even
R2 <- crossprod(data.matrix, data.matrix)

To obtain the the second matrix you have to repeat the same thing with
matrix of mean-corrected values.

data.centered <- data.matrix - matrix(colMeans(data.matrix),
ncol=ncol(data.matrix),nrow=nrow(data.matrix), byrow=T)

R1 <- t(data.centered) %*% data.centered

HTH

Jens Schumacher

```