Skip to content
Prev 18796 / 20628 Next

na.action = na.augment for random effects in lme4?

On 10/11/20 6:05 PM, Phillip Alday wrote:
Yes. Following up:

* do you mean na.exclude (rather than na.augment)?

* it would certainly make sense that you might want these cases to be NA 
rather than predicted at the population level.  In hindsight it might 
have been a good idea to set this up as new.re.levels allowing the 
options c("population","fail", "exclude", "omit").

   Honestly, sorting out and implementing appropriate behaviours for a 
possible combinations of NAs in covariates or grouping variables of the 
initial data set and in the prediction data set has always given me a 
headache ...

    I would say you should do

  newresp <- predict(fitted_model, newdata, allow.new.levels=TRUE)
  new_levels <- !newdata$groupingvar %in% levels(orig_data$groupingvar)
  newresp[new_levels] <- NA