Type: | Package |
Title: | Bootstrapping in Different One-Way and Two-Way ANOVA |
Version: | 0.1.2 |
Depends: | R (≥ 4.3.0), afex, emmeans, lsr, methods, carData |
Date: | 2025-03-21 |
Description: | To address the violation of the assumption of normally distributed variables, researchers frequently employ bootstrapping. Building upon established packages for R (Sigmann et al. (2024) <doi:10.32614/CRAN.package.afex>, Lenth (2024) <doi:10.32614/CRAN.package.emmeans>), we provide bootstrapping functions to approximate a normal distribution of the parameter estimates for between-subject, within-subject, and mixed one-way and two-way ANOVA. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-03-25 12:53:30 UTC; christianblotner |
Author: | Lisa-Marie Segbert [aut], Christian Blötner [aut, cre] |
Maintainer: | Christian Blötner <c.bloetner@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-03-25 18:00:02 UTC |
Bootstrapped ANOVA for Between-Subject Designs
Description
In case of violations of the assumption of the normal distribution, researchers
usually employ bootstrapping. Based on the R
packages
afex and
emmeans, this
function computes bootstrapped confidence intervals for the effect sizes,
estimated marginal means, and post hoc tests for one-way and two-way ANOVAs
following a between-subject design. Furthermore, the p-values of the F-statistic
are adjusted to reflect the probability to obtain equal or higher values than
the raw, non-bootstrapped ANOVA (Stine, 1989 <doi:10.1177/0049124189018002003>;
see also this tutorial by Nadine Spychala.).
Usage
AObootBetween(var.between,
var.dv,
var.id,
levels.b1,
levels.b2 = NULL,
eff.si = c("pes", "ges"),
data,
silence = FALSE,
n.sim = 1000,
alpha = .05,
seed = 1234,
n.round = 2)
Arguments
var.between |
Variable(s) reflecting the between-subject level. |
var.dv |
Dependent variable. |
var.id |
Unique person specifier. |
levels.b1 |
Levels of the first-named independent variable. Must be identical with the levels in the dataset. |
levels.b2 |
For two-way ANOVAs. Levels of the second-named independent variable. Must be identical with the levels in the dataset. |
eff.si |
Effect size for the F-tests. "pes" reflects partial eta-squared, "ges" reflects eta-squared. |
data |
Name of the dataframe. |
silence |
Logical. If FALSE, progress of the bootstrapping procedure will be displayed. |
n.sim |
Number of bootstrap samples to be drawn. |
alpha |
Type I error. |
seed |
To make the results reproducible, it is recommended to set a random seed parameter. |
n.round |
Number of digits in the output. |
Details
The p-value of the F-test ('Pr(>F)') in the output reflects the probability to obtain an F-value as high as or higher than the F-value from the raw, non-bootstrapped ANOVA. Thus, it should not be mistaken as a p-value in the sense of a null hypothesis significance test. More information about this can be found in this tutorial by Nadine Spychala.
Value
type.aov |
Type of ANOVA conducted. |
factor |
Name of the groups in the factor (in one-way ANOVA). |
factor1 |
Name of the groups in the first factor (in two-way ANOVA). |
factor2 |
Name of the groups in the second factor (in two-way ANOVA). |
anova |
Results of the conducted ANOVA (i.e., degrees of freedom, F-test, p-value, effect size with bootstrap confidence interval, and numbers of tests for which convergence was achieved. |
em |
Estimated marginal means in one-way ANOVA. |
em.1 |
Estimated marginal means for factor 1 in two-way ANOVA. |
em.2 |
Estimated marginal means for factor 2 in two-way ANOVA. |
em.3 |
Estimated marginal means for factor 1 by factor 2 in two-way ANOVA. |
em.4 |
Estimated marginal means for factor 2 by factor 1 in two-way ANOVA. |
no.test |
Number of post hoc tests in one-way ANOVAs for which convergence was achieved. |
no.test1 |
Number of post hoc tests for factor 1 in two-way ANOVAs for which convergence was achieved. |
no.test2 |
Number of post hoc tests for factor 2 in two-way ANOVAs for which convergence was achieved. |
no.test3 |
Number of post hoc tests for factor 1 by factor 2 in two-way ANOVAs for which convergence was achieved. |
no.test4 |
Number of post hoc tests for factor 2 by factor 1 in two-way ANOVAs for which convergence was achieved. |
ph |
Post hoc tests in one-way ANOVAs. |
ph.1 |
Post hoc tests for factor 1 in two-way ANOVAs. |
ph.2 |
Post hoc tests for factor 2 in two-way ANOVAs. |
ph.3 |
Post hoc tests for factor 1 by factor 2 in two-way ANOVAs. |
ph.4 |
Post hoc tests for factor 2 by factor 1 in two-way ANOVAs. |
Author(s)
Lisa-Marie Segbert, Christian Blötner c.bloetner@gmail.com
References
Stine, R. (1989). An introduction to bootstrap methods: Examples and ideas. Sociological Methods & Research, 18(2-3), 243–291. <https://doi.org/10.1177/0049124189018002003>
Examples
library(carData)
# The OBrienKaiser dataset from the carData package
ao <- OBrienKaiser
# Add a unique person identifier to the dataset
ao$pers <- 1:nrow(OBrienKaiser)
# One-way between-subjects ANOVA
AObootBetween(
var.between = "treatment",
var.dv = "pre.1",
var.id = "pers",
levels.b1 = c("control", "A", "B"),
eff.si = "ges",
data = ao,
n.sim = 1000,
alpha = .05,
seed = 1234,
n.round = 2)
# Two-way between-subjects ANOVA
AObootBetween(
var.between = c("treatment", "gender"),
var.dv = "pre.1",
var.id = "pers",
levels.b1 = c("control", "A", "B"),
levels.b2 = c("M", "F"),
eff.si = "pes",
data = ao,
n.sim = 1000,
alpha = .05,
seed = 1236,
n.round = 2)
Bootstrapped ANOVA for Mixed Designs
Description
In case of violations of the assumption of the normal distribution, researchers
usually employ bootstrapping. Based on the R
packages
afex and
emmeans, this function
computes bootstrapped confidence intervals for the effect sizes, estimated
marginal means, and post hoc tests for Mixed ANOVAs. Furthermore, the p-values
of the F-statistic are adjusted to reflect the probability to obtain equal or
higher values than the raw, non-bootstrapped ANOVA (Stine, 1989 <doi:10.1177/0049124189018002003>; see
also this tutorial by Nadine Spychala.).
Usage
AObootMixed(var.within,
var.between,
var.id,
levels.w1,
levels.b1,
eff.si = c("pes", "ges"),
data,
silence = FALSE,
n.sim = 1000,
alpha = .05,
seed = 1234,
n.round = 2)
Arguments
var.within |
Variable(s) reflecting the within-subject level. |
var.between |
Variable(s) reflecting the between-subject level. |
var.id |
Unique person specifier. |
levels.w1 |
Levels of the within-subjects variable. Must be identical with the levels in the dataset. |
levels.b1 |
Levels of the between-subjects variable. Must be identical with the levels in the dataset. |
eff.si |
Effect size for the F-tests. |
data |
Name of the dataframe. The dataset must be in a wide-format, with
one row per participant. If the original data is available in long format, we
advise users to apply the |
silence |
Logical. If FALSE, progress of the bootstrapping procedure will be displayed. |
n.sim |
Number of bootstrap samples to be drawn. |
alpha |
Type I error. |
seed |
To make the results reproducible, it is recommended to set a random seed parameter. |
n.round |
Number of digits in the output. |
Details
The p-value of the F-test (Pr(>F)
) in the output reflects the
probability to obtain an F-value as high as or higher than the F-value from the
raw, non-bootstrapped ANOVA. Thus, it should not be mistaken as a p-value in the
sense of a null hypothesis significance test. More information about this can be
found in this tutorial by Nadine Spychala.
Value
type.aov |
Type of ANOVA conducted. |
factor1 |
Name of the groups in the between factor. |
factor2 |
Name of the groups in the within factor. |
anova |
Results of the conducted ANOVA (i.e., degrees of freedom, F-test, p-value, effect size with bootstrap confidence interval, and numbers of tests for which convergence was achieved. |
em.1 |
Estimated marginal means for between factor. |
em.2 |
Estimated marginal means for within factor. |
em.3 |
Estimated marginal means for between factor by within factor. |
em.4 |
Estimated marginal means for within factor by between factor. |
no.test1 |
Number of post hoc tests for the between factor for which convergence was achieved. |
no.test2 |
Number of post hoc tests for the within factor for which convergence was achieved. |
no.test3 |
Number of post hoc tests for the between factor by within factor for which convergence was achieved. |
no.test4 |
Number of post hoc tests for within factor by between factor for which convergence was achieved. |
ph.1 |
Post hoc tests for between factor. |
ph.2 |
Post hoc tests for within factor. |
ph.3 |
Post hoc tests for between factor by within factor. |
ph.4 |
Post hoc tests for within factor by between factor. |
output <- list(type.aov = "Two-way mixed ANOVA", factor1 = levels.b1, factor2 = levels.w1, anova = round(orig.aov$anova_table, n.round), em.1 = dat.em1, no.test1 = no.test1, ph.1 = dat.ph1, em.2 = dat.em2, no.test2 = no.test2, ph.2 = dat.ph2, em.3 = dat.em3, no.test3 = no.test3, ph.3 = dat.ph3, em.4 = dat.em4, no.test4 = no.test4, ph.4 = dat.ph4)
Author(s)
Lisa-Marie Segbert, Christian Blötner c.bloetner@gmail.com
References
Stine, R. (1989). An introduction to bootstrap methods: Examples and ideas. Sociological Methods & Research, 18(2-3), 243–291. <https://doi.org/10.1177/0049124189018002003>
Examples
library(carData)
# The OBrienKaiser dataset from the carData package
ao <- OBrienKaiser
# Add a unique person identifier to the dataset
ao$pers <- 1:nrow(OBrienKaiser)
# Mixed ANOVA
AObootMixed(
var.within = c("pre.1", "post.1", "fup.1"),
var.between = "treatment",
var.id = "pers",
levels.w1 = c("pre", "post", "fup"),
levels.b1 = c("control", "A", "B"),
eff.si = "pes",
data = ao,
n.sim = 1000,
alpha = .05,
seed = 1234,
n.round = 2)
Bootstrapped ANOVA for Within-Subject Designs
Description
In case of violations of the assumption of the normal distribution, researchers
usually employ bootstrapping. Based on the R
packages
afex and
emmeans, this function
computes bootstrapped confidence intervals for the effect sizes, estimated
marginal means, and post hoc tests for one-way and two-way ANOVAs following a
within-subject design. Furthermore, the p-values of the F-statistic are adjusted
to reflect the probability to obtain equal or higher values than the raw,
non-bootstrapped ANOVA (Stine, 1989 <doi:10.1177/0049124189018002003>; see
also this tutorial by Nadine Spychala.).
Usage
AObootWithin(var.within,
var.id,
levels.w1,
levels.w2 = NULL,
eff.si = c("pes", "ges"),
data,
silence = FALSE,
n.sim = 1000,
alpha = .05,
seed = 1234,
n.round = 2)
Arguments
var.within |
Variable(s) reflecting the within-subject level. |
var.id |
Unique person specifier. |
levels.w1 |
Levels of the first-named independent variable. Must be identical with the levels in the dataset. |
levels.w2 |
For two-way ANOVAs. Levels of the second-named independent variable. Must be identical with the levels in the dataset. |
eff.si |
Effect size for the F-tests. |
data |
Name of the dataframe. The dataset must be in a wide-format, with
one row per participant. If the original data is available in long format, we
advise users to apply the |
silence |
Logical. If FALSE, progress of the bootstrapping procedure will be displayed. |
n.sim |
Number of bootstrap samples to be drawn. |
alpha |
Type I error. |
seed |
To make the results reproducible, it is recommended to set a random seed parameter. |
n.round |
Number of digits in the output. |
Details
The p-value of the F-test (Pr(>F)
) in the output reflects the
probability to obtain an F-value as high as or higher than the F-value from the
raw, non-bootstrapped ANOVA. Thus, it should not be mistaken as a p-value in the
sense of a null hypothesis significance test. More information about this can be
found in this tutorial by Nadine Spychala.
Value
type.aov |
Type of ANOVA conducted. |
factor |
Name of the groups in the factor (in one-way ANOVA). |
factor1 |
Name of the groups in the first factor (in two-way ANOVA). |
factor2 |
Name of the groups in the second factor (in two-way ANOVA). |
anova |
Results of the conducted ANOVA (i.e., degrees of freedom, F-test, p-value, effect size with bootstrap confidence interval, and numbers of tests for which convergence was achieved. |
em |
Estimated marginal means in one-way ANOVA. |
em.1 |
Estimated marginal means for factor 1 in two-way ANOVA. |
em.2 |
Estimated marginal means for factor 2 in two-way ANOVA. |
em.3 |
Estimated marginal means for factor 1 by factor 1 in two-way ANOVA. |
em.4 |
Estimated marginal means for factor 2 by factor 1 in two-way ANOVA. |
no.test |
Number of post hoc tests in one-way ANOVAs for which convergence was achieved. |
no.test1 |
Number of post hoc tests for factor 1 in two-way ANOVAs for which convergence was achieved. |
no.test2 |
Number of post hoc tests for factor 2 in two-way ANOVAs for which convergence was achieved. |
no.test3 |
Number of post hoc tests for factor 1 by factor 2 in two-way ANOVAs for which convergence was achieved. |
no.test4 |
Number of post hoc tests for factor 2 by factor 1 in two-way ANOVAs for which convergence was achieved. |
ph |
Post hoc tests in one-way ANOVAs. |
ph.1 |
Post hoc tests for factor 1 in two-way ANOVAs. |
ph.2 |
Post hoc tests for factor 2 in two-way ANOVAs. |
ph.3 |
Post hoc tests for factor 1 by factor 2 in two-way ANOVAs. |
ph.4 |
Post hoc tests for factor 2 by factor 1 in two-way ANOVAs. |
Author(s)
Lisa-Marie Segbert, Christian Blötner c.bloetner@gmail.com
References
Stine, R. (1989). An introduction to bootstrap methods: Examples and ideas. Sociological Methods & Research, 18(2-3), 243–291. <https://doi.org/10.1177/0049124189018002003>
Examples
library(carData)
# The OBrienKaiser dataset from the carData package
ao <- OBrienKaiser
# Add a unique person identifier to the dataset
ao$pers <- 1:nrow(OBrienKaiser)
# One-way within-subjects ANOVA
AObootWithin(
var.within = c("pre.1", "post.1", "fup.1"),
var.id = "pers",
levels.w1 = c("pre", "post", "fup"),
eff.si = "ges",
data = ao,
n.sim = 1000,
alpha = .05,
seed = 1234,
n.round = 2)
# Two-way within-subjects ANOVA
AObootWithin(
var.within = c("pre.1", "pre.2", "pre.3", "pre.4", "pre.5",
"post.1", "post.2", "post.3", "post.4", "post.5",
"fup.1", "fup.2", "fup.3", "fup.4", "fup.5"),
var.id = "pers",
levels.w1 = c("pre", "post", "fup"),
levels.w2 = c("1", "2", "3", "4", "5"),
eff.si = "pes",
data = ao,
n.sim = 1000,
alpha = .05,
seed = 1234,
n.round = 2)
AOboot.one Class
Description
A S3 class to represent one-way ANOVAs.
Usage
AOboot_one(type.aov, factor, anova, em, no.test, ph)
Arguments
type.aov |
Character string giving the type of ANOVA computed. |
factor |
Names of groups in the entered factor. |
anova |
Results of the ANOVA. |
em |
Bootstrapped estimated marginal means. |
no.test |
Number of tests conducted that did not produce errors. |
ph |
Bootstrapped post hoc tests. |
Value
An object of class "AOboot.one"
.
AOboot.two Class
Description
A S3 class to represent two-way ANOVAs.
Usage
AOboot_two(
type.aov,
factor1,
factor2,
anova,
em.1,
no.test1,
ph.1,
em.2,
no.test2,
ph.2,
em.3,
no.test3,
ph.3,
em.4,
no.test4,
ph.4
)
Arguments
type.aov |
Character string giving the type of ANOVA computed. |
factor1 |
Names of groups in the first factor. |
factor2 |
Names of groups in the second factor. |
anova |
Results of the ANOVA. |
em.1 |
Bootstrapped estimated marginal means for factor 1. |
no.test1 |
Number of bootstrapped tests conducted for factor 1 that did not produce errors. |
ph.1 |
Bootstrapped post hoc tests for factor 1. |
em.2 |
Bootstrapped estimated marginal means for factor 2. |
no.test2 |
Number of bootstrapped tests conducted for factor 2 that did not produce errors. |
ph.2 |
Bootstrapped post hoc tests for factor 2. |
em.3 |
Bootstrapped estimated marginal means for factor 1 by factor 2. |
no.test3 |
Number of bootstrapped tests conducted for factor 1 by factor 2 that did not produce errors. |
ph.3 |
Bootstrapped post hoc tests for factor 1 by factor 2. |
em.4 |
Bootstrapped estimated marginal means for factor 2 by factor 1. |
no.test4 |
Number of bootstrapped tests conducted for factor 2 by factor 1 that did not produce errors. |
ph.4 |
Bootstrapped post hoc tests for factor 2 by factor 1. |
Value
An object of class "AOboot.two"
.