# [R-sig-ME] how to estimate R- and G-side random effects of GLMM in R

Douglas Bates bates at stat.wisc.edu
Mon Sep 17 14:57:05 CEST 2007

```On 9/16/07, ts p <pts007 at hotmail.com> wrote:
> Hello, everyone,
>
> I am not very familiar to use R.
> I used SAS Proc GLIMMIX to estimate R- and G-side random effects of
> generalized linear mixed models. But the procedure can just use PQL or MQL.
> Now I want to lmer function in R to estimate GLMM because it can use Laplace
> approximation. It is more precise than PQL or MQL. But I read the manual of
> lmer. I did not find the information how to write a covariance structure in
> the function and how the function can know the struction is for R- or G-side
> random effects.
>
> For example, if I use the following SAS proc GLIMMIX code to estimate a
> model, I wonder who can tell me how to use lmer to write R code to estimate
> the same model.
>
> proc glimmix ;
>     class person group item;
>     model score(event='1')=item group /noint dist=binary link=logit s;
>     random _residual_ / sub=person type=cs ;
> run;

I am not fluent in SAS but I believe the model that you want to fit would be

lmer(score ~ item + group + (1|person), <dataSetName>, family = binomial)

assuming that score, item, person and group are stored as factors and
that score has only two levels.  If not you should dichotomize score
before fitting the model.

Others may be better able to decide what model the SAS code would fit.
I have difficulty with this because, for example, I can't see what
the compound symmetry structure is supposed to mean.  There certainly
isn't a compound symmetry structure on either the marginal or the
conditional distribution of the response given the random effects,
because the variance of a binomial depends on the mean.  Specifying an
R matrix independently of the linear predictor doesn't make sense to
me.

```