Skip to content

mixed models with two random variables?

4 messages · Malcolm Fairbrother, barbara costa

#
Hi Barbara,

The lme4 package may be a bit easier for you to use, and is more current than nlme in various ways (though nlme does do a few things lme4 can't do). I think the problem is the right hand side of the random part of your model: I don't believe you can have a "+" there, as you have in your first two models. Your third model definitely doesn't make sense, because you're treating fReserve as both a covariate and a random classification.

It's a bit hard to understand your query generally. Variables treated as fixed effects can be either categorical or continuous--not a problem. But I don't understand the random classification in your case, which is the part for which you probably want to calculate a variance term (and why you need a mixed model). A random classification is usually coded as 1 to 20, or A to Z, or something like that, whereas your Roughness and DivBoulders look like continuous variables.

However, if you are trying to model observations cross-classified in both Roughness and DivBoulders, and treating fReserve as the only covariate/predictor, then try lme4's lmer, along the lines of:

lmer(Biomass ~ fReserve + (1 | DivBoulders) + (1 | Roughness), myData)

Hope that helps. Follow up with further clarification if not.

Cheers,
Malcolm
1 day later