[R] lme4 / HLM question

Ben Bolker bbolker at gmail.com
Sun Aug 5 01:34:43 CEST 2012


Jeff <r <at> jp.pair.com> writes:

>  I'm hoping that this is a relatively easy question for someone
>  familiar with the lme4 package.  I'm accustomed to using HLM
>  software and writing a simple 2 level [null] equation like this:

>    L1 - Yij = b0 +  e
>    L2 - b0 = B00 + u0

>    The following command in R provides results that are identical to
>    the HLM program.

>    results <- lmer( Y ~ 1 |id , PanelData4)

>    I can't seem to find any examples on-line nor in the help about
>    how to write the lmer4 formula that contains two predictor
>    variables at level 1 with fixed slopes.

>    L1 - Yij = b0 + b1(x) + b2(z) + e
>    L2 - b0 = B00 + u0
>           b1 =  B10
>            b2 = B20

  In general you'd probably be better off asking this question
at r-sig-mixed-models at r-project.org ... but it's very easy to
put fixed effects into a model --

  lmer (Y ~ x + z + (1|id), PanelData4)

 or in lme (nlme package):

  lme ( Y~ x + z, random = ~ 1|id, PanelData4)

  Neither lmer nor lme need to be told explicitly which level
the fixed effects vary at (the data are always provided in 
long form).

    Ben Bolker



More information about the R-help mailing list