Package: afex 1.5-1

afex: Analysis of Factorial Experiments

Convenience functions for analyzing factorial experiments using ANOVA or mixed models. aov_ez(), aov_car(), and aov_4() allow specification of between, within (i.e., repeated-measures), or mixed (i.e., split-plot) ANOVAs for data in long format (i.e., one observation per row), automatically aggregating multiple observations per individual and cell of the design. mixed() fits mixed models using lme4::lmer() and computes p-values for all fixed effects using either Kenward-Roger or Satterthwaite approximation for degrees of freedom (LMM only), parametric bootstrap (LMMs and GLMMs), or likelihood ratio tests (LMMs and GLMMs). afex_plot() provides a high-level interface for interaction or one-way plots using ggplot2, combining raw data and model estimates. afex uses type 3 sums of squares as default (imitating commercial statistical software).

Authors:Henrik Singmann [aut, cre], Ben Bolker [aut], Jake Westfall [aut], Frederik Aust [aut], Mattan S. Ben-Shachar [aut], Søren Højsgaard [ctb], John Fox [ctb], Michael A. Lawrence [ctb], Ulf Mertens [ctb], Jonathon Love [ctb], Russell Lenth [ctb], Rune Haubo Bojesen Christensen [ctb]

afex_1.5-1.tar.gz
afex_1.5-1.zip(r-4.7)afex_1.5-1.zip(r-4.6)afex_1.5-1.zip(r-4.5)
afex_1.5-1.tgz(r-4.6-any)afex_1.5-1.tgz(r-4.5-any)
afex_1.5-1.tar.gz(r-4.7-any)afex_1.5-1.tar.gz(r-4.6-any)
afex_1.5-1.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
afex/json (API)

# Install 'afex' in R:
install.packages('afex', repos = c('https://singmann.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/singmann/afex/issues

Datasets:
  • fhch2010 - Data from Freeman, Heathcote, Chalmers, & Hockley
  • ks2013.3 - Data from Klauer & Singmann
  • laptop_urry - Replication of Laptop Note Taking Study
  • md_12.1 - Data 12.1 from Maxwell & Delaney
  • md_15.1 - Data 15.1 / 11.5 from Maxwell & Delaney
  • md_16.1 - Data 16.1 / 10.9 from Maxwell & Delaney
  • md_16.4 - Data 16.4 from Maxwell & Delaney
  • obk.long - O'Brien Kaiser's Repeated-Measures Dataset with Covariate
  • sk2011.1 - Data from Singmann & Klauer
  • sk2011.2 - Data from Singmann & Klauer
  • stroop - Stroop data from Lin et al.

On CRAN:

Conda:

14.60 score 132 stars 17 packages 2.7k scripts 29k downloads 176 mentions 22 exports 72 dependencies

Last updated from:c7a45c88ed. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK277
source / vignettesOK345
linux-release-x86_64OK293
macos-release-arm64OK280
macos-oldrel-arm64OK277
windows-develOK226
windows-releaseOK220
windows-oldrelOK229
wasm-releaseOK174

Exports:afex_optionsafex_plotaov_4aov_caraov_ezcompare.2.vectorsemsinteraction_plotlmerlmer_altmixedniceoneway_plotround_psround_ps_apaset_default_contrastsset_deviation_contrastsset_effects_contrastsset_sum_contrastsset_treatment_contraststest_levenetest_sphericity

Dependencies:abindbackportsbootbroomcarcarDataclicolorspacecowplotcpp11DerivdoBydplyrfarverforecastFormulafracdiffgenericsggplot2gluegtableisobandlabelinglatticelifecyclelme4lmerTestlmtestmagrittrMASSMatrixMatrixModelsmgcvmicrobenchmarkminqamodelrnlmenloptrnnetnumDerivpbkrtestpillarpkgconfigplyrpurrrquantregR6rbibutilsRColorBrewerRcppRcppArmadilloRcppEigenRdpackreformulasreshape2rlangS7scalesSparseMstringistringrsurvivaltibbletidyrtidyselecttimeDateurcautf8vctrsviridisLitewithrzoo

afex_plot: Publication Ready Plots for Experimental Designs
Two-Way Within-Subjects ANOVA | Basic Plot | Exploring Graphical Options and Themes | Saving Plots and Plot Sizes | Data in the Background | Single Geom | Multiple Geoms | Adding Color to Plots | Plotting Order and Error Bars | One-way Plots Without Trace Factor | 3-Way Mixed Model | Data and Model | Which Data to Plot in the Background | Ways of Plotting Data in the Background | Error Bars for Mixed Models | References

Last update: 2025-12-14
Started: 2018-09-22

afex_plot: Supported Models
Introduction | Base R stats models: lm, glm | nlme mixed model | glmmTMB | GLMMadaptive | rstanarm | brms

Last update: 2025-12-14
Started: 2019-02-15

Mixed Model Reanalysis of RT data
Overview | Description of Experiment and Data | Data and R Preparation | Descriptive Analysis | Model Setup | Finding the Final Model | Results of Maximal and Final Model | LRT Results | Summary of Results | Follow-Up Analyses | task:stimulus:frequency Interaction | task:stimulus:density:frequency Interaction | References

Last update: 2025-12-14
Started: 2017-04-04

Testing the Assumptions of ANOVAs
Foreword by Henrik Singmann | Testing the Empirically Testable Assumptions | Homogeneity of Variances | What to do when assumption is violated? | Sphericity | Normalicy of Residuals | References

Last update: 2025-08-24
Started: 2021-07-07

Analysis of Accuracy Data using ANOVA and binomial GLMMs
Overview | Data and Research Question | ANOVA Analysis | Mixed Model Analysis | Setting-Up and Fitting the Models | Dealing with Fit Warnings | ANOVA Table for GLMMs | Follow-Up Analysis and Plots | Analysis of Two Studies with GLMM | Estimating Models in Parallel | Type III versus Type II Sums of Squares | Follow-Up Tests for Type II Models | References

Last update: 2024-09-01
Started: 2020-05-05

ANOVA and Post-Hoc Contrasts: Reanalysis of Singmann and Klauer (2011)
Overview | Description of Experiment and Data | Data and R Preperation | ANOVA | Post-Hoc Contrasts and Plotting | Some First Contrasts | Main Effects Only | A Simple interaction | Running Custom Contrasts | Plotting | Basic Plots | Customizing Plots | Replicate Analysis from Singmann and Klauer (2011) | Final Note | References

Last update: 2024-09-01
Started: 2017-04-04

An Introduction to Mixed Models for Experimental Psychology
Fixed Effects, Random Effects, and Non-Independence | Setting up a Mixed Model | Fitting Mixed Models in R | Beyond Linear Mixed Models and the Identity Link Function | Summary

Last update: 2018-03-26
Started: 2018-03-26

Readme and manuals

Help Manual

Help pageTopics
Analysis of Factorial Experimentsafex-package afex
Methods for afex_aov objectsafex_aov-methods anova.afex_aov emm_basis.afex_aov print.afex_aov recover_data.afex_aov summary.afex_aov
Set/get global afex optionsafex_options
m-way Plot with Error Bars and Raw Dataafex_plot afex_plot.afex_aov afex_plot.default afex_plot.merMod afex_plot.mixed interaction_plot oneway_plot
Convenient ANOVA estimation for factorial designsaov_4 aov_car aov_ez
Compare two vectors using various tests.compare.2.vectors
Expected values of mean squares for factorial designsems
Data from Freeman, Heathcote, Chalmers, & Hockley (2010)fhch2010
Data from Klauer & Singmann (2013, Experiment 3)ks2013.3
Replication of Laptop Note Taking Study (Urry et al. 2021, Psych. Science)laptop_urry
Data 12.1 from Maxwell & Delaneymd_12.1
Data 15.1 / 11.5 from Maxwell & Delaneymd_15.1
Data 16.1 / 10.9 from Maxwell & Delaneymd_16.1
Data 16.4 from Maxwell & Delaneymd_16.4
p-values for fixed effects of mixed-model via lme4::lmer()lmer_alt mixed
Make nice ANOVA table for printing.nice nice.afex_aov nice.anova nice.mixed print.nice_table
O'Brien Kaiser's Repeated-Measures Dataset with Covariateobk.long
Predict method for 'afex_aov' objectspredict.afex_aov
Extract Residuals and Fitted Values from 'afex_aov' objectsfitted.afex_aov residuals.afex_aov
Helper functions for rounding p-valuesround_ps round_ps_apa
Set global contrastsset_default_contrasts set_deviation_contrasts set_effects_contrasts set_sum_contrasts set_treatment_contrasts
Data from Singmann & Klauer (2011, Experiment 1)sk2011.1
Data from Singmann & Klauer (2011, Experiment 2)sk2011.2
Stroop data from Lin et al. (2020, Psych. Science)stroop