[R-sig-ME] lmer: Model with crossed and nested factors, unbalanced data

Petri Lankoski petri.lankoski at gmail.com
Fri Jul 5 19:54:49 CEST 2013


r-sig-mixed-models FAQ:
"One point of particular relevance to 'modern' mixed model estimation 
(rather than 'classical' method-of-moments estimation) is that, for 
practical purposes, there must be a reasonable number of random-effects 
levels (e.g. blocks) — more than 5 or 6 at a minimum.
e.g., from Crawley [10] p. 670:"

http://glmm.wikidot.com/faq

Best,

Petri

On 2013/07/05 19:35 , Clara Vandeweerdt wrote:
> Dear Malcolm,
>
> Thanks, that was very helpful! Yes, it seems like I've been confusing lme4
> and nlme.
>
> As you noticed, there's only a limited number of bills: just three, which
> were voted upon in 2003, 2005 and 2008. Could you give me a hint on why
> that makes bill a bad candidate for a random effect? Or refer me to a
> source about that?
>
> My reasoning was based on the fact that we were not actually interested in
> the differences in voting behavior invoked by the content of
> the different bills. Rather, we regarded these three bills as three
> possible but randomly selected instances of 'a cap-and-trade bill', and we
> wanted to take into account the fact that (for unknown reasons), each bill
> was likely to invoke its own patterns of voting behavior. In that case,
> wouldn't treating bill as a fixed effect be unparsimonious?
>
> Key covariates are public opinion about climate change (state-level, not
> time-variant), presence of sensitive industries in the state (state-level,
> time-variant), party (Senator-level, strictly speaking time-variant), and
> campaign contributions (Senator-level, time-variant). Based on that, do I
> understand correctly that you would advise a model with a fixed effect for
> bill and (nested) random effects for Senator, state and stateyear?
>
> Best,
>
> Clara Vandeweerdt
> Master in Comparative and International Politics, 2013
> Faculty of Social Sciences
> KU Leuven
> Belgium
>
>
>
> 2013/7/5 Malcolm Fairbrother <M.Fairbrother at bristol.ac.uk>
>
>> Hi Clara,
>>
>> I think you may be confusing lme4 and nlme -- two different
>> packages. Crossed random effects are straightforward with lme4, somewhat
>> more complicated with nlme.
>>
>> However, I doubt that it makes sense to include a random intercept for
>> each vote. How many votes are there? It sounds like just a handful, in
>> which case that's not enough. I'd include a fixed effect for vote instead.
>>
>> So:
>>
>> glmer(vote ~ bill + (1 | Senator) + (1 | state), dataSenate,
>> family=binomial)
>>
>> lme4 will notice that Senators are nested within states, assuming every
>> Senator has a different name. And you don't need the link=logit bit, since
>> that's the default.
>>
>> Imbalance shouldn't be a problem, though for full advise it would help to
>> know about your key covariates. You might want to include a random
>> intercept for stateyear, for example, if you have time-varying state-level
>> covariates.
>>
>> Hope that helps.
>>
>> Cheers,
>> Malcolm
>>
>>
>>
>>
>>
>>> Date: Wed, 3 Jul 2013 20:59:23 +0200
>>> From: Clara Vandeweerdt <clara.vdw at gmail.com>
>>> To: r-sig-mixed-models at r-project.org
>>> Subject: [R-sig-ME] lmer: Model with crossed and nested factors,
>>>          unbalanced data
>>>
>>>
>>> Dear all,
>>>
>>> For a research project on climate legislation in the U.S., I am analyzing
>>> data on the votes that Senators cast on several cap-and-trade bills in the
>>> period 2003-2008. For each Senator, we have data about how he or she voted
>>> regarding a certain bill (i.e., 'yea' or 'nay')--given, of course, that
>>> that Senator had a seat in Congress in the year that the bill was voted
>>> upon. We want to explain the voting behavior of these Senators given
>>> characteristics of the Senators and of their constituencies, that is, the
>>> states they represent, but at the same time take into account the nested
>>> structure of the data.
>>>
>>> Thus, the data looks as follows:
>>> state    Senator    bill    vote
>>> FL    'Bill Nelson'    'CSA2003'    'yea'
>>> FL    'Bob Graham'    'CSA2003'    'yea'
>>> FL    'Bill Nelson'    'CSA2005'    'yea'
>>> FL    'Mel Martinez'    'CSA2005'    'nay'
>>>
>>> (See attachment for a sample of the data.)
>>>
>>> One choice to analyze such data seems to be a mixed model with both
>>> crossed
>>> and nested random factors. First, Senators are expected to behave
>>> consistently over time: their votes on different bills should be similar.
>>> Second, pairs of Senators represent the same state: for example, in 2003,
>>> Bill Nelson and Bob Graham both represented Florida. So, there seems to be
>>> a random effect of Senators, which are nested in states. Third, there
>>> would
>>> be a random effect of bill, which is crossed with states and Senators.
>>> Finally, the model should be logistic, as votes can be either 'yea' or
>>> 'nay'.
>>>
>>> 1. How should I specify such a model? Is it sufficient just to specify
>>> both
>>> the nested random effects of Senator and state, as well as the random
>>> effect of bill (in analogy to this post:
>>>
>>> http://r.789695.n4.nabble.com/lmer-crossed-random-effects-specification-td831762.html
>>> )?
>>> For example, in case of a model with only random intercepts for Senator,
>>> state and bill:
>>>
>>> dataSenate <- read.table("sampledata.txt", header = TRUE, sep = "\t",
>>> na.strings = c("-1"))
>>>
>>> dataSenate$state <- as.factor(dataSenate$state)
>>> dataSenate$Senator <- as.factor(dataSenate$Senator)
>>> dataSenate$bill <- as.factor(dataSenate$bill)
>>>
>>> library(lme4)
>>>
>>> interceptonly <- glmer(vote ~ 1 + (1 | state/Senator) + (1 | bill), data =
>>> dataSenate, family=binomial(link = "logit"))
>>>
>>> Or should I use the pdBlocked and pdIdent formulation that is suggested
>>> here: http://tolstoy.newcastle.edu.au/R/help/02b/2068.html?
>>>
>>> 2. This does not seem to be a balanced design: some Senators lost their
>>> seat in the period 2003-2008, so that many of them did not vote upon all
>>> three of the bills. In other words, for many Senator-bill-combinations,
>>> there are no data. Should this affect my interpretation of the results?
>>>
>>> Best regards,
>>>
>>> Clara Vandeweerdt
>>> Master in Comparative and International Politics, 2013
>>> Faculty of Social Sciences
>>> KU Leuven
>>> Belgium
>>> -------------- next part --------------
>>> state   bill    Senator vote
>>> WA      CSA2003 Patty Murray    1
>>> WA      CSA2003 Maria Cantwell  1
>>> WA      ACSA2008        Patty Murray    1
>>> WA      ACSA2008        Maria Cantwell  1
>>> WA      CSA2005 Patty Murray    1
>>> WA      CSA2005 Maria Cantwell  1
>>> DE      CSA2003 Joseph Biden    1
>>> DE      CSA2003 Thomas Carper   1
>>> DE      ACSA2008        Joseph Biden    -1
>>> DE      ACSA2008        Thomas Carper   1
>>> DE      CSA2005 Joseph Biden    1
>>> DE      CSA2005 Thomas Carper   1
>>> WI      CSA2003 Herbert Herb Kohl       1
>>> WI      CSA2003 Russell Feingold        1
>>> WI      ACSA2008        Herbert Herb Kohl       1
>>> WI      ACSA2008        Russell Feingold        1
>>> WI      CSA2005 Herbert Herb Kohl       1
>>> WI      CSA2005 Russell Feingold        0
>>> WV      CSA2003 John Jay Rockefeller    1
>>> WV      CSA2003 Robert Byrd     0
>>> WV      ACSA2008        John Jay Rockefeller    1
>>> WV      ACSA2008        Robert Byrd     -1
>>> WV      CSA2005 John Jay Rockefeller    1
>>> WV      CSA2005 Robert Byrd     0
>>> HI      CSA2003 Daniel Akaka    1
>>> HI      CSA2003 Daniel Inouye   1
>>> HI      ACSA2008        Daniel Akaka    1
>>> HI      ACSA2008        Daniel Inouye   1
>>> HI      CSA2005 Daniel Akaka    1
>>> HI      CSA2005 Daniel Inouye   1
>>> FL      CSA2003 Bill Nelson     1
>>> FL      CSA2003 Bob Graham      1
>>> FL      ACSA2008        Bill Nelson     1
>>> FL      ACSA2008        Mel Martinez    1
>>> FL      CSA2005 Bill Nelson     1
>>> FL      CSA2005 Mel Martinez    0
>>>
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

-- 
Petri Lankoski ....................... Senior Lecturer in Game Studies
Media technology ................................ Södertörn University
petri.lankoski at sh.se ... www.iki.fi/petri.lankoski ... +46 76 792 4073



More information about the R-sig-mixed-models mailing list