How to nest hierarchical data variances in R

Apologies ahead of time for not having an exact data set as this is more of theoretical question that I stumbled across while working on mixed effects models.

Suppose I have the following data structure: location/person/experiment.

Thus within each location, I have several people and within each person I have several experiments.

I can model this in R using something like:

lme(outcome ~1, random= 1| location/person/experiment).


In the output, we know that $location \sim N(0, \sigma^2_{loc})$, $person \sim N(0, \sigma^2_{per})$ and $experiment \sim N(0, \sigma^2_{exp})$.

The reason typically given for all of the distributions being centered at 0, is because the mean is rolled into the estimate of the variable above. So for instance, the mean of the experiments for a given person X, is the estimate of random effect for person X.

Further, all the variances are independent from each other. What this means is that the variance for a person at location x is independent of another person at location x as well as that of a third person in location y.

Question What if the variances were different by location?

For example, suppose that the variance of a person at location A is higher than the variance of a person at location B? Thus I want $person \sim N(0, \sigma^2_{per|location})$.

How would I model that?

Also, would it ever make sense to not model the means as 0 (with the mean rolled up as the parameter estimate of the variable higher up)? Looking at the math, I don't think so but perhaps I'm missing something?

• Look at the documentation for the weights argument of lme, which allows a call to a varFunc object and, in particular, varIdent which allows a different variance for each level of a factor. By the way, your lme call shows the random argument but you also need a fixed argument. – rvl Aug 17 '14 at 1:34