Would greatly appreciate help with this. Hope it is not a duplicate-- my first email to the list appeared to bounce back.
Dear Colleagues, I am trying to analyze an experiment comparing consumption of 2 food types in a choice-type design. Subjects 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? I attached my actual data and script, and also 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")) View(Df) 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 simulateneously 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 there a lot of 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) Thanks very much for your advice! Evan -- Department of Biology 221 Morrill Science Center 611 North Pleasant St Amherst MA 01003 https://sites.google.com/a/cornell.edu/evan-palmer-young/ -- Department of Biology 221 Morrill Science Center 611 North Pleasant St Amherst MA 01003 https://sites.google.com/a/cornell.edu/evan-palmer-young/ _______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology