Dear R-users, I’ve been looking at the lmer function (lme4 package) in order to set up a mixed linear model and something about the syntax of the random effects eludes me. I’d like a hand with understanding a specific point, if someone does master this function… Let’s say that I have 2 random effects, A (e.g. species, k=2) and B (e.g. individuals, n=100). I made some research about model syntax, and I have the understanding that everything at the left side of the random “parameter” is about SLOPE and everything at the right side about intercept : … + (1 |B) would give me an intercept per individual. … + (1 |A) would give me an intercept per species. … + (1 |A:B) would give me an intercept per individuals with nested effect (individual inside species). I would like to have random slopes per species. So I thought I could do something like that : … + (A |B) so to have an intercept per individual and a slope value per species. Graphically, I would therefore obtain 100 lines with 100 different intercepts and 2 possible slopes (1 per species). However, when I extract random parameter values (ranef()), I have : · First column is the intercept : varying values per line (individuals), so OK · 2nd and 3rd column are Species 1 and 2: I have different across individuals (without obvious pattern: I do not have similar values for individual of the same species), which is not what I was expecting (1 value per species : the slope parameter). Is the mistake I’m doing (or in my understanding of lme4) obvious to somebody? With regards [[alternative HTML version deleted]]
Robert U <tacsunday <at> yahoo.fr> writes:> > Dear > R-users, >[snip] This question probably belongs on r-sig-mixed-models at r-project.org . Followups there, please.> Let's say that I have 2 random effects, A (e.g. species, k=2) and B(e.g. individuals, n=100). I made some research about model syntax, and I have the understanding that everything at the left side of the random ?parameter? is about SLOPE and everything at the right side about intercept : You really can't practically fit a random effect to 2 species (see http://glmm.wikidot.com/faq#fixed_vs_random> + (1 |B) > would give me an intercept per individual.> + (1 |A) > would give me an intercept per species.yes> + (1 |A:B) > would give me an intercept per individuals with nested effect (individual > inside species)This would be the same as (1|B) if the individuals are uniquely identified. Otherwise you probably want (1|A/B) [except that you can't really fit a random effect for k=2, as discussed above]> I would like to have random slopes per species. So I thought I > could do something like that :Probably not feasible.> + (A |B) so to have an intercept per individual and a slope value > per species. Graphically, I would therefore obtain 100 lines with > 100 different intercepts and 2 possible slopes (1 per > species). However, when I extract random parameter values (ranef()), > I have :what variable is your slope with respect to? Suppose it's time. Then I would recommend ~ A*time + (1|A:B) which will fit a (FIXED effect) interaction between species and time (different slopes and intercepts for each species), and a random intercept per individual.