Home forums Mixed Models expand_re with missing values

Viewing 2 reply threads
  • Author
    • #126

      In the “Expand Random Effects” section of the afex manual one is warned to use the expand_re argument in case of missing value:

      Note that it most likely differs from g/lmer in how it handles missing values so it is recommended to only pass data without missing values to it!

      Is this only relevant to lmer_alt or also to mixed? Besides, what are the implications of using it anyway?

    • #128

      It is not advised to use any afex functions with missing data. Perhaps more generally, it is not advised for any standard (i.e., part of the stats package) R modeling function to have missing data. All those functions simply remove missing data on a casewise basis and it is a good idea to remove them before running any model. Otherwise you might get the false sense that all your data was used for fitting, whereas those observations with missing missing values were in fact simply removed.

      The way in which mixed works (i.e., in many situations it first creates several model matrices that are then fitted separately) somewhat complicates this. If the different model matrices have different numbers of rows due to missing values the ensuing models are non-commensurable and cannot be used for hypothesis testing. This can also appear when using expand_re = TRUE as this also creates a new model matrix (as the argument implies, it first expands the random effects structure into a new model matrix).

      The point of this warning is simply that the way in which the creation of the new model matrix deals with missing values cannot be guaranteed to be the same as is done in g/lmer. This also applies to both lmer_alt and mixed. Hence, I highly advise to remove missing values before fitting a model if they appear in any variables that are part of the model (i.e., for for dependent variables, fixed-, and random-effects). I would go so far to suggest this even when using modeling functions outside of afex unless they explicitly deal with missing values (e.g., multiple imputation, but note that these also fit models where each data set has no missings as they are imputed in each case).

      I hope this clears it up.

    • #130

      Yes, that made it clear! Thanks.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.