## check if the lmerTest package is already installed/attached sessionInfo() #if not yet installed then install it install.packages("lmerTest") # if not ye library("lmerTest") ################################################################################ ###### Example 1. TVbo data ################################################################################ #summarize the TVbo data str(TVbo) #specification of the "full" model M_TV <- lmer(Sharpnessofmovement ~ TVset*Picture + (1|Assessor:TVset) + (1|Assessor:Picture) + (1|Assessor:Picture:TVset) + (1|Repeat) + (1|Repeat:Picture) + (1|Repeat:TVset) + (1|Repeat:TVset:Picture) + (1|Assessor) , data=TVbo) # automated elimination process s_TV <- step(M_TV) #print the elimination process: analysis of random part and analysis of the fixed part print(s_TV) #print analysis of the random part print(s_TV$rand.table) #print analysis of the fixed part print(s_TV$anova.table) #plot the post-hoc analysis plot(s_TV) #plot the post-hoc analysis of only main effects plot(difflsmeans(s_TV$model, test.effs = c("TVset", "Picture"))) ################################################################################ ###### Example 2. carrots data ################################################################################ #summarize the carrots data str(carrots) #specification of the "full" model M_carrots <- lmer(Preference ~ sens2*sens1*Homesize+ (1|product)+(1 + sens1 + sens2|Consumer), data=carrots) ## look at the summary of the model summary(M_carrots) # test random effects rand(M_carrots) # automated elimination process s_carrots <- step(M_carrots) #print the elimination process: analysis of random part and analysis of the fixed part print(s_carrots) #print analysis of the random part print(s_carrots$rand.table) #print analysis of the fixed part print(s_carrots$anova.table) #plot the post-hoc analysis plot(s_carrots) ## reduced model M_red <- lmer(Preference ~ sens2 + Homesize + (1 | product) + (1 + sens2 |Consumer), data = carrots) summary(M_red)