Package {anovakun}


Type: Package
Title: Analysis of Variance for Factorial Designs ('ANOVA-kun')
Version: 1.1.0
Description: Performs analysis of variance for between-subjects, within-subjects and mixed factorial designs with up to 26 factors, together with stepwise multiple comparison procedures, simple effects analyses, tests of the covariance structure of repeated measures with the corresponding epsilon corrections, effect sizes with confidence intervals, and confidence intervals of cell means. It distributes the 'ANOVA-kun' functions https://riseki.cloudfree.jp/?ANOVA%E5%90%9B, which are widely used for factorial designs in Japanese psychology and whose author is listed in the Authors field, without changing their computations; the methods and their references are documented on that page, and the results are returned as objects that print the original tables.
License: MIT + file LICENSE
URL: https://github.com/kosugitti/anovakun, https://kosugitti.github.io/anovakun/
BugReports: https://github.com/kosugitti/anovakun/issues
Encoding: UTF-8
Language: en-US
Depends: R (≥ 4.1.0)
Imports: graphics, grDevices, stats, utils
Suggests: lmerTest, lme4, pbkrtest, testthat (≥ 3.0.0)
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-11-02 04:20:10 UTC; pythagoras
Author: Ryuta Iseki [aut, cph], Koji Kosugi ORCID iD [cre]
Maintainer: Koji Kosugi <kosugitti@gmail.com>
Repository: CRAN
Date/Publication: 2026-11-20 11:40:02 UTC

Analysis of variance for factorial designs (ANOVA-kun)

Description

Performs analysis of variance for between-subjects, within-subjects, and mixed designs, given the design type and the number of levels of each factor. Post hoc analyses (multiple comparisons and simple effects), sphericity tests and corrections, effect sizes and confidence intervals are included. This is the ANOVA-kun function written by Ryuta Iseki, packaged without changing its computations.

Usage

anovakun(dataset, design, ..., long = FALSE, type2 = FALSE, nopost = FALSE,
  tech = FALSE, data.frame = FALSE, copy = FALSE, holm = FALSE, hc = FALSE,
  s2r = FALSE, s2d = FALSE, fs1 = FALSE, fs2r = FALSE, fs2d = FALSE,
  welch = FALSE, criteria = FALSE, lb = FALSE, gg = FALSE, hf = FALSE,
  cm = FALSE, auto = FALSE, mau = FALSE, har = FALSE, iga = FALSE, ciga = FALSE,
  eta = FALSE, peta = FALSE, geta = NA, eps = FALSE, peps = FALSE, geps = NA,
  omega = FALSE, omegana = FALSE, pomega = FALSE, gomega = NA, gomegana = NA,
  nesci = FALSE, besci = FALSE, cilmd = FALSE, cilm = FALSE,
  cind = FALSE, cin = FALSE, ciml = FALSE, cipaird = FALSE, cipair = FALSE,
  bgraph = c(NA, NA))

## S3 method for class 'anovakun'
print(x, ...)

Arguments

x

An object of class "anovakun".

dataset

A data frame. Between-subjects factors are arranged in columns at the left (one label column per factor) and within-subjects levels across columns (wide format), unless long = TRUE.

design

A character string giving the design, e.g. "As", "sA", "AsB". Letters before s are between-subjects factors and letters after it are within-subjects factors.

...

The numbers of levels of each factor, given in order (e.g. 2, 3). Ignored by the print method.

long

If TRUE, read data in long format.

type2

If TRUE, use Type II sums of squares (default is Type III).

nopost

If TRUE, do not run post hoc analyses.

tech

If TRUE, return the results as a list of data frames (technical output).

data.frame

If TRUE, also return the data frame used in the computation.

copy

If TRUE, also copy the output to the clipboard.

holm

If TRUE, use Holm's method for multiple comparisons. With hc = TRUE, the Holm-Sidak method is used.

hc

If TRUE, use the Holland-Copenhaver method for multiple comparisons.

s2r

If TRUE, Shaffer's method counts hypotheses from the actual rejection pattern (Rasmussen's algorithm).

s2d

If TRUE, Shaffer's method counts hypotheses from the actual rejection pattern (Donoghue's algorithm).

fs1

If TRUE, use the F-Shaffer1 variant (the step-1 criterion is replaced by the step-2 criterion).

fs2r

If TRUE, combine Shaffer2 and F-Shaffer1 (Rasmussen's algorithm).

fs2d

If TRUE, combine Shaffer2 and F-Shaffer1 (Donoghue's algorithm).

welch

If TRUE, use the Keselman-Keselman-Shaffer statistic with Welch-Satterthwaite degrees of freedom in multiple comparisons.

criteria

If TRUE, show adjusted significance levels instead of adjusted p values in multiple comparisons.

lb

If TRUE, adjust degrees of freedom of all within-subjects effects by the lower bound of epsilon.

gg

If TRUE, adjust degrees of freedom of all within-subjects effects by the Greenhouse-Geisser epsilon.

hf

If TRUE, adjust degrees of freedom of all within-subjects effects by the Huynh-Feldt epsilon.

cm

If TRUE, adjust degrees of freedom of all within-subjects effects by the Chi-Muller epsilon.

auto

If TRUE, apply the Greenhouse-Geisser adjustment only to effects whose sphericity test is significant.

mau

If TRUE, use Mauchly's test of sphericity.

har

If TRUE, use Harris's multisample sphericity test.

iga

If TRUE, use the improved general approximation test.

ciga

If TRUE, use the corrected improved general approximation test.

eta

If TRUE, add eta squared to the ANOVA table.

peta

If TRUE, add partial eta squared to the ANOVA table.

geta

If TRUE, add generalized eta squared. A character string of factor labels marks those factors as measured factors.

eps

If TRUE, add epsilon squared to the ANOVA table.

peps

If TRUE, add partial epsilon squared to the ANOVA table.

geps

If TRUE, add generalized epsilon squared. A character string of factor labels marks those factors as measured factors.

omega

If TRUE, add omega squared (additive model).

omegana

If TRUE, add omega squared (nonadditive model).

pomega

If TRUE, add partial omega squared.

gomega

If TRUE, add generalized omega squared (additive model). A character string of factor labels marks measured factors.

gomegana

If TRUE, add generalized omega squared (nonadditive model). A character string of factor labels marks measured factors.

nesci

If TRUE, compute confidence intervals of the requested effect sizes based on the noncentral F distribution.

besci

If TRUE, compute bootstrap confidence intervals of the requested effect sizes.

cilmd

If TRUE, add difference-adjusted Loftus-Masson confidence intervals to the descriptive table.

cilm

If TRUE, add Loftus-Masson confidence intervals to the descriptive table.

cind

If TRUE, add difference-adjusted normalized confidence intervals to the descriptive table.

cin

If TRUE, add normalized confidence intervals to the descriptive table.

ciml

If TRUE, add confidence intervals based on a multilevel model (requires the lmerTest and pbkrtest packages).

cipaird

If TRUE, output difference-adjusted pairwise confidence intervals.

cipair

If TRUE, output pairwise confidence intervals.

bgraph

Names of confidence-interval options (inner and outer, up to two) for drawing a bar graph with confidence intervals.

Value

An object of class "anovakun". Printing it (which happens automatically when anovakun() is called at the top level) shows the tables in the same layout as the original ANOVA-kun; assigning it, as in res <- anovakun(...), shows nothing. The object is a list with the elements INFORMATION, DESCRIPTIVE STATISTICS, SPHERICITY INDICES, ANOVA TABLE, EFFECT SIZE INFORMATION (when besci = TRUE), POST ANALYSES and DATA.FRAME (when data.frame = TRUE), the same list as the technical output.

With tech = TRUE, the technical output is returned as a plain list (as in the original ANOVA-kun).

With copy = TRUE, the printed tables are also written to the clipboard. With besci = TRUE, the progress of the bootstrap is reported by message().

Author(s)

Ryuta Iseki (author); packaged by Koji Kosugi.

References

ANOVA-kun: https://riseki.cloudfree.jp/?ANOVA%E5%90%9B

Examples

# AsBC design (example from the original ANOVA-kun documentation):
# factor A (2 levels, between) x B (2 levels, within) x C (2 levels, within)
dat <- data.frame(
  A    = c("a1", "a1", "a1", "a2", "a2", "a2"),
  b1c1 = c(12, 13, 11, 18, 17, 15),
  b1c2 = c( 9, 10, 10, 12, 14, 13),
  b2c1 = c(14, 14, 13, 16, 15, 18),
  b2c2 = c(13, 12, 15, 15, 14, 15)
)
anovakun(dat, "AsBC", 2, 2, 2)

# Keep the result and look at a part of it
res <- anovakun(dat, "AsBC", 2, 2, 2, peta = TRUE)
res[["ANOVA TABLE"]][[2]]
res

Run anovakun separately for each level of a factor

Description

Splits the data by the factor given in tfact and runs anovakun for each level.

Usage

anovatan(dataset, design, ..., tfact = NULL, long = FALSE, type2 = FALSE,
  nopost = FALSE, tech = FALSE, data.frame = FALSE, copy = FALSE, holm = FALSE,
  hc = FALSE, s2r = FALSE, s2d = FALSE, fs1 = FALSE, fs2r = FALSE, fs2d = FALSE,
  welch = FALSE, criteria = FALSE, lb = FALSE, gg = FALSE, hf = FALSE,
  cm = FALSE, auto = FALSE, mau = FALSE, har = FALSE, iga = FALSE, ciga = FALSE,
  eta = FALSE, peta = FALSE, geta = NA, eps = FALSE, peps = FALSE, geps = NA,
  omega = FALSE, omegana = FALSE, pomega = FALSE, gomega = NA, gomegana = NA,
  nesci = FALSE, besci = FALSE, cilmd = FALSE, cilm = FALSE,
  cind = FALSE, cin = FALSE, ciml = FALSE, cipaird = FALSE, cipair = FALSE,
  bgraph = c(NA, NA))

## S3 method for class 'anovatan'
print(x, ...)

Arguments

x

An object of class "anovatan".

dataset

A data frame. Between-subjects factors are arranged in columns at the left (one label column per factor) and within-subjects levels across columns (wide format), unless long = TRUE.

design

A character string giving the design, e.g. "As", "sA", "AsB". Letters before s are between-subjects factors and letters after it are within-subjects factors.

...

The numbers of levels of each factor, given in order (e.g. 2, 3). Ignored by the print method.

tfact

The label of the factor by which the data are split; anovakun is run for each level of this factor.

long

If TRUE, read data in long format.

type2

If TRUE, use Type II sums of squares (default is Type III).

nopost

If TRUE, do not run post hoc analyses.

tech

If TRUE, return the results as a list of data frames (technical output).

data.frame

If TRUE, also return the data frame used in the computation.

copy

If TRUE, also copy the output to the clipboard.

holm

If TRUE, use Holm's method for multiple comparisons. With hc = TRUE, the Holm-Sidak method is used.

hc

If TRUE, use the Holland-Copenhaver method for multiple comparisons.

s2r

If TRUE, Shaffer's method counts hypotheses from the actual rejection pattern (Rasmussen's algorithm).

s2d

If TRUE, Shaffer's method counts hypotheses from the actual rejection pattern (Donoghue's algorithm).

fs1

If TRUE, use the F-Shaffer1 variant (the step-1 criterion is replaced by the step-2 criterion).

fs2r

If TRUE, combine Shaffer2 and F-Shaffer1 (Rasmussen's algorithm).

fs2d

If TRUE, combine Shaffer2 and F-Shaffer1 (Donoghue's algorithm).

welch

If TRUE, use the Keselman-Keselman-Shaffer statistic with Welch-Satterthwaite degrees of freedom in multiple comparisons.

criteria

If TRUE, show adjusted significance levels instead of adjusted p values in multiple comparisons.

lb

If TRUE, adjust degrees of freedom of all within-subjects effects by the lower bound of epsilon.

gg

If TRUE, adjust degrees of freedom of all within-subjects effects by the Greenhouse-Geisser epsilon.

hf

If TRUE, adjust degrees of freedom of all within-subjects effects by the Huynh-Feldt epsilon.

cm

If TRUE, adjust degrees of freedom of all within-subjects effects by the Chi-Muller epsilon.

auto

If TRUE, apply the Greenhouse-Geisser adjustment only to effects whose sphericity test is significant.

mau

If TRUE, use Mauchly's test of sphericity.

har

If TRUE, use Harris's multisample sphericity test.

iga

If TRUE, use the improved general approximation test.

ciga

If TRUE, use the corrected improved general approximation test.

eta

If TRUE, add eta squared to the ANOVA table.

peta

If TRUE, add partial eta squared to the ANOVA table.

geta

If TRUE, add generalized eta squared. A character string of factor labels marks those factors as measured factors.

eps

If TRUE, add epsilon squared to the ANOVA table.

peps

If TRUE, add partial epsilon squared to the ANOVA table.

geps

If TRUE, add generalized epsilon squared. A character string of factor labels marks those factors as measured factors.

omega

If TRUE, add omega squared (additive model).

omegana

If TRUE, add omega squared (nonadditive model).

pomega

If TRUE, add partial omega squared.

gomega

If TRUE, add generalized omega squared (additive model). A character string of factor labels marks measured factors.

gomegana

If TRUE, add generalized omega squared (nonadditive model). A character string of factor labels marks measured factors.

nesci

If TRUE, compute confidence intervals of the requested effect sizes based on the noncentral F distribution.

besci

If TRUE, compute bootstrap confidence intervals of the requested effect sizes.

cilmd

If TRUE, add difference-adjusted Loftus-Masson confidence intervals to the descriptive table.

cilm

If TRUE, add Loftus-Masson confidence intervals to the descriptive table.

cind

If TRUE, add difference-adjusted normalized confidence intervals to the descriptive table.

cin

If TRUE, add normalized confidence intervals to the descriptive table.

ciml

If TRUE, add confidence intervals based on a multilevel model (requires the lmerTest and pbkrtest packages).

cipaird

If TRUE, output difference-adjusted pairwise confidence intervals.

cipair

If TRUE, output pairwise confidence intervals.

bgraph

Names of confidence-interval options (inner and outer, up to two) for drawing a bar graph with confidence intervals.

Value

An object of class "anovatan": a list with results, the "anovakun" objects for each level of the split factor(s), removed, the number of cases removed because of missing values, and, if data.frame = TRUE, DATA.FRAME, the split data frames. Printing it shows the tables of each level in the same layout as the original ANOVA-kun. With tech = TRUE, a plain list is returned instead, holding in turn the heading of each level ("[[ Simple Effects for ... ]]") and its technical output (see anovakun); data.frame is ignored in this case.

Author(s)

Ryuta Iseki (author); packaged by Koji Kosugi.

References

ANOVA-kun: https://riseki.cloudfree.jp/?ANOVA%E5%90%9B

See Also

anovakun

Examples

# AsBC design: A (2 levels, between) x B (2 levels, within) x C (2 levels, within)
dat <- data.frame(
  A    = c("a1", "a1", "a1", "a2", "a2", "a2"),
  b1c1 = c(12, 13, 11, 18, 17, 15),
  b1c2 = c( 9, 10, 10, 12, 14, 13),
  b2c1 = c(14, 14, 13, 16, 15, 18),
  b2c2 = c(13, 12, 15, 15, 14, 15)
)
# Simple effects of B and C at each level of A
anovatan(dat, "AsBC", 2, 2, 2, tfact = "A")

Bar graph with confidence intervals

Description

Draws a bar graph of cell means with confidence intervals. Usually called through the bgraph option of anovakun.

Usage

ci.bars(dat, design, factnames = NA, conf.level = 0.95, inn.tier = "cind",
  out.tier = NA, main = NULL, ylab = NULL, barmin = 0)

Arguments

dat

A data frame as used inside anovakun (subject column, factor columns, and the dependent variable in long format).

design

A character string giving the design, e.g. "As", "sA", "AsB". Letters before s are between-subjects factors and letters after it are within-subjects factors.

factnames

Names of the factors. If NA, letters are used.

conf.level

Confidence level.

inn.tier

Type of the inner confidence interval (e.g. "cind").

out.tier

Type of the outer confidence interval, or NA.

main

Main title of the plot.

ylab

Label of the y axis.

barmin

Lower end of the bars.

Value

A bar graph is drawn on the current graphics device as a side effect.

Author(s)

Ryuta Iseki (author); packaged by Koji Kosugi.

References

ANOVA-kun: https://riseki.cloudfree.jp/?ANOVA%E5%90%9B

See Also

anovakun

Examples

dat <- data.frame(
  A    = c("a1", "a1", "a1", "a2", "a2", "a2"),
  b1c1 = c(12, 13, 11, 18, 17, 15),
  b1c2 = c( 9, 10, 10, 12, 14, 13),
  b2c1 = c(14, 14, 13, 16, 15, 18),
  b2c2 = c(13, 12, 15, 15, 14, 15)
)
# Usually drawn through the bgraph option of anovakun()
anovakun(dat, "AsBC", 2, 2, 2, bgraph = c("cind", "cin"))

# Direct use on the long-format data that anovakun() builds internally
long <- anovakun(dat, "AsBC", 2, 2, 2, tech = TRUE, data.frame = TRUE)$DATA.FRAME
ci.bars(long, "AsBC", inn.tier = "cind", out.tier = "cin", main = "AsBC design")

Read a data table from the clipboard

Description

A wrapper of read.table that reads from the clipboard on Windows, macOS, and Linux (requires xclip on Linux).

Usage

read.clip(...)

Arguments

...

Further arguments passed to read.table.

Value

A data frame.

Author(s)

Ryuta Iseki (author); packaged by Koji Kosugi.

References

ANOVA-kun: https://riseki.cloudfree.jp/?ANOVA%E5%90%9B

Examples

## Not run: 
# Copy a table (e.g. from a spreadsheet) to the clipboard, then:
dat <- read.clip(header = TRUE)
anovakun(dat, "AsB", 2, 3)

## End(Not run)