[R-sig-eco] LMER: applying a random term to only one level of a factor

Aislinn Pearson aislinn.pearson at rothamsted.ac.uk
Wed Apr 6 20:12:45 CEST 2016


Hi,

I've tried googling this but haven't been very successful. Essentially, I'd like to know what is the most statistically valid way of dealing with a random term which doesn't apply to every level of fixed-effect factor.

I have a mixed effect model that looks like this

Disease level <- weight + Flown +(1|DateFlown)

Either I flew my insects on a flight mill (which can be thought of as a 'treadmill' for flying insects) or I didn't, hence flown is a two level factor (Yes or No) and I want to understand how this affects the amount of disease in my insect. To get as many replicates as I could on a single day, I had two different banks of flight mills (A & B), each bank containing 16 individual insect treadmills. The insects were randomly assigned to one of the two sets of 16 flight mills. Previous studies tell me there are differences between these two sets of flight mills, so I would like to account for them as a random term in my model.

However, I can't run this in LMER. When I tried I got the error;

Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
  contrasts can be applied only to factors with 2 or more levels

Which I imagine means that one of my factors (i.e. Flown) doesn't include any levels for the random term mill set (i.e. for all unflown insects the value in the mill set column is NA)

Is it possible to include this form of experimental design in LMER (the package I know best) or, alternatively, nlme (which I am a lot less accustomed to using)?

I would be really grateful if anyone has any insight.

Many thanks

Rothamsted Research is a company limited by guarantee, registered in England at Harpenden, Hertfordshire, AL5 2JQ under the registration number 2393175 and a not for profit charity number 802038.



	[[alternative HTML version deleted]]



More information about the R-sig-ecology mailing list