Learn R Programming

ez (version 4.1-1)

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

Description

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

Usage

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

Arguments

fit
Fitted lmer object.
to_predict
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.
numeric_res
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 predi
boot
Logical. If TRUE (default), bootstrapping will be used to generate sample predictions.
iterations
Integer value specifying the number of bootstrap iterations to employ if boot==TRUE.
zero_intercept_variance
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

Value

  • 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

Examples

Run this code
#Read in the ANT data (see ?ANT).
data(ANT)
head(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
ezPlot2(
    preds = rt_preds
    , x = flank
    , row = cue
    , col = group
    , y_lab = 'RT (ms)'
)

Run the code above in your browser using DataLab