ez (version 4.4-0)

ezPredict: Compute predicted values from the fixed effects of a mixed effects model


This function computes the predicted values from the fixed effects of a mixed effects model.


ezPredict( fit , to_predict = NULL , numeric_res = 0 , boot = TRUE , iterations = 1e3 , zero_intercept_variance = FALSE )


Fitted lmer object.
Optional data frame containing the fixed effects design to predict. If absent, the function will assume that the full design from the provided fitted model is requested.
Integer value specifying the sampling resolution of any numeric fixed effect. Has no effect if non-NULL value supplied to to_predict. If to_predict is null and a numeric fixed effect is encountered in the fitted model, then predictions will be obtained at this many evenly spaced intervals between the minimum and maximum values in the original fitted data. The default value, 0, obtains predictions for each unique value found in the original data frame.
Logical. If TRUE (default), bootstrapping will be used to generate sample predictions.
Integer value specifying the number of bootstrap iterations to employ if boot==TRUE.
Logical. If TRUE (default), bootstrap samples will be obtained after setting the intercept variance and covariances to zero. This makes sense only when, prior to fitting the model, the predictor variables were set up with contrasts that make the intercept orthogonal to effects of interest (e.g. contr.sum or contr.helmert). This is useful to visualize cell means with confidence intervals that (roughly) can speak to differences between cells. However, it can be the case that even after zeroing the intercept variance, the resultant CIs on the raw cell values are deceptively large for comparing cells. So, if there appears to be no difference between cells, it is best to nonetheless re-visualize after collapsing the pair of cells of interest to a difference score (using the diff argument to ezPlot2).


A data frame containing the prediction value (and estimated variance of this value) for each cell in the fixed effects design.

See Also

ezMixed, ezPlot2


Run this code

#Read in the ANT data (see ?ANT).

#fit a mixed effects model to the rt data
rt_fit = lmer(
    formula = rt ~ cue*flank*group + (1|subnum)
    , data = ANT[ANT$error==0,]

#obtain the predictions from the model
rt_preds = ezPredict(
    fit = rt_fit

#visualize the predictions
    preds = rt_preds
    , x = flank
    , row = cue
    , col = group
    , y_lab = 'RT (ms)'

Run the code above in your browser using DataCamp Workspace