[R-sig-ME] question about linear mixed models

JOSE A ALEMAN aleman at fordham.edu
Thu Jul 8 17:53:37 CEST 2010


Dear Andrew, Douglas and Kevin,

Thank you for you quick and helpful responses. Andrew, this is what the
first six lines of the dataframe look like

    country    nation year gini_gross gini_net miwseppp miwsenc compens
1 Australia Australia 1960      39.19    28.48       NA      NA   10045
2 Australia Australia 1961      39.26    28.43       NA      NA   10378
3 Australia Australia 1962      39.22    28.64       NA      NA   11148
4 Australia Australia 1963      39.03    28.29       NA      NA   12026
5 Australia Australia 1964      38.83    28.20     3405    2622   13145
6 Australia Australia 1965      38.45    27.71     3655    2814   14397

There are 18 countries (or nations) and 40 years (1960 to 2000). It seems a
little bit strange that the variance for year is 0.

Jose



                                                                           
             Andrew Dolman                                                 
             <andydolman at gmail                                             
             .com>                                                      To 
                                       JOSE A ALEMAN <aleman at fordham.edu>  
             07/08/2010 03:56                                           cc 
             AM                        r-sig-mixed-models at r-project.org    
                                                                   Subject 
                                       Re: [R-sig-ME] question about       
                                       linear mixed models                 
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Hello Jose,

lme4 can handle crossed and nested random effects whereas nlme can
only do nested random effects.

What you've specified here:

> mixed.model <- lmer (y ~ x1+x2+x3 + (1 | nation) + (1 | year), data=data)

has crossed random effects.

> and R returns the following output for the random effects:
>
> Random effects:
>  Groups   Name          Variance   Std.Dev.
>  year          (Intercept)   0.00            0.00
>  nation      (Intercept)   9.40            3.07
>  Residual                      2.42             1.56

and you seem to have zero variance associated with the random effect
"year". This may be a problem with the way you've coded your data
which is why it's helpful if you post a sample of your data, or dummy
data, with your question.

do > head(mydataframe)
the output from str (mydataframe) is useful too because we can see how
many levels of each factor you have


If you want a nested model in lme4 you should specify it as  + (1 |
nation/year) OR +(1|nation) + (1|nation:year)


I'm not sure what the model is that you specified in nlme but it can't
be the same as the one for lme4 because nlme cannot do crossed random
effects

> mixed.effects <- lme (y ~ x1+x2+x3, data=data,
>      random=~1|nation+1|year, method="REML")


Andy.




More information about the R-sig-mixed-models mailing list