# [R-sig-ME] Difference lme4 and nlme

Douglas Bates bates at stat.wisc.edu
Wed Feb 23 15:08:11 CET 2011

```Notice that the first model has 27 levels for J and the second model
has 465 levels for PARTY %in% J.  That's the difference.

If you do indeed want to have PARTY nested within J then your call to
lmer should use the formula

REVENUES ~ INCUMBENCY + (1|PARTY) + (1|J:PARTY)

On Wed, Feb 23, 2011 at 6:27 AM, Daniel <dmsilv at gmail.com> wrote:
> Hello list,
>
> I'm just try to find out how can I produce the results using both packages.
> Perhaps I'm using different equation. Trailer model are consistent to Stata
> output using (tmixed REVENUES INCUMBENCY || J: || PARTY:)
>
> lme2 <- lmer(REVENUES~INCUMBENCY+(1|J)+(1|PARTY),data=data,na.action =
> "na.omit", REML=TRUE)
>
> Linear mixed model fit by REML
> Formula: REVENUES ~ INCUMBENCY + (1 | J) + (1 | PARTY)
>  Data: data
>  AIC   BIC logLik deviance REMLdev
> 78123 78153 -39057    78154   78113
> Random effects:
> Groups   Name        Variance   Std.Dev.
> J        (Intercept) 9.6263e+08  31026
> PARTY    (Intercept) 1.7502e+09  41836
> Residual             3.0534e+10 174741
> Number of obs: 2894, groups: J, 27; PARTY, 27
>
> Fixed effects:
>           Estimate Std. Error t value
> (Intercept)    34244      11657   2.938
> INCUMBENCY    211495       9536  22.178
>
> Correlation of Fixed Effects:
>          (Intr)
> INCUMBENCY -0.097
>
> lme3 <- lme(REVENUES~INCUMBENCY, random=~1 |J/PARTY,data=data,na.action =
> "na.omit", REML=TRUE)
>
> Linear mixed-effects model fit by REML
>  Data: data
>  Log-restricted-likelihood: -39078.07
>  Fixed: REVENUES ~ INCUMBENCY
> (Intercept)  INCUMBENCY
>   52469.19   220521.74
>
> Random effects:
>  Formula: ~1 | J
>        (Intercept)
> StdDev:    25424.31
>
>  Formula: ~1 | PARTY %in% J
>        (Intercept) Residual
> StdDev:     45574.5 173465.7
>
> Number of Observations: 2894
> Number of Groups:
>           J PARTY %in% J
>          27          465
>
> --
> Daniel Marcelino
> Skype: dmsilv