on the predict.merMod function arguments

321 Views Asked by At

In the function predict.merMod of the lme4 package, what is the difference between the following arguments: allow.new.levels=TRUE, re.form=NA and re.form=~0 if we have only a random intercept?

1

There are 1 best solutions below

4
On

re.form: ...if NA or ~0, include no random effects.

In other words, either of these choices makes predictions for all observations (or sets of predictors specified in newdata) at the population level, setting all random effects to zero.

allow.new.levels: logical if new levels (or NA values) in newdata are allowed. If FALSE (default), such new values in newdata will trigger an error; if TRUE, then the prediction will use the unconditional (population-level) values for data with previously unobserved levels (or NAs).

In other words, population-level predictions are made only (assuming re.form is not NA or ~0) for observations/sets of predictor values where the random-effect grouping variable is NA or a level that did not occur in the original data set used to fit. (If only a subset of the grouping variables in a model with multiple of grouping variables are set to NA/new values, only the random effects corresponding to those grouping variables will be set to zero [this detail is only relevant if there is more than one random-effect term in the model].)