#import lme4 package and lmerTest package
library(lmerTest)
m.carrots <- lmer(Preference ~ sens2 + Homesize
+(1+sens2|Consumer), data=carrots)
# only elimination of the random part is required.
#approximation of ddf is Kenward-Roger
step(m.carrots, ddf="Kenward-Roger")
Run the code above in your browser using DataLab