Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A researcher collected some data of a response/outcome variable Y from, for example, 20 subjects. In addition to an explanatory (within-subject or repeated-measures) variable A (a factor with two levels, A1 and A2), he would also want to consider another explanatory (and continuous) variable X. He's interested in finding out the effect of factor A on Y, and in the meantime would like to control for the variability in Y due to X. However, the subtle issue here is that X is correlated with Y to some extent, and, more importantly, the two levels (A1 and A2) may have different average value of X. The complication of the latter fact in modeling is that the effect of X on Y may partially or even fully explains the effect of A. I know this may be a controversial issue because X is correlated with the levels of A to some extent, but the investigator wants to account for the variability within each level of A. If I construct a model like

Y ~ X + A


Y ~ X*A

with lme4 of nlme package in R, I believe that the result of A effect from anova() should be interpreted with X taking the overall mean value, but that would not allow me to obtain the effect of A while 'controlling' for X (considering the fact that X has different mean value across the two levels of A; i.e., the average value of X at A1 is different from the average value of X at A2)! I've thought of scaling Y by X with a model like

Y/X ~ A

but I don't feel so comfortable with it. Any suggestions on modeling this situation? Is there such a thing as multivariate LME?

share|improve this question

I would suggest using random model in this case. In my opinion to allow for within and across subjects variability it is better to consider it as a hierarchical modelling. The first level allows for within subjects variation and the second level allows for across subjects variation.

To clarify, in the first level you try to find the average for within subject variation and assume and the second level will detect the relationship across subject taking the within variation into account. Such that:

  • level 1: (An average for A effect on x with within-x variation)

    xi|A ~ (x, var(within))
  • level 2: (The average effect of x on Y by taking within-subject variation into account)

    Y|x ~(Mean (x), var(across)+var(within))
share|improve this answer
thanks for the suggestion! I thought linear mixed-effects model and hierarchical model were the same thing. Not true for you? Could you elaborate it a little bit more about your approach? It would be more helpful if you could provide some functions in R. Thanks again... – bluepole Oct 29 '11 at 11:51
Hierarchical models are a subset of multi-level models. By definition a hierarchical model does not allow for crossed random-effects but only for fully nested ones. eg. your typical County>School>Student paradigm is fully nested. A school can only be in only one county and student at only a single school (in a fixed time-point that is). On the other hand a study where you examine the yield of corn varieties with respect to different fertilizers and soil quality is/can be crossed. You do not use specific fertilizers exclusively in fields of a certain soil type. – usεr11852 May 11 '13 at 0:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.