lmer with nested/nonnested groupings?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

lmer with nested/nonnested groupings?

Andrew Gelman
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
[hidden email]
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: lmer with nested/nonnested groupings?

Spencer Graves
        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
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html