# How to perform a MANOVA with a random effect in R?

I performed an experiment where I raised different families coming from two different source populations, where each family was split up into a different treatments. After the experiment I measured several traits on each individual. Now I would like to have an overall and hence multivariate statistic that tests for an effect of either treatment or source as well as their interaction but correcting for family effects.

So, basically I would like to perform a MANOVA with a random effect, which would translate to something like this:

 manova(data~source*treatment+Error(family))


However, the standard R MANOVA function does not support random effects and I was unable to find another function that would do the trick. So I would like to ask if anyone has a suggestion that may help.

Thanks!

• I think you want either the lme4 or the nlme package – Peter Flom Mar 17 '13 at 11:42
• I use both packages to analyze especially univariate contrasts. How would you implement then a multivariate scenario? – KL_STKBK Mar 18 '13 at 16:34
• I am not expert in either of these... Others here may know. – Peter Flom Mar 18 '13 at 17:28
• – Ben Bolker Oct 18 '14 at 22:27

Chapter 16 of Snijders and Bosker 2012 solve the problem by creating a dummy variable to represent the different response variables ($Y$), stacking the data (see quote below), and adding an additional level to your model to represent different response variables within subject.
From page 284 of Snijders and Bosker 2012: "To represent the multivariate data in the multilevel approach, three nesting levels are used. The first level is that of the dependent variables indexed by $h = 1,\ldots,m$, the second level is that of the individuals $i = 1,\ldots,n_j$, and the third level is that of the groups, $j = 1,\ldots,N$. So each measurement of a dependent variable on some individual is represented by a separate line in the data matrix, containing the values $i$, $j$, $j$, $Y_{hij}$, $x_{1ij}$, and those of the other explanatory variables. The multivariate model is formulated as hierarchical linear model using the same trick as in Section 15.1.3. Dummy variables $d_1,\ldots,d_m$ are used to indicate the dependent variables, just as in formula (14.2). Dummy variable $d_h$ is $1$ or $0$, depending on whether the data line refers to dependent variable $Y_j$ or to one of the other dependent variables."