Post-hoc test for interaction and time-series

I have a lmer model based on time-series data. The data is from an experiment with two treatments (“c” and “t”) and I have two individuals per treatment. I am trying to do a post-hoc test to determine if there is a difference in weight between the two treatments. I have tried using emmeans (see code below) but as far as I understand, the results from this is based on the difference between the treatments for a specific year (2000.5 in this case…). However, I’d like to find if there is a difference between the treatments, taking into account all of the years. Any advice would be greatly appreciated.

library(lmerTest)
library(emmeans)

#make dataframe
weight<-c(5.2,3.4,3.5,4.0,3.5,5.2,10.2,7.8,8.2,7.1,8.5,6.2,3.2,2.4,2.5,4.7,2.6,7.3,11.3,9.2,10.2,6.1,9.6,8.7)
year<-c(1998,1999,2000,2001,2002,2003,1998,1999,2000,2001,2002,2003,1998,1999,2000,2001,2002,2003,1998,1999,2000,2001,2002,2003)
treatment<-c("c","c","c","c","c","c","t","t","t","t","t","t","c","c","c","c","c","c","t","t","t","t","t","t")
id<-c("a","a","a","a","a","a","b","b","b","b","b","b","c","c","c","c","c","c","d","d","d","d","d","d")
df<-data.frame(weight,year,treatment,id)

#model
mod<-lmer(weight~year*treatment+(1|id),data=df)

#post-hoc test
compare <- emmeans(mod, specs = pairwise ~ year*treatment, type = "response")
plot<-plot(compare, comparisons = TRUE)

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.