Skip to contents

Graeco-Latin square four-way ANOVA (row, col, Latin, Greek)

Usage

mrm_graeco_latin(data, response_col, row_col, col_col, latin_col, greek_col)

Arguments

data

data.frame.

response_col, row_col, col_col, latin_col, greek_col

Column names.

Value

Named list with anova, n, interpretation.

Examples

# Hardcoded 4 x 4 orthogonal Graeco-Latin square (two random Latin
# squares are generally NOT orthogonal, so we use a known pair):
L <- matrix(c(
  "A", "B", "C", "D",
  "B", "A", "D", "C",
  "C", "D", "A", "B",
  "D", "C", "B", "A"
), nrow = 4L, byrow = TRUE)
G <- matrix(c(
  "a", "b", "c", "d",
  "c", "d", "a", "b",
  "d", "c", "b", "a",
  "b", "a", "d", "c"
), nrow = 4L, byrow = TRUE)
set.seed(2026)
df <- expand.grid(row = paste0("R", 1:4), col = paste0("C", 1:4))
df$latin <- as.vector(L)
df$greek <- as.vector(G)
df$y <- match(df$latin, LETTERS) * 1.2 +
  match(df$greek, letters) * 0.5 + rnorm(16, 0, 0.3)
res <- mrm_graeco_latin(df,
  response_col = "y",
  row_col = "row", col_col = "col",
  latin_col = "latin", greek_col = "greek"
)
res$anova
#>   Df     Sum Sq     Mean Sq    F value      Pr(>F)    source
#> 1  3  0.2907400  0.09691333  0.8156641 0.564521845       row
#> 2  3  0.2510331  0.08367769  0.7042673 0.609912435       col
#> 3  3 30.0077721 10.00259071 84.1860821 0.002151595     latin
#> 4  3  5.4000489  1.80001630 15.1497072 0.025666420     greek
#> 5  3  0.3564458  0.11881525         NA          NA Residuals