The oneway function wraps a number of analysis of variance functions into one convenient interface that is similar to the oneway anova command in SPSS.

oneway(
  y,
  x,
  posthoc = NULL,
  means = FALSE,
  fullDescribe = FALSE,
  levene = FALSE,
  plot = FALSE,
  digits = 2,
  omegasq = TRUE,
  etasq = TRUE,
  corrections = FALSE,
  pvalueDigits = 3,
  t = FALSE,
  conf.level = 0.95,
  posthocLetters = FALSE,
  posthocLetterAlpha = 0.05,
  overrideVarNames = NULL,
  silent = FALSE
)

# S3 method for oneway
print(
  x,
  digits = x$input$digits,
  pvalueDigits = x$input$pvalueDigits,
  na.print = "",
  ...
)

# S3 method for oneway
pander(
  x,
  digits = x$input$digits,
  pvalueDigits = x$input$pvalueDigits,
  headerStyle = "**",
  na.print = "",
  ...
)

Arguments

y

y has to be a numeric vector.

x

x has to be vector that either is a factor or can be converted into one.

posthoc

Which post-hoc tests to conduct. Valid values are any correction methods in p.adjust.methods (at the time of writing of this document, "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"), as well as "tukey" and "games-howell".

means

Whether to show the means for the y variable in each of the groups determined by the x variable.

fullDescribe

If TRUE, not only the means are shown, but all statistics acquired through the 'describe' function in the 'psych' package are shown.

levene

Whether to show Levene's test for equality of variances (using car's leveneTest function but specifying mean as function to compute the center of each group).

plot

Whether to show a plot of the means of the y variable in each of the groups determined by the x variable.

digits

The number of digits to show in the output.

omegasq

Whether to show the omega squared effect size.

etasq

Whether to show the eta squared effect size (this is biased and generally advised against; omega squared is less biased).

corrections

Whether to show the corrections for unequal variances (Welch and Brown-Forsythe).

pvalueDigits

The number of digits to show for p-values; smaller p-values will be shown as <.001 or <.0001 etc.

t

Whether to transpose the dataframes with the means (if requested) and the anova results. This can be useful for blind people.

conf.level

Confidence level to use when computing the confidence interval for eta^2. Note that the function we use doubles the 'unconfidence' level to maintain consistency with the NHST value (see http://yatani.jp/HCIstats/ANOVA#RCodeOneWay, http://daniellakens.blogspot.nl/2014/06/calculating-confidence-intervals-for.html or Steiger, J. H. (2004). Beyond the F test: Effect size confidence intervals and tests of close fit in the analysis of variance and contrast analysis. Psychological methods, 9(2), 164-82. doi:10.1037/1082-989X.9.2.164

posthocLetters

Whether to also compute and show the letters signifying differences between groups when conducting post hoc tests. This requires package multcompView to be installed.

posthocLetterAlpha

The alpha to use when determining whether groups have different means when using posthocLetters.

overrideVarNames

Can be used to override the variable names (most useful in functions).

silent

Whether to show warnings and other diagnostic information or remain silent.

na.print

How to print missing values.

...

Any additional arguments are passed to the print or pander function.

headerStyle

The header pre- and suffix to use when pandering the result (useful when working with Markdown).

Value

A list of three elements:

input

List with input arguments

intermediate

List of intermediate objects, such as the aov and Anova (from the car package) objects.

output

List with etasq, the effect size, and dat, a dataframe with the Oneway Anova results.

Note

By my knowledge the Brown-Forsythe correction was not yet available in R. I took this from the original paper (directed there by Field, 2014). Note that this is the corrected F value, not the Brown-Forsythe test for normality!

References

Brown, M., & Forsythe, A. (1974). The small sample behavior of some statistics which test the equality of several means. Technometrics, 16(1), 129-132. https://doi.org/10.2307/1267501

Field, A. (2014) Discovering statistics using SPSS (4th ed.). London: Sage.

Steiger, J. H. (2004). Beyond the F test: Effect size confidence intervals and tests of close fit in the analysis of variance and contrast analysis. Psychological methods, 9(2), 164-82. doi:10.1037/1082-989X.9.2.164

Author

Gjalt-Jorn Peters

Maintainer: Gjalt-Jorn Peters gjalt-jorn@userfriendlyscience.com

Examples


### Do a oneway Anova
oneway(y=ChickWeight$weight, x=ChickWeight$Diet);
#> ### Oneway Anova for y=weight and x=Diet (groups: 1, 2, 3, 4)
#> 
#> Omega squared: 95% CI = [.02; .09], point estimate = .05
#> Eta Squared: 95% CI = [.02; .08], point estimate = .05
#> 
#>                                         SS  Df       MS     F     p
#> Between groups (error + effect)  155862.66   3 51954.22 10.81 <.001
#> Within groups (error only)      2758693.27 574  4806.09            
#> 

### Also order means and transpose the results
oneway(y=ChickWeight$weight, x=ChickWeight$Diet, means=TRUE, t=TRUE);
#> ### Oneway Anova for y=weight and x=Diet (groups: 1, 2, 3, 4)
#> 
#> Omega squared: 95% CI = [.02; .09], point estimate = .05
#> Eta Squared: 95% CI = [.02; .08], point estimate = .05
#> 
#>    Between groups (error + effect) Within groups (error only)
#> SS 155862.66                       2758693.27                
#> Df 3                               574                       
#> MS 51954.22                        4806.09                   
#> F  10.81                                                     
#> p  <.001                                                     
#> 
#> ### Means for y (weight) separate for each level of x (Diet):
#> 
#> Diet = 1:
#>             
#> n      220.0
#> mean   102.6
#> sd      56.7
#> median  88.0
#> se       3.8
#> 
#> Diet = 2:
#>             
#> n      120.0
#> mean   122.6
#> sd      71.6
#> median 104.5
#> se       6.5
#> 
#> Diet = 3:
#>             
#> n      120.0
#> mean   142.9
#> sd      86.5
#> median 125.5
#> se       7.9
#> 
#> Diet = 4:
#>             
#> n      118.0
#> mean   135.3
#> sd      68.8
#> median 129.5
#> se       6.3