if (FALSE) { # requireNamespace("afex", quietly = TRUE)
# \donttest{
# for reproducibility
set.seed(123)
library(statsExpressions)
library(afex) # for within-subjects parametric ANOVA
options(tibble.width = Inf, pillar.bold = TRUE, pillar.neg = TRUE)
# ----------------------- parametric -------------------------------------
# between-subjects
oneway_anova(
data = mtcars,
x = cyl,
y = wt
)
# within-subjects design
oneway_anova(
data = iris_long,
x = condition,
y = value,
subject.id = id,
paired = TRUE
)
# ----------------------- non-parametric ----------------------------------
# between-subjects
oneway_anova(
data = mtcars,
x = cyl,
y = wt,
type = "np"
)
# within-subjects design
oneway_anova(
data = iris_long,
x = condition,
y = value,
subject.id = id,
paired = TRUE,
type = "np"
)
# ----------------------- robust -------------------------------------
# between-subjects
oneway_anova(
data = mtcars,
x = cyl,
y = wt,
type = "r"
)
# within-subjects design
oneway_anova(
data = iris_long,
x = condition,
y = value,
subject.id = id,
paired = TRUE,
type = "r"
)
# ----------------------- Bayesian -------------------------------------
# between-subjects
oneway_anova(
data = mtcars,
x = cyl,
y = wt,
type = "bayes"
)
# within-subjects design
oneway_anova(
data = iris_long,
x = condition,
y = value,
subject.id = id,
paired = TRUE,
type = "bayes"
)
# }
}
Run the code above in your browser using DataLab