knitr::opts_chunk$set(echo = TRUE)

On the the use of contr.SAS in lmerTest

When computing type III ANOVA tables, lmerTest refits the model using contr.SAS, i.e., SAS-type contrasts for all factors. This has the following consequences:

Draw backs:

  1. The same model has to be refit once more thus wasting time and computational recourses.
  2. The coding of ordered factors is changed from contr.poly to contr.SAS. What is the meaning of type III tests for ordered factors? How does SAS handle these?
  3. There could be cases where the numerical behaviour of the models differ when SAS contrasts are used. For example the model might not converge proporly after changing to SAS contrasts.

Advantages:

  1. Irrespective of the contrasts used, type III tests for all terms are produced. This obviously includes the usual contr.treatment but also contr.sum, contr.helmert and contr.poly which generates orthogonal polynomials for ordered factors.
  2. Whether contr.treatment or contr.SAS are used usually does not matter - only the interpretation of coefficients (which are never seen anyway) changes.
  3. The L-matrix (containing the general contrast structure) has a particular and known structure.

Notes:

  1. It seems that even though models are refitted with contr.SAS, that the code also works when contr.treatment is used. This means that when the default contr.treatment have been used, there should be no reason to refit the models with contr.SAS.

lmerTestR takes a different approach since it doesn't refit the models and so throws an error if contr.treatment or contr.SAS has not been used. Essentially this requires the user to refit the models with one of these contrasts. This will probably rarely be the case, but can come into play if contr.sum has been set for some odd reason, or if ordered factors are used in which case contr.poly will be used by default.



runehaubo/lmerTestR documentation built on Oct. 24, 2020, 12:20 p.m.