# RE: [R] doubly multivariate analysis in R

From: Doran, Harold <HDoran_at_air.org>
Date: Mon 05 Jul 2004 - 22:01:10 EST

If your subjects share similar settings (and therefore may not be ind.), you may consider performing this analysis in nlme. However, imagine for a moment that you allow for random intercepts and slopes for each individual. You would be required to fit a model with 8 fixed effects (a mean and slope for each response), an 8x8 covariance matrix along with 4 residual variances. Things are getting rather large.

A colleague and I have a paper currently under review for an educational audience showing how to fit a host of lme models, including a doubly-multivariate model. We show how to structure the data matrix, model a covariance structure, and estimate the individual variance terms. I would be happy to share the code we use and show the structure of the data matrix if you like. We devote a lot of space to this model, so answering your question here is difficult.

However, structuring the data matrix is rather simple, with a small trick. To estimate, one needs to stack the individual response variables into a single column with a dummy code used to flag the individual response variables. We then create a separate variable for time for each response variable to estimate the linear rate of change for each response individually (although this need not be the case). In the modeling function, you then need to remove the overall intercept from the model (-1) such that the main effect for each response are interpreted directly as subject-specific means, and then use a few small tricks to estimate to residual variances through use of the weights() function.

If interested, you might check out a paper we published in the R Newsletter in Dec. showing how to fit longitudinal models in lme with a single response variable and then go from there. Of course, Pinhiero and Bates is the authoritative source on models in lme and I would start there. The link below will take you to a software review page and has a small paper on R showing to fit a model with 2 response variable, but are not repeated measures.

Harold

```	-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch on behalf of Ludo Max
Sent: Sun 7/4/2004 4:06 PM
To: r-help@stat.math.ethz.ch
Cc:
Subject: [R] doubly multivariate analysis in R

20 subjects were measured in 5 conditions (thus repeated measures) and
for each subject in each condition there are 4 response measures (thus
multivariate as it is a combined score that needs to be compared across
the conditions).

So, using a multivariate approach to repeated measures this is a doubly
multivariate analysis.

I would appreciate any suggestions as to the best way to do such a
doubly multivariate analysis in R (I have done it in SPSS and SAS but
would like to see what it takes to do the same in R).

Thank you in advance for any help.

Ludo

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