A dataframe containing results for one-way ANOVA.

To see details about functions which are internally used to carry out these analyses, see the following vignette- https://indrajeetpatil.github.io/statsExpressions/articles/stats_details.html

oneway_anova(
  data,
  x,
  y,
  subject.id = NULL,
  type = "parametric",
  paired = FALSE,
  k = 2L,
  conf.level = 0.95,
  effsize.type = "omega",
  var.equal = FALSE,
  bf.prior = 0.707,
  tr = 0.2,
  nboot = 100L,
  top.text = NULL,
  ...
)

Arguments

data

A dataframe (or a tibble) from which variables specified are to be taken. Other data types (e.g., matrix,table, array, etc.) will not be accepted.

x

The grouping (or independent) variable from the dataframe data. In case of a repeated measures or within-subjects design, if subject.id argument is not available or not explicitly specified, the function assumes that the data has already been sorted by such an id by the user and creates an internal identifier. So if your data is not sorted, the results can be inaccurate when there are more than two levels in x and there are NAs present. The data is expected to be sorted by user in subject-1,subject-2, ..., pattern.

y

The response (or outcome or dependent) variable from the dataframe data.

subject.id

Relevant in case of a repeated measures or within-subjects design (paired = TRUE, i.e.), it specifies the subject or repeated measures identifier. Important: Note that if this argument is NULL (which is the default), the function assumes that the data has already been sorted by such an id by the user and creates an internal identifier. So if your data is not sorted and you leave this argument unspecified, the results can be inaccurate when there are more than two levels in x and there are NAs present.

type

A character specifying the type of statistical approach:

  • "parametric"

  • "nonparametric"

  • "robust"

  • "bayes"

This argument also accepts the following abbreviations: "p" (for parametric), "np" (for nonparametric), "r" (for robust), "bf" (for Bayes Factor or Bayesian).

paired

Logical that decides whether the experimental design is repeated measures/within-subjects or between-subjects. The default is FALSE.

k

Number of digits after decimal point (should be an integer) (Default: k = 2L).

conf.level

Scalar between 0 and 1. If unspecified, the defaults return 95% confidence/credible intervals (0.95).

effsize.type

Type of effect size needed for parametric tests. The argument can be "eta" (partial eta-squared) or "omega" (partial omega-squared).

var.equal

a logical variable indicating whether to treat the two variances as being equal. If TRUE then the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used.

bf.prior

A number between 0.5 and 2 (default 0.707), the prior width to use in calculating Bayes factors and posterior estimates. In addition to numeric arguments, several named values are also recognized: "medium", "wide", and "ultrawide", corresponding to r scale values of 1/2, sqrt(2)/2, and 1, respectively. In case of an ANOVA, this value corresponds to scale for fixed effects.

tr

Trim level for the mean when carrying out robust tests. In case of an error, try reducing the value of tr, which is by default set to 0.2. Lowering the value might help.

nboot

Number of bootstrap samples for computing confidence interval for the effect size (Default: 100L).

top.text

Text to display on top of the Bayes Factor message. This is mostly relevant in the context of ggstatsplot functions.

...

Additional arguments (currently ignored).

Note

To carry out Bayesian posterior estimation for ANOVA designs, you will need to install the development version of BayesFactor (0.9.12-4.3). You can download it by running: remotes::install_github("richarddmorey/BayesFactor/pkg/BayesFactor").

Examples

# \donttest{ # for reproducibility set.seed(123) library(statsExpressions) options(tibble.width = Inf, pillar.bold = TRUE, pillar.neg = TRUE) # ----------------------- parametric ------------------------------------- # between-subjects oneway_anova( data = ggplot2::msleep, x = vore, y = sleep_rem )
#> # A tibble: 1 x 11 #> statistic df df.error p.value #> <dbl> <dbl> <dbl> <dbl> #> 1 2.63 3 11.1 0.102 #> method estimate conf.level #> <chr> <dbl> <dbl> #> 1 One-way analysis of means (not assuming equal variances) 0.245 0.95 #> conf.low conf.high effectsize expression #> <dbl> <dbl> <chr> <list> #> 1 0 0.539 Omega2 <language>
if (require("afex", quietly = TRUE)) { # within-subjects design oneway_anova( data = iris_long, x = condition, y = value, subject.id = id, paired = TRUE ) }
#> Registered S3 methods overwritten by 'car': #> method from #> influence.merMod lme4 #> cooks.distance.influence.merMod lme4 #> dfbeta.influence.merMod lme4 #> dfbetas.influence.merMod lme4
#> ************ #> Welcome to afex. For support visit: http://afex.singmann.science/
#> - Functions for ANOVAs: aov_car(), aov_ez(), and aov_4() #> - Methods for calculating p-values with mixed(): 'KR', 'S', 'LRT', and 'PB' #> - 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests #> - NEWS: library('emmeans') now needs to be called explicitly! #> - Get and set global package options with: afex_options() #> - Set orthogonal sum-to-zero contrasts globally: set_sum_contrasts() #> - For example analyses see: browseVignettes("afex") #> ************
#> #> Attaching package: ‘afex’
#> The following object is masked from ‘package:lme4’: #> #> lmer
#> # A tibble: 1 x 15 #> term sumsq sum.squares.error df df.error meansq statistic p.value #> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 condition 1656. 318. 1.15 171. 1.86 776. 1.32e-69 #> method estimate conf.level #> <chr> <dbl> <dbl> #> 1 ANOVA estimation for factorial designs using 'afex' 0.707 0.95 #> conf.low conf.high effectsize expression #> <dbl> <dbl> <chr> <list> #> 1 0.666 0.740 Omega2 (partial) <language>
# ----------------------- non-parametric ---------------------------------- # between-subjects oneway_anova( data = ggplot2::msleep, x = vore, y = sleep_rem, type = "np" )
#> # A tibble: 1 x 12 #> parameter1 parameter2 statistic df.error p.value method #> <chr> <chr> <dbl> <int> <dbl> <chr> #> 1 sleep_rem vore 9.06 3 0.0285 Kruskal-Wallis rank sum test #> estimate conf.level conf.low conf.high effectsize expression #> <dbl> <dbl> <dbl> <dbl> <chr> <list> #> 1 0.165 0.95 0.0503 0.364 Epsilon2 (rank) <language>
# within-subjects design oneway_anova( data = iris_long, x = condition, y = value, subject.id = id, paired = TRUE, type = "np" )
#> # A tibble: 1 x 12 #> parameter1 parameter2 statistic df.error p.value method #> <chr> <chr> <dbl> <dbl> <dbl> <chr> #> 1 value condition 410 3 1.51e-88 Friedman rank sum test #> estimate conf.level conf.low conf.high effectsize expression #> <dbl> <dbl> <dbl> <dbl> <chr> <list> #> 1 0.911 0.95 0.903 0.922 Kendall's W <language>
# ----------------------- robust ------------------------------------- # between-subjects oneway_anova( data = ggplot2::msleep, x = vore, y = sleep_rem, type = "r" )
#> # A tibble: 1 x 11 #> statistic df df.error p.value estimate conf.level conf.low conf.high #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 2.76 3 9.37 0.102 0.806 0.95 0.363 1.58 #> effectsize #> <chr> #> 1 Explanatory measure of effect size #> method expression #> <chr> <list> #> 1 A heteroscedastic one-way ANOVA for trimmed means <language>
# within-subjects design oneway_anova( data = iris_long, x = condition, y = value, subject.id = id, paired = TRUE, type = "r" )
#> # A tibble: 1 x 11 #> statistic df df.error p.value #> <dbl> <dbl> <dbl> <dbl> #> 1 368. 1.09 97.1 0 #> method estimate #> <chr> <dbl> #> 1 A heteroscedastic one-way repeated measures ANOVA for trimmed means -0.349 #> conf.low conf.high conf.level #> <dbl> <dbl> <dbl> #> 1 -0.740 0.152 0.95 #> effectsize expression #> <chr> <list> #> 1 Algina-Keselman-Penfield robust standardized difference average <language>
# ----------------------- Bayesian ------------------------------------- # between-subjects oneway_anova( data = ggplot2::msleep, x = vore, y = sleep_rem, type = "bayes" )
#> # A tibble: 7 x 19 #> term estimate conf.level conf.low conf.high pd rope.percentage #> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 mu 2.18 0.95 1.77 2.58 1 0 #> 2 vore-carni 0.0836 0.95 -0.554 0.688 0.602 0.349 #> 3 vore-herbi -0.738 0.95 -1.27 -0.219 0.998 0 #> 4 vore-insecti 0.845 0.95 -0.0476 1.77 0.975 0.0239 #> 5 vore-omni -0.196 0.95 -0.739 0.322 0.758 0.337 #> 6 sig2 1.55 0.95 1.05 2.26 1 0 #> 7 g_vore 0.456 0.95 0.0441 2.61 1 0.0806 #> prior.distribution prior.location prior.scale component bf10 #> <chr> <dbl> <dbl> <chr> <dbl> #> 1 cauchy 0 0.707 extra 3.41 #> 2 cauchy 0 0.707 conditional 3.41 #> 3 cauchy 0 0.707 conditional 3.41 #> 4 cauchy 0 0.707 conditional 3.41 #> 5 cauchy 0 0.707 conditional 3.41 #> 6 cauchy 0 0.707 extra 3.41 #> 7 cauchy 0 0.707 extra 3.41 #> method r2 std.dev r2.conf.level r2.conf.low #> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 Bayes factors for linear models 0.111 0.111 0.95 0 #> 2 Bayes factors for linear models 0.111 0.111 0.95 0 #> 3 Bayes factors for linear models 0.111 0.111 0.95 0 #> 4 Bayes factors for linear models 0.111 0.111 0.95 0 #> 5 Bayes factors for linear models 0.111 0.111 0.95 0 #> 6 Bayes factors for linear models 0.111 0.111 0.95 0 #> 7 Bayes factors for linear models 0.111 0.111 0.95 0 #> r2.conf.high expression #> <dbl> <list> #> 1 0.271 <language> #> 2 0.271 <language> #> 3 0.271 <language> #> 4 0.271 <language> #> 5 0.271 <language> #> 6 0.271 <language> #> 7 0.271 <language>
# within-subjects design # needs `BayesFactor 0.9.12-4.3` or above if (utils::packageVersion("BayesFactor") >= package_version("0.9.12-4.3")) { oneway_anova( data = iris_long, x = condition, y = value, subject.id = id, paired = TRUE, type = "bayes" ) } # }