nice {afex}R Documentation

Make nice ANOVA table for printing.

Description

This generic function produces a nice ANOVA table for printing for objects of class. nice_anova takes an object from Anova possible created by the convenience functions aov_ez or aov_car. When within-subject factors are present, either sphericity corrected or uncorrected degrees of freedom can be reported.

Usage

nice(object, ...)

## S3 method for class 'afex_aov'
nice(
  object,
  es = attr(object$anova_table, "es"),
  observed = attr(object$anova_table, "observed"),
  correction = attr(object$anova_table, "correction"),
  MSE = NULL,
  intercept = NULL,
  p_adjust_method = attr(object$anova_table, "p_adjust_method"),
  sig_symbols = attr(object$anova_table, "sig_symbols"),
  round_ps = attr(object$anova_table, "round_ps"),
  ...
)

## S3 method for class 'anova'
nice(
  object,
  MSE = NULL,
  intercept = NULL,
  sig_symbols = attr(object, "sig_symbols"),
  round_ps = attr(object, "round_ps"),
  sig.symbols,
  ...
)

## S3 method for class 'mixed'
nice(
  object,
  sig_symbols = attr(object$anova_table, "sig_symbols"),
  round_ps = attr(object$anova_table, "round_ps"),
  ...
)

## S3 method for class 'nice_table'
print(x, ...)

Arguments

object, x

An object of class "afex_aov" (see aov_car) or of class "mixed" (see mixed) as returned from the afex functions. Alternatively, an object of class "Anova.mlm" or "anova" as returned from Anova.

...

currently ignored.

es

Effect Size to be reported. The default is given by afex_options("es_aov"), which is initially set to "ges" (i.e., reporting generalized eta-squared, see details). Also supported is partial eta-squared ("pes") or "none".

observed

character vector referring to the observed (i.e., non manipulated) variables/effects in the design. Important for calculation of generalized eta-squared (ignored if es is not "ges"), see details.

correction

Character. Which sphericity correction of the degrees of freedom should be reported for the within-subject factors. The default is given by afex_options("correction_aov"), which is initially set to "GG" corresponding to the Greenhouse-Geisser correction. Possible values are "GG", "HF" (i.e., Hyunh-Feldt correction), and "none" (i.e., no correction).

MSE

logical. Should the column containing the Mean Sqaured Error (MSE) be displayed? Default is TRUE.

intercept

logical. Should intercept (if present) be included in the ANOVA table? Default is FALSE which hides the intercept.

p_adjust_method

character indicating if p-values for individual effects should be adjusted for multiple comparisons (see p.adjust and details). The default NULL corresponds to no adjustment.

sig_symbols

Character. What should be the symbols designating significance? When entering an vector with length(sig.symbol) < 4 only those elements of the default (c(" +", " *", " **", " ***")) will be replaced. sig_symbols = "" will display the stars but not the +, sig_symbols = rep("", 4) will display no symbols. The default is given by afex_options("sig_symbols").

round_ps

Function that should be used for rounding p-values. The default is given by afex_options("round_ps").

sig.symbols

deprecated argument, only for backwards compatibility, use "sig_symbols" instead.

Details

The returned data.frame is print-ready when adding to a document with proper methods. Either directly via knitr or similar approaches such as via package xtable (nowadays knitr is probably the best approach, see here). xtable converts a data.frame into LaTeX code with many possible options (e.g., allowing for "longtable" or "sidewaystable"), see xtable and print.xtable. See Examples.

Conversion functions to other formats (such as HTML, ODF, or Word) can be found at the Reproducible Research Task View.

The default reports generalized eta squared (Olejnik & Algina, 2003), the "recommended effect size for repeated measured designs" (Bakeman, 2005). Note that it is important that all measured variables (as opposed to experimentally manipulated variables), such as e.g., age, gender, weight, ..., must be declared via observed to obtain the correct effect size estimate. Partial eta squared ("pes") does not require this.

Exploratory ANOVA, for which no detailed hypotheses have been specified a priori, harbor a multiple comparison problem (Cramer et al., 2015). To avoid an inflation of familywise Type I error rate, results need to be corrected for multiple comparisons using p_adjust_method. p_adjust_method defaults to the method specified in the call to aov_car in anova_table. If no method was specified and p_adjust_method = NULL p-values are not adjusted.

Value

A data.frame of class nice_table with the ANOVA table consisting of characters. The columns that are always present are: Effect, df (degrees of freedom), F, and p.

ges contains the generalized eta-squared effect size measure (Bakeman, 2005), pes contains partial eta-squared (if requested).

Author(s)

The code for calculating generalized eta-squared was written by Mike Lawrence.
Everything else was written by Henrik Singmann.

References

Bakeman, R. (2005). Recommended effect size statistics for repeated measures designs. Behavior Research Methods, 37(3), 379-384. doi:10.3758/BF03192707

Cramer, A. O. J., van Ravenzwaaij, D., Matzke, D., Steingroever, H., Wetzels, R., Grasman, R. P. P. P., ... Wagenmakers, E.-J. (2015). Hidden multiplicity in exploratory multiway ANOVA: Prevalence and remedies. Psychonomic Bulletin & Review, 1-8. doi:10.3758/s13423-015-0913-5

Olejnik, S., & Algina, J. (2003). Generalized Eta and Omega Squared Statistics: Measures of Effect Size for Some Common Research Designs. Psychological Methods, 8(4), 434-447. doi:10.1037/1082-989X.8.4.434

See Also

aov_ez and aov_car are the convenience functions to create the object appropriate for nice_anova.

Examples


## example from Olejnik & Algina (2003)
# "Repeated Measures Design" (pp. 439):
data(md_12.1)
# create object of class afex_aov:
rmd <- aov_ez("id", "rt", md_12.1, within = c("angle", "noise"))
rmd
nice(rmd)
str(nice(rmd))
# use different es:
nice(rmd, es = "pes") # noise: .82
nice(rmd, es = "ges") # noise: .39

# same data other approach:
rmd2 <- aov_ez("id", "rt", md_12.1, within = c("angle", "noise"), 
               anova_table=list(correction = "none", es = "none"))
nice(rmd2)
nice(rmd2, correction = "GG")
nice(rmd2, correction = "GG", es = "ges")

# exampel using obk.long (see ?obk.long), a long version of the OBrienKaiser dataset from car.
data(obk.long)
# create object of class afex_aov:
tmp.aov <- aov_car(value ~ treatment * gender + Error(id/phase*hour), data = obk.long)

nice(tmp.aov, observed = "gender")

nice(tmp.aov, observed = "gender", sig_symbols = rep("", 4))

## Not run: 
# use package ascii or xtable for formatting of tables ready for printing.

full <- nice(tmp.aov, observed = "gender")

require(ascii)
print(ascii(full, include.rownames = FALSE, caption = "ANOVA 1"), type = "org")

require(xtable)
print.xtable(xtable(full, caption = "ANOVA 2"), include.rownames = FALSE)

## End(Not run)

[Package afex version 1.3-1 Index]