Reed, Nicola
2010-Dec-13 15:45 UTC
[R] Testing an interaction with a random effect in lmer
Hi, I was hoping to get some advice regarding the testing of interactions, when one factor is modelled as a random effect... I have a model with binomial error structure where the response variable is the proportion of time spent at the main sett (animals were tracked for 28 consecutive days in each season, and were recorded either at the main sett or an outlier sett, so the response variable is a number out of 28). Animals from 9 social groups were tracked for 28 days in each of the four seasons of the year. Thus, in my model, 'individual' nested within 'social group' are my random error terms. model<-lmer(binom~season+(1|group/individual),binomial,data=data1) Group explains some variation in the sett use patterns, and what i was wanting to test and display was an interaction between season and group, as the raw data suggests that different groups may behave differently in different seasons. Is there a way to do this in the lmer package? When i put it in directly: model<-lmer(binom~season*group+(1|group/individual),binomial,data=data1) I get an error messgae: Warning message: In mer_finalize(ans) : gr cannot be computed at initial par (65) The model runs with the following: modelb<-lmer(binom~season*(1|group)+(1|group/badger),binomial,data=data1) or modelb<-lmer(binom~season+(1|group/badger)+(1|group:season),binomial,data=data1) but here I guess I am modelling it as part of the random effect so can't plug out coefficients for the different groups in different seasons. Thanks for any advice, Nicola [[alternative HTML version deleted]]
Reed, Nicola <nr232 <at> exeter.ac.uk> writes:> I was hoping to get some advice regarding the testing of interactions, > when one factor is modelled as a > random effect... > I have a model with binomial error structure where the response > variable is the proportion of time spent at > the main sett (animals were tracked for 28 consecutive days > in each season, and were recorded either at the > main sett or an outlier sett, so the response variable is a number out of 28). > Animals from 9 social groups were tracked for 28 days in each of > the four seasons of the year. > Thus, in my model, 'individual' nested within 'social group' > are my random error terms. > > model<-lmer(binom~season+(1|group/individual),binomial,data=data1) > > Group explains some variation in the sett use patterns, > and what i was wanting to test and display was an > interaction between season and group, as the raw data suggests > that different groups may behave > differently in different seasons. Is there a way to do this in > the lmer package? > > When i put it in directly: > > model<-lmer(binom~season*group+(1|group/individual),binomial,data=data1) > > I get an error messgae: > Warning message: > In mer_finalize(ans) : gr cannot be computed at initial par (65) >I think you want binom~season + (season|group) + (1|individual) [assuming that individuals are coded uniquely, i.e. you don't have an 'individual A' in each group] If you had enough data to consider testing variation in seasonality among individuals, you could try binom~season + (season|group/individual) was the switch from 'individual' above to 'badger' below a slip? Thanks for the clear description. Ben Bolker