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### Df<-expand.grid(Time=seq(0,10,1), Subject=c("Honeybunch","Buttercup","Rosy", "Sting", "Buzz", "Bumble")) Df$Infection<-NULL Df$Infection[1:33]<-"Infected" Df$Infection[34:66]<-"Uninfected" Df$Infection 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) library(lme4) ##Analysis with consumption of other food type as covariate ModelA<-lmer(Consumption.Food.A~ Time + Infection + Consumption.Food.B + (1|Subject),data=Df) ModelB<-lmer(Consumption.Food.B~ Time + Infection + Consumption.Food.A + (1|Subject), data=Df) #option to convert data to long format library(tidyr) Df_long<-gather(data=Df, key=Foodtype, value=Amt.eaten, Consumption.Food.A,Consumption.Food.B) View(Df_long) #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)