I've kinda asked this before, but I guess that I've made it too complicated and I still don't get it right...(I'm using R, so lmer)

  • To put it simply: can we have NAs in the outcome and/or in the predictor variables of a linear mixed model (or should we always delete them or imputate?) So,

1) Can we have Na/missing data in the outcome variable?

2) Can we have NA/missing data in the predictor variables?

Thanks in advance! (I'm trying to understand if a model (not necessary mine) with Nas is conceptually wrong + how having Nas bias the results in general so that I can get the bigger picture)


I'm wondering If I should do this before (any) model:

data <- data %>% 
  dplyr::select(Participant, OutcomeContVariable, PredContVariable, PredCateg2-LevelVariable) %>% 
  # group_by(Participant) %>% 
  # filter(all(!is.na(OutcomeContVariable) & !is.na(PredContVariable)))
  • 1
    $\begingroup$ it's not conceptually wrong, you can, in theory, universally deal with missingness using imputation, though getting that right in practice can be tricky $\endgroup$ Sep 13, 2022 at 13:52
  • $\begingroup$ @JohnMadden , thanks, but does it apply to both variables or only to the outcome or to the pred variables? (I'm trying to understand If I need to do it pairwise) $\endgroup$ Sep 13, 2022 at 13:55
  • $\begingroup$ Perhaps you had ought to look up the work "universally" :) But to be slightly more helpful, indeed the "pairwise" approach is popular. See e.g. Mice: cran.r-project.org/web/packages/mice/mice.pdf $\endgroup$ Sep 13, 2022 at 13:57

3 Answers 3


Software like lmer() will typically omit any row of data that has an NA value for any variable that's in the model, outcome or predictor. From that perspective, if you don't impute then what other pre-modeling choice you make doesn't matter--rows with any missing data in the variables of interest simply won't be used in building your model. (As @Björn notes in another answer, other modeling approaches can incorporate missing data directly.)

The question then becomes whether this matters. There are circumstances in which it's OK to delete cases with missing outcome data, as explained by Stef Van Buuren where $X$ represents predictors and $Y$ outcome:

If the missing data occur in $Y$ only, complete-case analysis and multiple imputation are equivalent...

He notes two additional special cases:

The first special case occurs if the probability to be missing does not depend on $Y$. Under the assumption that the complete-data model is correct, the regression coefficients are free of bias... This holds for any type of regression analysis, and for missing data in both $Y$ and $X$.

The second special case holds only if the complete data model is logistic regression. Suppose that the missing data are confined to either a dichotomous $Y$ or to $X$, but not to both. Assuming that the model is correctly specified, the regression coefficients (except the intercept) from the complete-case analysis are unbiased if the probability to be missing depends only on $Y$ and not on $X$.

He warns:

At a minimum, application of listwise deletion should be a conscious decision of the analyst, and should preferably be accompanied by an explicit statement that the missing data fit in one of the three categories described above.

Otherwise, multiple imputation is preferred, as illustrated nicely by @dipetkov on a data set you previously provided.

van Buuren's Flexible Imputation of Missing Data is a superb, generally accessible discussion of missing-data issues and how to deal with them, whether in your own data or in considering work by others.

In response to edited question:

I'm not fluent in tidyverse, but I infer that your specific question (if you aren't going to do imputation) is whether you should completely remove a Participant that has any missing values in modeled variables at any observation time in a longitudinal study.

A Participant can still provide information about observation times for which she provides data, as Björn's answer indicates. Mixed models can even handle completely different observations times among individuals, particularly if you model time smoothly (e.g., with regression splines). So the most general answer is: don't throw away data, keep all the useful data that you have.

Or use multiple imputation if appropriate.

  • $\begingroup$ thank you very much! so, "From that perspective, if you don't impute then what other pre-modeling choice you make doesn't matter--rows with any missing data in the variables of interest simply won't be used in building your model." Ok, I get that. But I'm wondering how nas can bias the model ? I mean, if I have 2 categories from a categorical variable and more scores for one than another, wouldn't this be an issue? $\endgroup$ Sep 13, 2022 at 18:42
  • $\begingroup$ by the way, yes, that code would totally exclude a participant if s/he had a missing value for either Y or X, I was wondering if I had to do that before fiting a model in order to force pairwise $\endgroup$ Sep 13, 2022 at 18:45
  • $\begingroup$ @LarissaCury one question is whether or why you want to force pairwise deletion. With the exceptions noted in the answer, deletion of observations with missing data can lead to bias. Study the van Buuren FIMD book, particularly Part I for an overview and Chapter 11 for how to work with longitudinal data. You might try playing with a full data set (maybe simulated) similar to yours, modeling it, then omitting some data and seeing how different ways of handling the missingness compare. $\endgroup$
    – EdM
    Sep 13, 2022 at 19:48

Part 1 of the question

For the outcome variable, if one does not explicitly impute missing values (whether you leave records with NA in or delete them, as long as you leave the non-missing records for patients with partially missing data in), then missing values would be dealt with under full information maximum likelihood. I.e. using a mixed model without imputing missing values is usually equivalent to imputing under the assumption of missing at random.

For example, if you have a randomized trial comparing two treatments and values after treatment discontinuation are missing, then you are saying that your estimand is: the hypothetical difference between treatments if all patients had finished treatment (which we know they have not, but you are interested in this hypothetical question). Additionally, you assume that everything that explains the treatment discontinuation is part of the baseline covariates in the model or is jointly modelled together with the outcome variable in your outcome model.

If you want to target a different estimand or want to not make the assumption above, you would want to explicitly impute (usually done via multiple imputation) under whatever assumptions you want to make.

Part 2 of the question

lmer has no capabilities for directly dealing with missing covariates, but that's not a general theoretical limitation (e.g. in the brms R package you can directly deal with this situation under certain assumptions).

Multiple imputation before model fitting is one of the obvious approaches for dealing with this situation in a way that then lets us use lmer.


Think of it like having a jigsaw puzzle, and even if some pieces are missing, you can still put together a pretty good picture using the pieces you do have. That's what a linear-mixed model does with missing data - it helps us find relationships and patterns in our data even when some information is missing.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.