[R] lmer with nested/nonnested groupings?

Spencer Graves spencer.graves at pdf.com
Mon Jan 16 00:01:43 CET 2006


	RSiteSearch("lmer nested") produced 85 hits, the first of which looks 
to me like it would answer your question 
(http://finzi.psych.upenn.edu/R/Rhelp02a/archive/61571.html):  Have you 
tried replacing "state" with "region:state" something like the following:

 > lmer (y ~ black*female + (1 | region:state) + (1 | region) + (1 | 
age) + (1 | edu) + (1 | age.edu), family=binomial(link="logit"))

	  But please read the earlier post, as makes cites other documents, 
e.g., the "MlmSoftRev" vignette, and contains useful comments from Doug 
Bates, among others.

	  hope this helps.
	  spencer graves

Andrew Gelman wrote:

> I'm trying to figure out how to use lmer to fit models with factors that 
> have some nesting and some non-nested groupings.  For example, in this 
> paper:
> http://www.stat.columbia.edu/~gelman/research/published/parkgelmanbafumi.pdf
> we have a logistic regression of survey respondents' political 
> preferences (1=Republican, 0=Democrat), regressing on sex, ethnicity, 
> state (51 states within 5 regions), 4 age categories, and 4 education 
> categories.  I'd like to include states (nested within regions), and 
> also age, education, and age x education.  (That is, 5 batches of 
> varying coefs:  50 states, 5 regions, 4 age categories, 4 education 
> categories, and 16 age x education categories.)  The age x education 
> factor is kinda tricky because it's connected both to age and to education.
> 
> I'm thinking of a model like this:
> 
> lmer (y ~ black*female + (1 | state) + (1 | region) + (1 | age) + (1 | 
> edu) + (1 | age.edu), family=binomial(link="logit"))
> 
> (Here, I'm thinking of age.edu as a variable with 16 levels.)
> 
> Anyway, it blows up when i try to put in these nested things.  I read 
> Doug Bates's article in R-news and there seems to be a  way of doing 
> nested groupings (unfortunately, I can't quite figure out how to do it), 
> but I don't see any references to situations such as age, edu, and age*edu .
> 
> For the article, we used Bugs, which is fine, but I'd like to see how 
> far I can take it using lmer.  I could kludge it by, for example, 
> including age, edu, and region as unmodeled factors:
> 
> lmer (y ~ black*female + (1 | state) + factor(region) + factor(age) + 
> factor(edu) + (1 | age.edu), family=binomial(link="logit"))
> 
> but I'd like to do the full multilevel version.
> 
> Thanks!
> Andrew
>




More information about the R-help mailing list