I am trying to analyze an experiment comparing consumption of 2 food types in a choice-type design. Subjects (bees) were offered a choice of 2 food types, and their daily consumption of each food type was recorded. Each subject also was assigned to one of 2 Infection treatments. We want to know-- " How does infection affect preference for one food type over another?

I am wondering if it is acceptable to model this like a repeated measures design, with 2 observations per subject and timepoint-- one for each food type. Or is that not acceptable because the 2 food types were given at the same time? The repeated measures type design seems to be what was suggested here by Ben Bolker: https://stackoverflow.com/questions/7831243/multivariate-linear-mixed-model-in-lme4

Below I paste a code to generate a random data set, to show the general data structure.

####choice analysis for list###
                          "Sting", "Buzz", "Bumble"))

Df$Consumption.Food.A<-rnorm(n=length(Df$Time),mean=30, sd=6)
Df$Consumption.Food.B<-rnorm(n=length(Df$Time),mean=25, sd=8)

##Analysis with consumption of other food type as covariate
ModelA<-lmer(Consumption.Food.A~ Time + Infection + Consumption.Food.B +
ModelB<-lmer(Consumption.Food.B~ Time + Infection + Consumption.Food.A +
             (1|Subject), data=Df)

#option to convert data to long format
Df_long<-gather(data=Df, key=Foodtype, value=Amt.eaten, 
#Is this model legal, because both foods offered simultaneously?
Fullmodel<-lmer(Amt.eaten ~ Foodtype * Infection + Time +
                  (1|Subject) + (1|Time), data=Df_long)

(Originally I was planning to model proportions of the 2 food types eaten, but the actual data has many values close to zero that could make the proportion estimates highly variable. And the proportional analysis would not account for the strong trends of decreasing with (a) time and (b) infection treatment)


I think what you described about using a "long format" for your data is perfectly reasonable. Additionally I think it is very natural to model this having a repeated measurements design; after all you are repeatedly measuring the consumption of each of your bees. Having said that there are some caveats you need to be careful with:

  1. You do not have many Subjects (6) so you cannot have anything more than rather simple random-effects structures.
  2. You appear to use Time as a factor to define a random intercept (1|Time), this is somewhat counter-intuitive. I suspect you want to use it within a random slope per subject (Time|Subject).
  3. Because of point 1 you will probably be unable to properly account for correlation between random factors in the context of (Time|Subject). I would suggest using uncorrelated random slopes and intercepts (Time + 0 | Subject).
  4. You might need to consider using MCMCglmm to have a somewhat more informed model . This will allow you to define some weak priors for your random effects variance structure. MCMCglmm fits multivariate mixed models natively.
| cite | improve this answer | |
  • $\begingroup$ Thanks for your response, "11852". (1) The situation is not quite so grim as it looks-- there are 20 Subjects, not 6 as in the fabricated dataset. (2) Thank you for the suggestions to use random slopes for each subject across time. (4) Intrigued by MCMCglmm, but given that there are 20 subjects, I am inclined to stick with lmer for consistency with the other models in the publication. I was also spooked by Ben Bolker's comments about MCMCglmm "not doing well" or "misbehaving", and the touchy nature of the priors. [link] (ms.mcmaster.ca/~bolker/classes/uqam/mixedlab1.pdf) $\endgroup$ – Evan Palmer-Young Mar 25 '16 at 9:30
  • $\begingroup$ I am glad I could help and that you actually have a larger number of subjects than originally presented (more data $\approx$ good thing :) ); if this is post is useful for you or answers your original question please consider upvoting it or accepting it as an answer. If you get -1/+1 correlation estimates you might want to consider the third point mentioned (I say this so you do not overlook it). $\endgroup$ – usεr11852 Mar 25 '16 at 18:10
  • $\begingroup$ Tried to upvote this but looks like a don't have the "15"-level Cross-val reputation:) Thanks again 11852! $\endgroup$ – Evan Palmer-Young Mar 25 '16 at 21:05
  • $\begingroup$ No problem! Welcome to the community. I am sure that if you stick around for a bit and answer some questions you will get your rep up. $\endgroup$ – usεr11852 Mar 25 '16 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.