Learn R Programming

afex (version 1.4-1)

predict.afex_aov: Predict method for afex_aov objects

Description

Predicted values based on afex_aov objects.

Usage

# S3 method for afex_aov
predict(object, newdata, append = FALSE, colname_predict = ".predict", ...)

Value

A vector of predicted values corresponding to the data in

object$data$long or to newdata, or if append = TRUE a data frame with an additional column of predicted values.

Arguments

object

afex_aov object.

newdata

An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used.

append

If set to TRUE returns the residuals/fitted values appended as an additional column to the long data. Recommended when data was aggregated across within conditions.

colname_predict

Name of the appended column when append = TRUE.

...

Not used.

Author

Mattan S. Ben-Shachar

Examples

Run this code

data(obk.long, package = "afex")

# estimate mixed ANOVA on the full design:
fit <- aov_ez("id", "value", obk.long, between = c("treatment", "gender"), 
              within = c("phase", "hour"), observed = "gender")

new_data <- expand.grid(
  treatment = "A",
  gender = "F",
  phase = c("pre", "post"),
  hour = c(1, 5)
)

predict(fit, newdata = new_data)
predict(fit, newdata = new_data, append = TRUE)

Run the code above in your browser using DataLab