Learn R Programming

misty (version 0.6.7)

aov.w: Repeated Measures Analysis of Variance (Within-Subject ANOVA)

Description

This function performs an one-way repeated measures analysis of variance (within subject ANOVA) including paired-samples t-tests for multiple comparison and provides descriptive statistics, effect size measures, and a plot showing error bars for difference-adjusted Cousineau-Morey within-subject confidence intervals with jittered data points including subject-specific lines.

Usage

aov.w(formula, data, print = c("all", "none", "LB", "GG", "HF"),
      posthoc = FALSE, conf.level = 0.95,
      p.adj = c("none", "bonferroni", "holm", "hochberg", "hommel", "BH", "BY", "fdr"),
      hypo = TRUE, descript = TRUE, epsilon = TRUE, effsize = FALSE,
      na.omit = TRUE, plot = FALSE, point.size = 4, adjust = TRUE,
      error.width = 0.1, xlab = NULL, ylab = NULL, ylim = NULL,
      breaks = ggplot2::waiver(), jitter = TRUE, line = TRUE,
      jitter.size = 1.25, jitter.width = 0.05, jitter.height = 0,
      jitter.alpha = 0.1, title = "", subtitle = "Confidence Interval",
      digits = 2, p.digits = 4, as.na = NULL, write = NULL, append = TRUE,
      check = TRUE, output = TRUE, ...)

Value

Returns an object of class misty.object, which is a list with following entries:

call

function call

type

type of analysis

data

list with the data (data) in wide-format (wide), reshaped data in long-format (long), and within-subject confidence intervals (ci)

formula

formula of the current analysis

plot

ggplot2 object for plotting the results

args

specification of function arguments

result

list with result tables, i.e., descript for descriptive statistics, epsilon for a table with indices of sphericity, test for the ANOVA table (none for no sphericity correction, lb for lower bound correction, gg for Greenhouse and Geiser correction, and hf for Huynh and Feldt correction), posthoc for post hoc tests, and aov for the return object of the aov function

Arguments

formula

a formula of the form cbind(time1, time2, time3) ~ 1 where time1, time2, and time3 are numeric variables representing the levels of the within-subject factor, i.e., data are specified in wide-format (i.e., multivariate person level format).

data

a matrix or data frame containing the variables in the formula formula.

print

a character vector indicating which sphericity correction to use, i.e., all for all corrections, none for no correction, LB for lower bound correction, GG for Greenhouse-Geisser correction, and HF, for Huynh-Feldt correction.

posthoc

logical: if TRUE, paired-samples t-tests for multiple comparison are conducted.

conf.level

a numeric value between 0 and 1 indicating the confidence level of the interval.

p.adj

a character string indicating an adjustment method for multiple testing based on p.adjust, i.e., none, bonferroni, holm (default), h ochberg, hommel, BH, BY, or fdr.

hypo

logical: if TRUE (default), null and alternative hypothesis are shown on the console.

descript

logical: if TRUE (default), descriptive statistics are shown on the console.

epsilon

logical: if TRUE (default), box indices of sphericity (epsilon) are shown on the console, i.e., lower bound, Greenhouse and Geiser (GG), Huynh and Feldt (HF) and average of GG and HF.

effsize

logical: if TRUE, effect size measures eta-squared (\(\eta^2\)), partial eta-squared (\(\eta^2_p\)), omega-squared (\(\omega^2\)), and partial omega-squared (\(\omega^2_p\)) for the repeated measures ANOVA and Cohen's d for the post hoc tests are shown on the console.

na.omit

logical: if TRUE, incomplete cases are removed before conducting the analysis (i.e., listwise deletion).

plot

logical: if TRUE, a plot showing error bars for confidence intervals is drawn.

point.size

a numeric value indicating the size aesthetic for the point representing the mean value.

adjust

logical: if TRUE (default), difference-adjustment for the Cousineau-Morey within-subject confidence intervals is applied.

error.width

a numeric value indicating the horizontal bar width of the error bar.

xlab

a character string specifying the labels for the x-axis.

ylab

a character string specifying the labels for the y-axis.

ylim

a numeric vector of length two specifying limits of the limits of the y-axis.

breaks

a numeric vector specifying the points at which tick-marks are drawn at the y-axis.

jitter

logical: if TRUE (default), jittered data points are drawn.

line

logical: if TRUE (default), subject-specific lines are drawn.

jitter.size

a numeric value indicating the size aesthetic for the jittered data points.

jitter.width

a numeric value indicating the amount of horizontal jitter.

jitter.height

a numeric value indicating the amount of vertical jitter.

jitter.alpha

a numeric value indicating the opacity of the jittered data points.

title

a character string specifying the text for the title for the plot.

subtitle

a character string specifying the text for the subtitle for the plot.

digits

an integer value indicating the number of decimal places to be used for displaying descriptive statistics and confidence interval.

p.digits

an integer value indicating the number of decimal places to be used for displaying the p-value.

as.na

a numeric vector indicating user-defined missing values, i.e. these values are converted to NA before conducting the analysis.

write

a character string naming a text file with file extension ".txt" (e.g., "Output.txt") for writing the output into a text file.

append

logical: if TRUE (default), output will be appended to an existing text file with extension .txt specified in write, if FALSE existing text file will be overwritten.

check

logical: if TRUE (default), argument specification is checked.

output

logical: if TRUE (default), output is shown on the console.

...

further arguments to be passed to or from methods.

Author

Takuya Yanagida takuya.yanagida@univie.ac.at

Details

Sphericity

The F-Test of the repeated measures ANOVA is based on the assumption of sphericity, which is defined as the assumption that the variance of differences between repeated measures are equal in the population. The Mauchly's test is commonly used to test this hypothesis. However, test of assumptions addresses an irrelevant hypothesis because what matters is the degree of violation rather than its presence (Baguley, 2012a). Moreover, the test is not recommended because it lacks statistical power (Abdi, 2010). Instead, the Box index of sphericity (\(\varepsilon\)) should be used to assess the degree of violation of the sphericity assumption. The \(\varepsilon\) parameter indicates the degree to which the population departs from sphericity with \(\varepsilon = 1\) indicating that sphericity holds. As the departure becomes more extreme, \(\varepsilon\) approaches its lower bound \(\hat{\varepsilon}_{lb}\):

$$\hat{\varepsilon}_{lb} = \frac{1}{J - 1}$$

where \(J\) is the number of levels of the within-subject factor. Box (1954a, 1954b) suggested a measure for sphericity, which applies to a population covariance matrix. Greenhouse and Geisser (1959) proposed an estimate for \(\varepsilon\) known as \(\hat{\varepsilon}_{gg}\) that can be computed from the sample covariance matrix, whereas Huynh and Feldt (1976) proposed an alternative estimate \(\hat{\varepsilon}_{hf}\). These estimates can be used to correct the effect and error df of the F-test. Simulation studies showed that \(\hat{\varepsilon}_{gg} \leq \hat{\varepsilon}_{hf}\) and that \(\hat{\varepsilon}_{gg}\) tends to be conservative underestimating \(\varepsilon\), whereas \(\hat{\varepsilon}_{hf}\) tends to be liberal overestimating \(\varepsilon\) and occasionally exceeding one. Baguley (2012a) recommended to compute the average of the conservative estimate \(\hat{\varepsilon}_{gg}\) and the liberal estimate \(\hat{\varepsilon}_{hf}\) to assess the sphericity assumption. By default, the function prints results depending on the average \(\hat{\varepsilon}_{gg}\) and \(\hat{\varepsilon}_{hf}\):

  • If the average is less than 0.75 results of the F-Test based on Greenhouse-Geiser correction factor (\(\hat{\varepsilon}_{gg}\)) is printed.

  • If the average is less greater or equal 0.75, but less than 0.95 results of the F-Test based on Huynh-Feldt correction factor (\(\hat{\varepsilon}_{hf}\)) is printed.

  • If the average is greater or equal 0.95 results of the F-Test without any corrections are printed.

Missing Data

The function uses listwise deletion by default to deal with missing data. However, the function also allows to use all available observations by conducting the repeated measures ANOVA in long data format when specifying na.omit = FALSE. Note that in the presence of missing data, the F-Test without any sphericity corrections may be reliable, but it is not clear whether results based on Greenhouse-Geiser or Huynh-Feldt correction are trustworthy given that pairwise deletion is used for estimating the variance-covariance matrix when computing \(\hat{\varepsilon}_{gg}\) and the total number of subjects regardless of missing values (i.e., complete and incomplete cases) are used for computing \(\hat{\varepsilon}_{hf}\).

Within-Subject Confidence Intervals

The function provides a plot showing error bars for difference-adjusted Cousineau-Morey confidence intervals (Baguley, 2012b). The intervals matches that of a CI for a difference, i.e., non-overlapping CIs corresponds to an inferences of no statistically significant difference. The Cousineau-Morey confidence intervals without adjustment can be used by specifying adjust = FALSE.

References

Abdi, H. (2010). The Greenhouse-Geisser correction. In N. J. Salkind (Ed.) Encyclopedia of Research Design (pp. 630-634), Sage. https://dx.doi.org/10.4135/9781412961288

Baguley, T. S. (2012a). Serious stats: A guide to advanced statistics for the behavioral sciences. Palgrave Macmillan.

Baguley, T. (2012b). Calculating and graphing within-subject confidence intervals for ANOVA. Behavior Research Methods, 44, 158-175. https://doi.org/10.3758/s13428-011-0123-7

Bakerman, R. (2005). Recommended effect size statistics for repeated measures designs. Behavior Research Methods, 37, 179-384. https://doi.org/10.3758/BF03192707

Box, G. E. P. (1954a) Some Theorems on Quadratic Forms Applied in the Study of Analysis of Variance Problems, I. Effects of Inequality of Variance in the One-way Classification. Annals of Mathematical Statistics, 25, 290–302.

Box, G. E. P. (1954b) Some Theorems on Quadratic Forms Applied in the Study of Analysis of Variance Problems, II. Effects of Inequality of Variance and of Correlation between Errors in the Two-way Classification. Annals of Mathematical Statistics, 25, 484–98.

Greenhouse, S. W., and Geisser, S. (1959). On methods in the analysis of profile data.Psychometrika, 24, 95-112. https://doi.org/10.1007/BF02289823

Huynh, H., and Feldt, L. S. (1976). Estimation of the box correction for degrees of freedom from sample data in randomized block and splitplot designs. Journal of Educational Statistics, 1, 69-82. https://doi.org/10.2307/1164736

Olejnik, S., & Algina, J. (2000). Measures of effect size for comparative studies: Applications, interpretations, and limitations. Contemporary Educational Psychology, 25, 241-286. https://doi.org/10.1006/ceps.2000.1040

Rasch, D., Kubinger, K. D., & Yanagida, T. (2011). Statistics in psychology - Using R and SPSS. John Wiley & Sons.

See Also

aov.b, test.t, test.z, cohens.d, ci.mean.diff, ci.mean