# [R-sig-ME] Special case for random effects models lmer or lme?

Douglas Bates bates at stat.wisc.edu
Wed Jun 11 17:34:22 CEST 2008

```On Wed, Jun 11, 2008 at 5:24 AM, Pavlou, Menelaos <Mpavlou at gum.ucl.ac.uk> wrote:
> Hi all,

> The problem I want to solve is as follows. Suppose that we have repeated
> measurements per cluster. Y is the outcome variable, x is a single binary
> covariate cluster constant, id represents each cluster  and we have an
> unbalanced design of the following form and arbitrary number of clusters

> Y         x     id
> Y_11     1      1
> Y_12     1      1
> Y_13     1      1
> Y_14     1      1
> Y_21     0      2
> Y_22     0      2
> Y_23     0      2
> Y_24     0      2
> Y_25     0      2
> Y_26     0      2
>  ....    ....    ....

> where Y_jj respresents the jth measurement I the ith cluster. The first
> impression is that a simple model of the form

> Yij=beta_0+ b_i +beta_1x_i +epsilon_ij,     bi~N(0,sigmab^2)
> would suffice.

> However a special feature of the data renders this model inappropriate:
> There seems to be a connection between  the cluster size and the outcome Y
> which is not capture fully by the model above. So what I want to do is to
> "pretend" that there are some "super clusters"  at the top level for some
> groups of cluster sizes. For example :

> cluster sizes (and clusters...)    "super cluster "
> 1-3                                                  1
> 4-6                                                  2
> 7-10                                                3

> What I want to do is to fit a model with different random effects for each
> super cluster (denoted by the indicator k, so the measurements would now be
> of the form Y_ijk)

Your description seems different from the formula below.  Do you mean
"different random effects" or "different variances of the random
effects" for each super cluster? In the first case you can use nested
random effects, one level of random effects for cluster and one level
for super cluster.  In the second case I think you would need to fit
the model with lme to get the different variances.

> The model I imagine would then be of the form

> Yijk=beta_0+ b_ik +beta_1x_i +epsilon_ijk,     bik~N(0,sigmab_k^2)

> So for each super cluster include a different random effect that *could*
> capture  the association above.

> I haven't managed to fit such a model in R using lmer or lme, nor to find a
> similar case in the help archives so I would be grateful if anybody could
> help.

```