Hi Clara,

Petri got you a reference for the minimal number of random effects.

Given what you say about the three bills, it would probably make sense to
analyse each as a separate outcome, and also to include them all, as you
suggest, but yes I think a fixed effect is your only solution in this
regard.

As for your covariates, since you have some that are time-varying at the
state level, then yes a state-year (or, equivalently, state-bill) random
intercept is worth trying. (This will be informative because it will tell
you how much variance there is within states across years/bills compared to
across states.)

(I say equivalently, but I'm assuming each bill comes up for a vote in a
different year?)

Also, you may want to center your covariates, as described for example in:
http://polmeth.wustl.edu/mediaDetail.php?docId=1324
http://psycnet.apa.org/doi/10.1037/1082-989X.12.2.121

Cheers,
Malcolm


On 5 July 2013 18:35, Clara Vandeweerdt <clara.vdw@gmail.com> 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@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@gmail.com>
>>> To: r-sig-mixed-models@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]]

