# the R package afex includes an ems function that gives expected mean squares: library(afex) # gives the results from Table 7.3 on page 237 of the text ems(r ~ A*B*C, random="ABC") # check the documentation at https://cran.r-project.org/web/packages/afex/afex.pdf # for more features of the afex package, including the ability to # specify nested effects in the ems function