[R] lmer with nested/nonnested groupings?

Andrew Gelman gelman at stat.columbia.edu
Sun Jan 8 19:19:30 CET 2006


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

-- 
Andrew Gelman
Professor, Department of Statistics
Professor, Department of Political Science
gelman at stat.columbia.edu
www.stat.columbia.edu/~gelman

Tues, Wed, Thurs:  
  Social Work Bldg (Amsterdam Ave at 122 St), Room 1016
  212-851-2142
Mon, Fri:
  International Affairs Bldg (Amsterdam Ave at 118 St), Room 711
  212-854-7075

Mailing address:
  1255 Amsterdam Ave, Room 1016
  Columbia University
  New York, NY 10027-5904
  212-851-2142
  (fax) 212-851-2164




More information about the R-help mailing list